spynnaker.pyNN.models package

Subpackages

Submodules

spynnaker.pyNN.models.abstract_pynn_model module

class spynnaker.pyNN.models.abstract_pynn_model.AbstractPyNNModel[source]

Bases: AbstractProvidesDefaults

A Model that can be passed in to a Population object in PyNN.

absolute_max_atoms_per_core = 9223372036854775807
abstractmethod create_vertex(n_neurons: int, label: str) PopulationApplicationVertex[source]

Create a vertex for a population of the model.

Parameters:
  • n_neurons – The number of neurons in the population

  • label – The label to give to the vertex

Returns:

An application vertex for the population

default_population_parameters: Dict[str, Any] = {}

The default values for the parameters at the population level. These are parameters that can be passed in to the Population constructor in addition to the standard PyNN options.

describe(template: str | None = 'modeltype_default.txt', engine: str = 'default') str[source]

Returns a human-readable description of the population.

The output may be customised by specifying a different template together with an associated template engine (see pyNN.descriptions).

If template is None, then a dictionary containing the template context will be returned.

Parameters:
  • template – Template filename

  • engine – Template substitution engine

Returns:

A human-readable description

classmethod get_model_max_atoms_per_dimension_per_core() Tuple[int, ...][source]
Returns:

The maximum number of atoms per dimension per core for this model.

classmethod get_parameter_names() Sequence[str][source]
Returns:

The names of the parameters of the model.

classmethod has_parameter(name: str) bool[source]
Parameters:

name – The name of the parameter to check for

Returns:

True if the model has a parameter with the given name

property name: str

The name of this model.

classmethod reset_all() None[source]

Reset the maximum values for all classes.

classmethod set_model_max_atoms_per_dimension_per_core(n_atoms: None | int | Tuple[int, ...] = None) None[source]

Set the default maximum number of atoms per dimension per core for this model. This can be overridden by the individual Population. The new value can be None, meaning that the maximum is the same as the number of atoms, an int, meaning all Populations of this model must have one dimension, or a tuple of n integers, meaning all Populations of this model must have n dimensions. If not all Populations of this model have the same number of dimensions, it is recommended to set this to None here and then set the maximum on each Population.

Parameters:

n_atoms – The new maximum, or None for the largest possible

classmethod verify_may_set(param: str) None[source]
If a Population has been created, this method will raise an

exception; used to avoid setting global limits after a Population has been created.

Parameters:

param – The parameter name that can be used to set the value being changed in the Population constructor instead.

spynnaker.pyNN.models.defaults module

Decorators to support default argument handling.

class spynnaker.pyNN.models.defaults.AbstractProvidesDefaults[source]

Bases: object

Provides the default_parameters and default_initial_values properties

These will be filled in based on the @default_parameters and @default_initial_values decorators with values read from the init.

default_initial_values = mappingproxy({})
default_parameters = mappingproxy({})
spynnaker.pyNN.models.defaults.default_initial_values(state_variables: Iterable[str]) Callable[source]

Specifies arguments which are state variables. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

state_variables – The names of the arguments that are state variables

Returns:

A check method to be called when first used

spynnaker.pyNN.models.defaults.default_parameters(parameters: Iterable[str]) Callable[source]

Specifies arguments which are parameters. Only works on the __init__ method of a class that is additionally decorated with defaults()

Parameters:

parameters – The names of the arguments that are parameters

Returns:

A check method to be called when first used

spynnaker.pyNN.models.defaults.get_map_from_init(init_method: Callable, skip: FrozenSet[str] | None = None, include: FrozenSet[str] | None = None) Mapping[str, Any][source]

Get an argument initialisation dictionary by examining an __init__ method or function.

Parameters:
  • init_method – The method.

  • skip – The arguments to be skipped, if any

  • include – The arguments that must be present, if any

Returns:

an initialisation dictionary

spynnaker.pyNN.models.projection module

class spynnaker.pyNN.models.projection.Projection(pre_synaptic_population: _Pop, post_synaptic_population: _Pop, connector: AbstractConnector, synapse_type: AbstractSynapseDynamics | None = None, source: None = None, receptor_type: str = 'excitatory', space: PyNNSpace | None = None, label: str | None = None, download_synapses: bool = False, partition_id: str | None = None)[source]

Bases: object

A container for all the connections of a given type (same synapse type and plasticity mechanisms) between two populations, together with methods to set parameters of those connections, including of plasticity mechanisms.

Parameters:
  • pre_synaptic_population

  • post_synaptic_population

  • connector

  • synapse_type

  • source – Unsupported; must be None

  • receptor_type

  • space

  • label

  • download_synapses

get(attribute_names: str | Sequence[str], format: str, gather: Literal[True] = True, with_address: bool = True, multiple_synapses: Literal['last'] = 'last') ConnectionHolder[source]

Get a parameter/attribute of the projection.

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names – list of attributes to gather

  • format"list" or "array"

  • gather – Ignored. Purely for PyNN compatibility

  • with_address – True if the source and target are to be included

  • multiple_synapses – What to do with the data if format=”array” and if the multiple source-target pairs with the same values exist. Currently only “last” is supported

Returns:

values selected

property label: str

Label of this Projection

property post: _Pop

The post-population or population view.

property pre: _Pop

The pre-population or population view.

save(attribute_names: str | Sequence[str], file: str | BaseFile, format: str = 'list', gather: Literal[True] = True, with_address: bool = True) None[source]

Print synaptic attributes (weights, delays, etc.) to file. In the array format, zeros are printed for non-existent connections. Values will be expressed in the standard PyNN units (i.e., millivolts, nanoamps, milliseconds, microsiemens, nanofarads, event per second).

Note

SpiNNaker always gathers.

Parameters:
  • attribute_names

  • file – filename or open handle (which will be closed)

  • format

  • gather – Ignored. Purely for PyNN compatibility

  • with_address

set(**attributes: Any) Never[source]

Warning

Not implemented.

set_download_synapses(download_synapses: bool) None[source]

Set whether synapses should be downloaded when the simulation pauses.

Parameters:

download_synapses – Whether to download synapses or not

size(gather: bool = True) Never[source]

Return the total number of connections.

Note

SpiNNaker always gathers.

Warning

Not implemented.

Parameters:

gather – If False, only get the number of connections locally.

spynnaker.pyNN.models.recorder module

class spynnaker.pyNN.models.recorder.Recorder(population: Population, vertex: PopulationApplicationVertex)[source]

Bases: object

Object to hold recording behaviour, used by populations.

Parameters:
  • population – the population to record for

  • vertex – the SpiNNaker graph vertex used by the population

extract_neo_block(variables: Names, view_indexes: Sequence[int] | None, clear: bool, annotations: Dict[str, Any] | None) neo.Block[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables – the variables to extract

  • view_indexes – the indexes to be included in the view

  • clear – if the variables should be cleared after reading

  • annotations – annotations to put on the Neo block

Returns:

The Neo block

Raises:

ConfigurationException – If the recording not setup correctly

record(variables: Names, to_file: IoDest, sampling_interval: int | None, indexes: Collection[int] | None) None[source]

Turns on (or off) recording.

Parameters:
  • variables – 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. Can also be None to reset the list of variables.

  • to_file – a file to automatically record to (optional). write_data() will be automatically called when sim.end() is called.

  • sampling_interval – a value in milliseconds, and an integer multiple of the simulation timestep.

  • indexes – The indexes of neurons to record from. This is non-standard PyNN and equivalent to creating a view with these indexes and asking the View to record.

property recording_label: str

The label from the vertex is applicable or a default.

turn_off_all_recording(indexes: Collection[int] | None = None) None[source]

Turns off recording, is used by a pop saying .record().

Parameters:

indexes

turn_on_record(variable: str, sampling_interval: int | None = None, to_file: str | neo.baseio.BaseIO | None = None, indexes: Collection[int] | None = None) None[source]

Tell the vertex to record data.

Parameters:
  • variable – The variable to record, supported variables to record are: gsyn_exc, gsyn_inh, v, spikes.

  • sampling_interval – the interval to record them

  • to_file – If set, a file to write to (by handle or name)

  • indexes – List of indexes to record or None for all

Raises:
  • SimulatorRunningException – If sim.run is currently running

  • SimulatorNotSetupException – If called before sim.setup

  • SimulatorShutdownException – If called after sim.end

write_data(csv_file: str, variables: Names | None, view_indexes: Sequence[int] | None = None, annotations: Dict[str, Any] | None = None) None[source]

Extracts block from the vertices and puts them into a Neo block.

Parameters:
  • variables – the variables to extract

  • variables – the variables to extract

  • view_indexes – the indexes to be included in the view

  • annotations – annotations to put on the Neo block

Raises:

ConfigurationException – If the recording not setup correctly

property write_to_files_indicators: Mapping[str, str | neo.baseio.BaseIO | None]

What variables should be written to files, and where should they be written.

Module contents