Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 21 additions & 60 deletions spynnaker/pyNN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,16 @@ def distance(src_cell: IDMixin, tgt_cell: IDMixin,

:param src_cell: Measure from this cell
:param tgt_cell: To this cell
:param ~numpy.ndarray mask:
:param mask:
allows only certain dimensions to be considered, e.g.:

* to ignore the z-dimension, use ``mask=array([0,1])``
* to ignore y, ``mask=array([0,2])``
* to just consider z-distance, ``mask=array([2])``
:param float scale_factor:
:param scale_factor:
allows for different units in the pre- and post-position
(the post-synaptic position is multiplied by this quantity).
:param float offset:
:param offset:
:param periodic_boundaries:
"""
return _pynn_distance(
Expand All @@ -275,31 +275,22 @@ def setup(timestep: Optional[Union[float, Literal["auto"]]] = None,
:param timestep:
the time step of the simulations in microseconds;
if `None`, the configuration value is used
:type timestep: float or None
:param min_delay: the minimum delay of the simulation
:type min_delay: float or str
:param max_delay: Ignored and logs a warning if provided
:type max_delay: float or str or None
:param database_socket_addresses: the sockets used by external devices
for the database notification protocol
:type database_socket_addresses:
iterable(~spinn_utilities.socket_address.SocketAddress)
:param time_scale_factor: multiplicative factor to the machine time step
(does not affect the neuron models accuracy)
:type time_scale_factor: int or None
:param n_chips_required:
Deprecated! Use n_boards_required instead.
Must be `None` if n_boards_required specified.
:type n_chips_required: int or None
:param n_boards_required:
if you need to be allocated a machine (for spalloc) before building
your graph, then fill this in with a general idea of the number of
boards you need so that the spalloc system can allocate you a machine
big enough for your needs.
:type n_boards_required: int or None
:param extra_params: other keyword arguments used to configure PyNN
:return: MPI rank (always 0 on SpiNNaker)
:rtype: int
:raises \
~spinn_front_end_common.utilities.exceptions.ConfigurationException:
if both ``n_chips_required`` and ``n_boards_required`` are used.
Expand Down Expand Up @@ -358,8 +349,6 @@ def setup(timestep: Optional[Union[float, Literal["auto"]]] = None,
def name() -> str:
"""
Returns the name of the simulator.

:rtype: str
"""
return SpynnakerDataView.get_sim_name()

Expand All @@ -377,23 +366,16 @@ def Projection(
Used to support PEP 8 spelling correctly.

:param presynaptic_population: the source pop
:type presynaptic_population:
~spynnaker.pyNN.models.populations.Population
:param postsynaptic_population: the destination population
:type postsynaptic_population:
~spynnaker.pyNN.models.populations.Population
:param AbstractConnector connector: the connector type
:param AbstractStaticSynapseDynamics synapse_type: the synapse type
:param None source: Unsupported; must be ``None``
:param str receptor_type: the receptor type
:param connector: the connector type
:param synapse_type: the synapse type
:param source: Unsupported; must be ``None``
:param receptor_type: the receptor type
:param space: the space object
:type space: ~pyNN.space.Space or None
:param label: the label
:type label: str or None
:param bool download_synapses: whether to download synapses
:param str partition_id: the partition id to use for the projection
:param download_synapses: whether to download synapses
:param partition_id: the partition id to use for the projection
:return: a projection object for SpiNNaker
:rtype: ~spynnaker.pyNN.models.projection.Projection
"""
return SpiNNakerProjection(
pre_synaptic_population=presynaptic_population,
Expand Down Expand Up @@ -457,8 +439,6 @@ def list_standard_models() -> List[str]:
"""
Return a list of all the StandardCellType classes available for this
simulator.

:rtype: list(str)
"""
return [
key
Expand All @@ -482,9 +462,8 @@ def set_number_of_neurons_per_core(
dimensions, it is recommended to set this to `None` here and then
set the maximum on each Population.

:param type(PopulationVertex) neuron_type: neuron type
:param neuron_type: neuron type
:param max_permitted: the number to set to
:type max_permitted: int or tuple or None
"""
if isinstance(neuron_type, str):
raise ConfigurationException(
Expand Down Expand Up @@ -546,13 +525,13 @@ def connect(pre: Population, post: Population, weight: float = 0.0,
"""
Builds a projection.

:param ~spynnaker.pyNN.models.populations.Population pre: source pop
:param ~spynnaker.pyNN.models.populations.Population post: destination pop
:param float weight: weight of the connections
:param float delay: the delay of the connections
:param str receptor_type: excitatory / inhibitory
:param float p: probability
:param ~pyNN.random.NumpyRNG rng: random number generator
:param pre: source pop
:param post: destination pop
:param weight: weight of the connections
:param delay: the delay of the connections
:param receptor_type: excitatory / inhibitory
:param p: probability
:param rng: random number generator
"""
SpynnakerDataView.check_user_can_act()
__pynn["connect"](pre, post, weight, delay, receptor_type, p, rng)
Expand All @@ -566,10 +545,8 @@ def create(
Builds a population with certain parameters.

:param cellclass: population class
:type cellclass: type or AbstractPyNNModel
:param cellparams: population parameters.
:param int n: number of neurons
:rtype: ~spynnaker.pyNN.models.populations.Population
:param n: number of neurons
"""
SpynnakerDataView.check_user_can_act()
return __pynn["create"](cellclass, cellparams, n)
Expand All @@ -580,7 +557,6 @@ def NativeRNG(seed_value: Union[int, List[int], NDArray]) -> None:
Fixes the random number generator's seed.

:param seed_value:
:type seed_value: int or list(int) or ~numpy.ndarray(int32)
"""
__numpy.random.seed(seed_value)

Expand All @@ -601,7 +577,6 @@ def get_min_delay() -> int:
least this.

:return: returns the min delay of the simulation
:rtype: int
"""
SpynnakerDataView.check_user_can_act()
return __pynn["get_min_delay"]()
Expand All @@ -626,7 +601,6 @@ def get_time_step() -> float:
The integration time step.

:return: get the time step of the simulation (in ms)
:rtype: float
"""
SpynnakerDataView.check_user_can_act()
return float(__pynn["get_time_step"]())
Expand All @@ -637,8 +611,6 @@ def initialize(cells: PopulationBase, **initial_values: Any) -> None:
Sets cells to be initialised to the given values.

:param cells: the cells to change parameters on
:type cells: ~spynnaker.pyNN.models.populations.Population or
~spynnaker.pyNN.models.populations.PopulationView
:param initial_values: the parameters and their values to change
"""
SpynnakerDataView.check_user_can_act()
Expand All @@ -653,7 +625,6 @@ def num_processes() -> int:
Always 1 on SpiNNaker, which doesn't use MPI.

:return: the number of MPI processes
:rtype: int
"""
SpynnakerDataView.check_user_can_act()
return __pynn["num_processes"]()
Expand All @@ -667,7 +638,6 @@ def rank() -> int:
Always 0 on SpiNNaker, which doesn't use MPI.

:return: MPI rank
:rtype: int
"""
SpynnakerDataView.check_user_can_act()
return __pynn["rank"]()
Expand All @@ -682,17 +652,12 @@ def record(variables: Union[str, Sequence[str]], source: PopulationBase,
:param variables: may be either a single variable name or a list of
variable names. For a given `celltype` class, `celltype.recordable`
contains a list of variables that can be recorded for that `celltype`.
:type variables: str or list(str)
:param source: where to record from
:type source: ~spynnaker.pyNN.models.populations.Population or
~spynnaker.pyNN.models.populations.PopulationView
:param str filename: file name to write data to
:param filename: file name to write data to
:param sampling_interval:
how often to sample the recording, not ignored so far
:param annotations: the annotations to data writers
:type annotations: dict(str, ...)
:return: neo object
:rtype: ~neo.core.Block
"""
SpynnakerDataView.check_user_can_act()
return __pynn["record"](variables, source, filename, sampling_interval,
Expand All @@ -704,7 +669,6 @@ def reset(annotations: Optional[Dict[str, Any]] = None) -> None:
Resets the simulation to t = 0.

:param annotations: the annotations to the data objects
:type annotations: dict(str, ...)
"""
if annotations is None:
annotations = {}
Expand All @@ -717,10 +681,9 @@ def run(simtime: float, callbacks: Optional[Callable] = None) -> float:
The run() function advances the simulation for a given number of
milliseconds.

:param float simtime: time to run for (in milliseconds)
:param simtime: time to run for (in milliseconds)
:param callbacks: callbacks to run
:return: the actual simulation time that the simulation stopped at
:rtype: float
"""
SpynnakerDataView.check_user_can_act()
return __pynn["run"](simtime, callbacks)
Expand All @@ -735,9 +698,8 @@ def run_until(tstop: float) -> float:
"""
Run until a (simulation) time period has completed.

:param float tstop: the time to stop at (in milliseconds)
:param tstop: the time to stop at (in milliseconds)
:return: the actual simulation time that the simulation stopped at
:rtype: float
"""
SpynnakerDataView.check_user_can_act()
return __pynn["run_until"](tstop, None)
Expand All @@ -748,7 +710,6 @@ def get_machine() -> Machine:
Get the SpiNNaker machine in use.

:return: the machine object
:rtype: ~spinn_machine.Machine
"""
SpynnakerDataView.check_user_can_act()
return SpynnakerDataView.get_machine()
Expand Down
10 changes: 3 additions & 7 deletions spynnaker/pyNN/connections/ethernet_command_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ def __init__(
local_host: Optional[str] = None,
local_port: Optional[int] = NOTIFY_PORT):
"""
:param AbstractEthernetTranslator translator:
:param translator:
A translator of multicast commands to device commands
:param command_containers:
A list of vertices that have commands to be sent at the start
and end of simulation
:type command_containers:
list(~spinn_front_end_common.abstract_models.AbstractSendMeMulticastCommandsVertex)
:param str local_host:
:param local_host:
The optional host to listen on for the start/resume message
:param int local_port:
:param local_port:
The optional port to listen on for the stop/pause message
"""
super().__init__(
Expand All @@ -69,8 +67,6 @@ def add_command_container(
:param command_container:
A vertex that has commands to be sent at the start and end of
simulation
:type command_container:
~spinn_front_end_common.abstract_models.AbstractSendMeMulticastCommandsVertex
"""
if not isinstance(
command_container, AbstractSendMeMulticastCommandsVertex):
Expand Down
16 changes: 7 additions & 9 deletions spynnaker/pyNN/connections/ethernet_control_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ def __init__(
live_packet_gather_label: str, local_host: Optional[str] = None,
local_port: Optional[int] = None):
"""
:param AbstractEthernetTranslator translator:
The translator of multicast to control commands
:param str label: The label of the vertex to attach the translator to
:param str live_packet_gather_label: The label of the LPG vertex that
:param translator: The translator of multicast to control commands
:param label: The label of the vertex to attach the translator to
:param live_packet_gather_label: The label of the LPG vertex that
this control connection will listen to.
:param str local_host: The optional host to listen on
:param int local_port: The optional port to listen on
:param local_host: The optional host to listen on
:param local_port: The optional port to listen on
"""
super().__init__(
live_packet_gather_label, receive_labels=[label],
Expand All @@ -51,9 +50,8 @@ def add_translator(
"""
Add another translator that routes via the LPG.

:param str label: The label of the vertex to attach the translator to
:param AbstractEthernetTranslator translator:
The translator of multicast to control commands
:param label: The label of the vertex to attach the translator to
:param translator: The translator of multicast to control commands
"""
super().add_receive_label(label)
self.__translators[label] = translator
Expand Down
Loading
Loading