spynnaker.pyNN.utilities package

Subpackages

Submodules

spynnaker.pyNN.utilities.bit_field_utilities module

spynnaker.pyNN.utilities.bit_field_utilities.FILTER_HEADER_WORDS = 2

n_filters, pointer for array

spynnaker.pyNN.utilities.bit_field_utilities.get_bitfield_key_map_data(incoming_projections)[source]

Get data for the key map region.

Parameters:

incoming_projections (iterable(Projection)) – The projections to generate bitfields for

Return type:

ndarray

spynnaker.pyNN.utilities.bit_field_utilities.get_sdram_for_bit_field_region(incoming_projections)[source]

The SDRAM for the bit field filter region.

Parameters:

incoming_projections (iterable(Projection)) – The projections that target the vertex in question

Returns:

the estimated number of bytes used by the bit field region

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.get_sdram_for_keys(incoming_projections)[source]

Gets the space needed for keys.

Parameters:

incoming_projections (iterable(Projection)) – The projections that target the vertex in question

Returns:

SDRAM needed

Return type:

int

spynnaker.pyNN.utilities.bit_field_utilities.write_bitfield_init_data(spec, bit_field_region, n_bit_field_bytes, bit_field_region_ref=None)[source]

Writes the initialisation data needed for the bitfield generator.

Parameters:
  • spec (DataSpecificationGenerator) – data specification writer

  • bit_field_region (int) – the region ID for the bit-field filters

  • n_bit_field_bytes (int) – the size of the region

  • bit_field_region_ref (int) – The reference to the region

spynnaker.pyNN.utilities.buffer_data_type module

class spynnaker.pyNN.utilities.buffer_data_type.BufferDataType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Different functions to retrieve the data.

This class is designed to used internally by NeoBufferDatabase

EIEIO_SPIKES = 2
MATRIX = 4
MULTI_SPIKES = 3
NEURON_SPIKES = 1
NOT_NEO = 6
REWIRES = 5

spynnaker.pyNN.utilities.constants module

spynnaker.pyNN.utilities.constants.LIVE_POISSON_CONTROL_PARTITION_ID = 'CONTROL'

The partition ID used for Poisson live control data

spynnaker.pyNN.utilities.constants.MIN_SUPPORTED_DELAY = 1

the minimum supported delay slot between two neurons

spynnaker.pyNN.utilities.constants.OUT_SPIKE_BYTES = 32

The number of bytes for each spike line

spynnaker.pyNN.utilities.constants.OUT_SPIKE_SIZE = 8

The size of each output spike line

spynnaker.pyNN.utilities.constants.POP_TABLE_MAX_ROW_LENGTH = 256

The maximum row length of the master population table

spynnaker.pyNN.utilities.constants.SPIKE_PARTITION_ID = 'SPIKE'

The partition ID used for spike data

spynnaker.pyNN.utilities.constants.SYNAPSE_SDRAM_PARTITION_ID = 'SDRAM Synaptic Inputs'

The name of the partition for Synaptic SDRAM

spynnaker.pyNN.utilities.constants.SYNAPTIC_ROW_HEADER_WORDS = 3

Words: 2 for row length and number of rows and 1 for plastic region size (which might be 0)

spynnaker.pyNN.utilities.constants.WRITE_BANDWIDTH_BYTES_PER_SECOND = 262144000

The conservative amount of write bandwidth available on a chip

spynnaker.pyNN.utilities.data_population module

class spynnaker.pyNN.utilities.data_population.DataPopulation(database_file, label, indexes=None)[source]

Bases: object

describe(template=None, engine=None)[source]

Returns a human-readable description of the population.

The output may be customized 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 (str) – Template filename

  • engine (str or TemplateEngine or None) – Template substitution engine

Return type:

str or dict

find_units(variable)[source]

Get the units of a variable.

Parameters:

variable (str) – The name of the variable

Returns:

The units of the variable

Return type:

str

get_data(variables='all', gather=True, clear=False, annotations=None)[source]

Return a Neo Block containing the data (spikes, state variables) recorded from the Assembly.

Parameters:
  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to collect data from all MPI nodes or just the current node.

    Note

    This is irrelevant on sPyNNaker, which always behaves as if this parameter is True.

  • clear (bool) – Whether recorded data will be deleted from the Assembly.

  • annotations (dict(str, ...)) – annotations to put on the neo block

Return type:

Block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

get_spike_counts(gather=True)[source]

Return the number of spikes for each neuron.

Return type:

ndarray

id_to_index(id)[source]

Given the ID(s) of cell(s) in the Population, return its (their) index (order in the Population).

Defined by https://neuralensemble.org/docs/PyNN/reference/populations.html

Parameters:

id (int or iterable(int)) –

Return type:

int or iterable(int)

index_to_id(index)[source]

Given the index (order in the Population) of cell(s) in the Population, return their ID(s)

Parameters:

index (int or iterable(int)) –

Return type:

int or iterable(int)

property label
property local_size
mean_spike_count(gather=True)[source]

Returns the mean number of spikes per neuron.

Parameters:

gather (bool) –

For parallel simulators, if this is True, all data will be gathered to all nodes and the Neo Block will contain data from all nodes. Otherwise, the Neo Block will contain only data from the cells simulated on the local node.

Note

SpiNNaker always gathers.

Return type:

float

property size
spinnaker_get_data(variable, as_matrix=False, view_indexes=None)[source]

Public accessor for getting data as a numpy array, instead of the Neo-based object

Parameters:
  • variable (str or list(str)) – a single variable name.

  • as_matrix (bool) – If set True the data is returned as a 2d matrix

  • view_indexes – The indexes for which data should be returned. If None, all data (view_index = data_indexes)

Returns:

array of the data

Return type:

ndarray

write_data(io, variables='all', gather=True, clear=False, annotations=None)[source]

Write recorded data to file, using one of the file formats supported by Neo.

Parameters:
  • io (neo.io.baseio.BaseIO or str) – a Neo IO instance, or a string for where to put a neo instance

  • variables (str or list(str)) – either a single variable name or a list of variable names. Variables must have been previously recorded, otherwise an Exception will be raised.

  • gather (bool) –

    Whether to bring all relevant data together.

    Note

    SpiNNaker always gathers.

  • clear (bool) – clears the storage data if set to true after reading it back

  • annotations (dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the variable or variables have not been previously set to record.

spynnaker.pyNN.utilities.extracted_data module

class spynnaker.pyNN.utilities.extracted_data.ExtractedData[source]

Bases: object

Data holder for all synaptic data being extracted in parallel.

get(projection, attribute)[source]

Allow getting data from a given projection and attribute.

Parameters:
  • projection (Projection) – the projection data was extracted from

  • attribute (list(int) or tuple(int) or None) – the attribute to retrieve

Returns:

the attribute data in a connection holder

Return type:

ConnectionHolder

set(projection, attribute, data)[source]

Allow the addition of data from a projection and attribute.

Parameters:
  • projection (Projection) – the projection data was extracted from

  • attribute (list(int) or tuple(int) or None) – the attribute to store

  • data (ConnectionHolder) – attribute data in a connection holder

spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider module

class spynnaker.pyNN.utilities.fake_HBP_Portal_machine_provider.FakeHBPPortalMachineProvider(n_boards, config)[source]

Bases: object

create()[source]
destroy()[source]
get_machine_info()[source]
wait_till_not_ready()[source]
wait_until_ready()[source]

spynnaker.pyNN.utilities.neo_buffer_database module

class spynnaker.pyNN.utilities.neo_buffer_database.NeoBufferDatabase(database_file=None, read_only=None)[source]

Bases: BufferDatabase, NeoCsv

Extra support for Neo on top of the Database for SQLite 3.

This is the same database as used by BufferManager but with extra tables and access methods added.

Parameters:
  • database_file (None or str) – The name of a file that contains (or will contain) an SQLite database holding the data. If omitted the default location will be used.

  • read_only (bool) – By default the database is read-only if given a database file. This allows to override that (mainly for clear)

add_segment(block, pop_label, variables, view_indexes=None)[source]

Adds a segment to the block.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

Raises:

ConfigurationException – If the recording metadata not setup correctly

static array_to_string(indexes)[source]

Converts a list of integers into a compact string. Works best if the list is sorted.

IDs are comma separated, except when a series of IDs is sequential then the start:end is used.

Parameters:

indexes (list(int)) –

Return type:

str

clear_data(pop_label, variables)[source]

Clears the data for one population and given variables.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typical the Population label, corrected for None or duplicate values

  • variables (list(str)) – names of variable to get data for

csv_block_metadata(csv_file, pop_label, annotations=None)[source]

Writes the data including metadata to a CSV file. Overwrites any previous data in the file.

Parameters:
  • csvfile (str) – Path to file to write block metadata to

  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Raises:

ConfigurationException – If the recording metadata not setup correctly

csv_segment(csv_file, pop_label, variables, view_indexes=None)[source]

Writes the data including metadata to a CSV file.

Parameters:
  • csvfile (str) – Path to file to write block metadata to

  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typical the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_empty_block(pop_label, annotations=None)[source]

Creates a block with just metadata but not data segments.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Returns:

The Neo block

Return type:

Block

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_full_block(pop_label, variables, view_indexes, annotations)[source]

Creates a block with metadata and data for this segment. Any previous segments will be empty.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variables (str, list(str) or None) – One or more variable names or None for all available

  • view_indexes (None or list(int)) – List of neurons IDs to include or None for all

  • annotations (None or dict(str, ...)) – annotations to put on the neo block

Returns:

The Neo block

Return type:

Block

get_population(pop_label)[source]

Gets an Object with the same data retrieval API as a Population.

Retrieval is limited to recorded data and a little metadata needed to create a single Neo Segment wrapped in a Neo Block.

Note

As each database only includes data for one run (with resets creating another database) the structure is relatively simple.

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

An Object which acts like a Population for getting neo data

Return type:

DataPopulation

get_population_metdadata(pop_label)[source]

Gets the metadata for the population with this label

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

population size, first id and description

Return type:

(int, int, str)

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_recording_metadeta(pop_label, variable)[source]

Gets the metadata ID for this population and recording label combination.

Parameters:
  • pop_label (str) –

    The label for the population of interest

    Note

    This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

  • variable (str) –

Returns:

data_type, t_start, sampling_interval_ms, first_id, pop_size, units

Return type:

(DataType, float, float, int, int, str)

Raises:

ConfigurationException – If the recording metadata not setup correctly

get_recording_populations()[source]

Gets a list of the labels of Populations recording. Or to be exact the ones with metadata saved so likely to be recording.

Note

These are actually the labels of the Application Vertices. Typically the Population label, corrected for None or duplicate values

Returns:

List of population labels

Return type:

list(str)

get_recording_variables(pop_label)[source]

List of the names of variables recording. Or, to be exact, list of the names of variables with metadata so likely to be recording.

Parameters:

pop_label (str) –

The label for the population of interest

Note

This is actually the label of the Application Vertex. Typically the Population label, corrected for None or duplicate values

Returns:

List of variable names

get_spike_counts(pop_label, view_indexes=None)[source]
spinnaker_get_data(pop_label, variable, as_matrix=False, view_indexes=None)[source]
static string_to_array(string)[source]

Converts a string into a list of integers. Assumes the string was created by array_to_string()

Parameters:

string (str) –

Return type:

list(int)

write_metadata()[source]

Write the current metadata to the database.

Note

The database must be writable for this to work!

write_segment_metadata()[source]

Writes the global information from the Views.

This writes information held in SpynnakerDataView so that the database is usable stand-alone.

Note

The database must be writable for this to work!

write_t_stop()[source]

Records the current run time as t_Stop.

This writes information held in SpynnakerDataView so that the database is usable stand-alone.

Note

The database must be writable for this to work!

spynnaker.pyNN.utilities.neo_compare module

spynnaker.pyNN.utilities.neo_compare.compare_analogsignal(as1, as2, same_length=True)[source]

Compares two analog signal objects to see if they are the same.

Parameters:
  • as1 (AnalogSignal) – first analog signal holding list of individual analog signal objects

  • as2 (AnalogSignal) – second analog signal holding list of individual analog signal objects

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the analog signals are not equal

spynnaker.pyNN.utilities.neo_compare.compare_blocks(neo1, neo2, same_runs=True, same_data=True, same_length=True)[source]

Compares two neo Blocks to see if they hold the same data.

Parameters:
  • neo1 (Block) – First block to check

  • neo2 (Block) – Second block to check

  • same_runs (bool) – Flag to signal if blocks are the same length. If False extra segments in the larger block are ignored

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False only data in both blocks is compared

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the blocks are not equal

spynnaker.pyNN.utilities.neo_compare.compare_segments(seg1, seg2, same_data=True, same_length=True)[source]
Parameters:
  • seg1 (Segment) – First Segment to check

  • seg2 (Segment) – Second Segment to check

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False only data in both blocks is compared

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional data after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the segments are not equal

spynnaker.pyNN.utilities.neo_compare.compare_spiketrain(spiketrain1, spiketrain2, same_length=True)[source]

Checks two spike trains have the exact same data.

Parameters:
  • spiketrain1 (SpikeTrain) – first spike train

  • spiketrain2 (SpikeTrain) – second spike train

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional spikes after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the spike trains are not equal

spynnaker.pyNN.utilities.neo_compare.compare_spiketrains(spiketrains1, spiketrains2, same_data=True, same_length=True)[source]

Check two Lists of spike trains have the exact same data.

Parameters:
  • spiketrains1 (list(SpikeTrain)) – First list of spike trains to compare

  • spiketrains2 (list(SpikeTrain)) – Second list of spike trains to compare

  • same_data (bool) – Flag to indicate if the same type of data is held, i.e., same spikes, v, gsyn_exc and gsyn_inh. If False allows one or both lists to be Empty. Even if False none empty lists must be the same length

  • same_length (bool) – Flag to indicate if the same length of data is held, i.e., all spikes up to the same time. If False allows one trains to have additional spikes after the first ends. This is used to compare data extracted part way with data extracted at the end.

Raises:

AssertionError – If the spike trains are not equal

spynnaker.pyNN.utilities.neo_convertor module

spynnaker.pyNN.utilities.neo_convertor.convert_analog_signal(signal_array, time_unit=quantities.ms)[source]

Converts part of a NEO object into told spynnaker7 format.

Parameters:
  • signal_array (AnalogSignal) – Extended Quantities object

  • time_unit (quantities.unitquantity.UnitTime) – Data time unit for time index

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_data(data, name, run=0)[source]

Converts the data into a numpy array in the format ID, time, value.

Parameters:
  • data (Block) – Data as returned by a getData() call

  • name (str) – Name of the data to be extracted. Same values as used in getData()

  • run (int) – Zero based index of the run to extract data for

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_data_list(data, name, runs=None)[source]

Converts the data into a list of numpy arrays in the format ID, time, value.

Parameters:
  • data (Block) – Data as returned by a getData() call

  • name (str) – Name of the data to be extracted. Same values as used in getData()

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn(gsyn_exc, gsyn_inh)[source]

Converts two neo objects into the spynnaker7 format.

Note

It is acceptable for both neo parameters to be the same object

Parameters:
  • gsyn_exc (Block) – neo with gsyn_exc data

  • gsyn_inh (Block) – neo with gsyn_exc data

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn_exc_list(data, runs=None)[source]

Converts the gsyn_exc into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have Gsyn_exc data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_gsyn_inh_list(data, runs=None)[source]

Converts the gsyn_inh into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have Gsyn_inh data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.convert_spikes(neo, run=0)[source]

Extracts the spikes for run one from a Neo Object.

Parameters:
  • neo (Block) – neo Object including Spike Data

  • run (int) – Zero based index of the run to extract data for

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_spiketrains(spiketrains)[source]

Converts a list of spiketrains into spynnaker7 format.

Parameters:

spiketrains (list(SpikeTrain)) – List of SpikeTrains

Return type:

ndarray

spynnaker.pyNN.utilities.neo_convertor.convert_v_list(data, runs=None)[source]

Converts the voltage into a list numpy array one per segment (all runs) in the format ID, time, value.

Parameters:
  • data (Block) – The data to convert; it must have V data in it

  • runs (list(int) or None) – List of Zero based index of the run to extract data for. Or None to extract all runs

Return type:

list(ndarray)

spynnaker.pyNN.utilities.neo_convertor.count_spikes(neo)[source]

Help function to count the number of spikes in a list of spiketrains.

Only counts run 0

Parameters:

neo (Block) – Neo Object which has spikes in it

Returns:

The number of spikes in the first segment

spynnaker.pyNN.utilities.neo_convertor.count_spiketrains(spiketrains)[source]

Help function to count the number of spikes in a list of spiketrains.

Parameters:

spiketrains (list(SpikeTrain)) – List of SpikeTrains

Returns:

Total number of spikes in all the spiketrains

Return type:

int

spynnaker.pyNN.utilities.neo_csv module

class spynnaker.pyNN.utilities.neo_csv.NeoCsv[source]

Bases: object

read_csv(csv_file)[source]

Reads a whole CSV file and creates a block with data.

Parameters:

csv_file (str) – Path of file to read

Returns:

a block with all the data in the CSV file.

Return type:

Block

spynnaker.pyNN.utilities.running_stats module

class spynnaker.pyNN.utilities.running_stats.RunningStats[source]

Bases: object

Keeps running statistics. From: https://www.johndcook.com/blog/skewness_kurtosis/

add_item(x)[source]

Adds an item to the running statistics.

Parameters:

x (int or float) – The item to add

add_items(mean, variance, n_items)[source]

Add a bunch of items (via their statistics).

Parameters:
  • mean (float) – The mean of the items to add.

  • variance (float) – The variance of the items to add.

  • n_items (int) – The number of items represented.

property mean

The mean of the items seen.

Return type:

float

property n_items

The number of items seen.

Return type:

int

property standard_deviation

The population standard deviation of the items seen.

Return type:

float

property variance

The variance of the items seen.

Return type:

float

spynnaker.pyNN.utilities.struct module

class spynnaker.pyNN.utilities.struct.Struct(fields, repeat_type=StructRepeat.PER_NEURON, default_values=None)[source]

Bases: object

Represents a C code structure.

Parameters:
  • fields (list(DataType, str)) – The types and names of the fields, ordered as they appear in the structure.

  • repeat_type (StructRepeat) – How the structure repeats

  • default_values (dict(str, int or float) or None) – Dict of field name -> value to use when values doesn’t contain the field

property fields

The types and names of the fields, ordered as they appear in the structure.

Return type:

list(DataType, str)

get_data(values, vertex_slice=None)[source]

Get a numpy array of uint32 of data for the given values.

Parameters:
  • values (dict(str, int or float or AbstractList)) – The values to fill in the data with

  • vertex_slice (Slice or None) – The vertex slice to get the data for, or None if the structure is global.

Return type:

ndarray(dtype=”uint32”)

get_generator_data(values, vertex_slice=None)[source]

Get a numpy array of uint32 of data to generate the given values.

Parameters:
  • values (~dict-like) – The values to fill in the data with

  • vertex_slice (Slice or None) – The vertex slice or None for a structure with repeat_type global, or where a single value repeats for every neuron. If this is not the case and vertex_slice is None, an error will be raised!

Return type:

ndarray(dtype=”uint32”)

get_size_in_whole_words(array_size=1)[source]

Get the size of the structure in whole words in an array of given size (default 1 item).

Parameters:

array_size (int) – The number of elements in an array of structures

Return type:

int

property is_generatable

Whether the data inside could be generated on machine.

Return type:

bool

property numpy_dtype

The numpy data type of the structure.

Return type:

dtype

read_data(data, values, data_offset=0, vertex_slice=None)[source]

Read a byte string of data and write to values.

Parameters:
  • data (bytes or bytearray) – The data to be read

  • values (RangeDictionary) – The values to update with the read data

  • data_offset (int) – Index of the byte at the start of the valid data.

  • offset (int) – The first index into values to write to.

  • array_size (int or None) – The number of structure copies to read, or None if this is a non-repeating structure.

property repeat_type

How the structure repeats.

Return type:

StructRepeat

class spynnaker.pyNN.utilities.struct.StructRepeat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

How a structure repeats, or not, in memory.

GLOBAL = 0

Indicates a single global struct

PER_NEURON = 1

Indicates a struct that repeats per neuron

spynnaker.pyNN.utilities.utility_calls module

Utility package containing simple helper functions.

spynnaker.pyNN.utilities.utility_calls.check_directory_exists_and_create_if_not(filename)[source]

Create a parent directory for a file if it doesn’t exist.

Parameters:

filename (str) – The file whose parent directory is to be created

spynnaker.pyNN.utilities.utility_calls.check_rng(rng, where)[source]

Check for non-None rng parameter since this is no longer compatible with sPyNNaker. If not None, warn or error depending on a config value.

Parameters:

rng – The rng parameter value.

spynnaker.pyNN.utilities.utility_calls.convert_param_to_numpy(param, no_atoms)[source]

Convert parameters into numpy arrays.

Parameters:
Returns:

the converted param as an array of floats

Return type:

ndarray(float)

spynnaker.pyNN.utilities.utility_calls.convert_to(value, data_type)[source]

Convert a value to a given data type.

Parameters:
  • value – The value to convert

  • data_type (DataType) – The data type to convert to

Returns:

The converted data as a numpy data type

Return type:

ndarray(int32)

spynnaker.pyNN.utilities.utility_calls.create_mars_kiss_seeds(rng)[source]

Generates and checks that the seed values generated by the given random number generator or seed to a random number generator are suitable for use as a mars 64 kiss seed.

Parameters:
  • rng (RandomState) – the random number generator.

  • seed (int or None) – the seed to create a random number generator if not handed.

Returns:

a list of 4 integers which are used by the mars64 kiss random number generator for seeds.

Return type:

list(int)

spynnaker.pyNN.utilities.utility_calls.get_maximum_probable_value(distribution, n_items, chance=0.01)[source]

Get the likely maximum value of a RandomDistribution given a number of draws.

Parameters:
  • distribution (RandomDistribution) –

  • n_items (int) –

  • chance (float) –

spynnaker.pyNN.utilities.utility_calls.get_mean(distribution)[source]

Get the mean of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_minimum_probable_value(distribution, n_items, chance=0.01)[source]

Get the likely minimum value of a RandomDistribution given a number of draws.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_n_bits(n_values)[source]

Determine how many bits are required for the given number of values.

Parameters:

n_values (int) – the number of values (starting at 0)

Returns:

the number of bits required to express that many values

Return type:

int

spynnaker.pyNN.utilities.utility_calls.get_neo_io(file_or_folder)[source]

Hack for https://github.com/NeuralEnsemble/python-neo/issues/1287

In Neo 0.12 neo.get_io only works with existing files

Parameters:

file_or_folder (str) –

spynnaker.pyNN.utilities.utility_calls.get_probability_within_range(distribution, lower, upper)[source]

Get the probability that a value will fall within the given range for a given RandomDistribution.

Parameters:
  • distribution (RandomDistribution) –

  • lower (float) –

  • upper (float) –

spynnaker.pyNN.utilities.utility_calls.get_probable_maximum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely maximum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob.

spynnaker.pyNN.utilities.utility_calls.get_probable_minimum_selected(n_total_trials, n_trials, selection_prob, chance=0.01)[source]

Get the likely minimum number of items that will be selected from a set of n_trials from a total set of n_total_trials with a probability of selection of selection_prob.

spynnaker.pyNN.utilities.utility_calls.get_standard_deviation(distribution)[source]

Get the standard deviation of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.get_time_to_write_us(n_bytes, n_cores)[source]

Determine how long a write of a given number of bytes will take in us.

Parameters:
  • n_bytes (int) – The number of bytes to transfer

  • n_cores (int) – How many cores will be writing at the same time

spynnaker.pyNN.utilities.utility_calls.get_variance(distribution)[source]

Get the variance of a RandomDistribution.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.high(distribution)[source]

Gets the high or maximum boundary value for this distribution.

Could return None.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.low(distribution)[source]

Gets the high or minimum boundary value for this distribution.

Could return None.

Parameters:

distribution (RandomDistribution) –

spynnaker.pyNN.utilities.utility_calls.read_in_data_from_file(file_path, min_atom, max_atom, min_time, max_time, extra=False)[source]

Read in a file of data values where the values are in a format of:

<time>  <atom ID>       <data value>
Parameters:
  • file_path (str) – absolute path to a file containing the data

  • min_atom (int) – min neuron ID to which neurons to read in

  • max_atom (int) – max neuron ID to which neurons to read in

  • extra

  • min_time (float or int) – min time slot to read neurons values of.

  • max_time (float or int) – max time slot to read neurons values of.

Returns:

a numpy array of (time stamp, atom ID, data value)

Return type:

ndarray(tuple(float, int, float))

spynnaker.pyNN.utilities.utility_calls.read_spikes_from_file(file_path, min_atom=0, max_atom=inf, min_time=0, max_time=inf, split_value='\t')[source]

Read spikes from a file formatted as:

<time>  <neuron ID>
Parameters:
  • file_path (str) – absolute path to a file containing spike values

  • min_atom (int or float) – min neuron ID to which neurons to read in

  • max_atom (int or float) – max neuron ID to which neurons to read in

  • min_time (float or int) – min time slot to read neurons values of.

  • max_time (float or int) – max time slot to read neurons values of.

  • split_value (str) – the pattern to split by

Returns:

a numpy array with max_atom elements each of which is a list of spike times.

Return type:

numpy.ndarray(int, int)

spynnaker.pyNN.utilities.utility_calls.report_non_spynnaker_pyNN(msg)[source]

Report a case of non-spynnaker-compatible PyNN being used. This will warn or error depending on the configuration setting.

Parameters:

msg (str) – The message to report

Module contents