spynnaker.pyNN.utilities.ranged package¶
Module contents¶
- class spynnaker.pyNN.utilities.ranged.SpynnakerRangedList(size: int | None = None, value: T | Callable[[int], T] | Sequence[T] | None = None, key: str | None = None, use_list_as_value: bool = False)¶
Bases:
RangedListAdds support for
RandomDistributiontoRangedList.- Parameters:
size – Fixed length of the list; if
None, the value must be a sized object.value – value to given to all elements in the list
key – The dict key this list covers. This is used only for better Exception messages
use_list_as_value – True if the value is a list
- as_list(value: Callable[[int], T] | Sequence[T] | RandomDistribution, size: int, ids: Sequence[int] | ndarray[tuple[Any, ...], dtype[integer]] | None = None) List[T][source]¶
Converts (if required) the value into a list of a given size. An exception is raised if value cannot be given size elements.
Note
This method can be extended to add other conversions to list in which case
listness_check()must also be extended.- Parameters:
value – Either a method that takes an int as input or something that can have the list method applied.
size – The number of elements to put in the list.
ids – A list of IDs to call the function for or
Noneto use the size. Only used if the value is a callable.
- Returns:
value as a list
- Raises:
Exception – if the number of values and the size do not match
- listness_check(value: T | Callable[[int], T] | Sequence[T] | RandomDistribution | None) bool[source]¶
Easier to override in subclasses as not type guard.
Note
This method can be extended to add other checks for list in which case
as_list()must also be extended.- Parameters:
value – The value to examine.
- Returns:
True if the value should be treated as a list