pacman.model.routing_info package¶
Module contents¶
-
class
pacman.model.routing_info.
AbstractMachinePartitionNKeysMap
[source]¶ Bases:
object
A map that provides the number of keys required by each partition
-
n_keys_for_partition
(partition)[source]¶ The number of keys required by the given partition
Parameters: partition (AbstractSingleSourcePartition) – The partition to set the number of keys for Returns: The number of keys required by the partition Return type: int
-
-
class
pacman.model.routing_info.
BaseKeyAndMask
(base_key, mask)[source]¶ Bases:
object
A Key and Mask to be used for routing.
Parameters: Raises: PacmanConfigurationException – If key & mask != key i.e. the key is not valid for the given mask
-
get_keys
(key_array=None, offset=0, n_keys=None)[source]¶ Get the ordered list of keys that the combination allows
Parameters: - key_array (ndarray(int)) – Optional array into which the returned keys will be placed
- offset (int) – Optional offset into the array at which to start placing keys
- n_keys (int) – Optional limit on the number of keys returned. If less than this number of keys are available, only the keys available will be added
Returns: A tuple of an array of keys and the number of keys added to the array
Return type:
-
-
class
pacman.model.routing_info.
DictBasedMachinePartitionNKeysMap
[source]¶ Bases:
pacman.model.routing_info.abstract_machine_partition_n_keys_map.AbstractMachinePartitionNKeysMap
A python dict-based implementation of the
AbstractMachinePartitionNKeysMap
-
NOT_EXIST_ERROR_MESSAGE
= 'Partition {} does not exist in the mapping to n keys'¶
-
n_keys_for_partition
(partition)[source]¶ The number of keys required by the given partition
Parameters: partition (AbstractSingleSourcePartition) – The partition to set the number of keys for Returns: The number of keys required by the partition Return type: int
-
set_n_keys_for_partition
(partition, n_keys)[source]¶ Set the number of keys required by a machine outgoing edge partition
Parameters: - partition (AbstractSingleSourcePartition) – The partition to set the number of keys for
- n_keys (int) – The number of keys required by the edge
-
-
class
pacman.model.routing_info.
PartitionRoutingInfo
(keys_and_masks, partition)[source]¶ Bases:
object
Associates a partition to its routing information (keys and masks).
Parameters: - keys_and_masks (iterable(BaseKeyAndMask)) – The keys allocated to the machine partition
- partition (AbstractSingleSourcePartition) – The partition to set the number of keys for
-
first_key_and_mask
¶ The first key and mask (or only one if there is only one)
Return type: BaseKeyAndMask
-
get_keys
(n_keys=None)[source]¶ Get the ordered list of individual keys allocated to the edge
Parameters: n_keys (int) – Optional limit on the number of keys to return Returns: An array of keys Return type: ndarray
-
keys_and_masks
¶ Return type: iterable(BaseKeyAndMask)
-
partition
¶ Return type: AbstractSingleSourcePartition
-
class
pacman.model.routing_info.
RoutingInfo
(partition_info_items=None)[source]¶ Bases:
object
An association of a set of edges to a non-overlapping set of keys and masks.
Parameters: partition_info_items (iterable(PartitionRoutingInfo) or None) – The partition information items to add Raises: PacmanAlreadyExistsException – If there are two partition information objects with the same partition -
add_partition_info
(partition_info)[source]¶ Add a partition information item
Parameters: partition_info (PartitionRoutingInfo) – The partition information item to add Return type: None Raises: PacmanAlreadyExistsException – If the partition is already in the set of edges
-
get_first_key_for_edge
(edge)[source]¶ Get routing key for an edge
Parameters: edge (AbstractEdge) – The edge to search for
-
get_first_key_from_partition
(partition)[source]¶ Get the first key associated with a particular partition
Parameters: partition (AbstractSingleSourcePartition) – The partition to get the first key of Returns: The routing key, or None if the partition does not exist Return type: int or None
-
get_first_key_from_pre_vertex
(vertex, partition_id)[source]¶ Get the first key for the partition starting at a (pre)vertex
Parameters: - vertex (AbstractVertex) – The vertex which the partition starts at
- partition_id (str) – The ID of the partition for which to get the routing information
Returns: The routing key of the partition
Return type:
-
get_routing_info_for_edge
(edge)[source]¶ Get routing information for an edge
Parameters: edge (AbstractEdge) – The edge to search for
-
get_routing_info_from_partition
(partition)[source]¶ Get the routing information for a given partition.
Parameters: partition (AbstractSingleSourcePartition) – The partition to obtain routing information about. Returns: the partition_routing_info for the partition, if any exists Return type: PartitionRoutingInfo or None
-
get_routing_info_from_pre_vertex
(vertex, partition_id)[source]¶ Get routing information for edges with a given partition_id from a prevertex
Parameters: - vertex (AbstractVertex) – The prevertex to search for
- partition_id (str) – The ID of the partition for which to get the routing information
-