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=None, use_list_as_value=False)

Bases: RangedList

Adds support for RandomDistribution to RangedList.

Parameters:
  • size (int or None) – Fixed length of the list; if None, the value must be a sized object.

  • value (object or Sized) – 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 (bool) – True if the value is a list

as_list(value, size, ids=None)[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

Returns:

value as a list

Raises:

Exception – if the number of values and the size do not match

listness_check(value)[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.