data_specification.enums package

Module contents

class data_specification.enums.ArithmeticOperation(value, operator, doc='')

Bases: enum.Enum

Arithmetic Operations

ADD = 0
MULTIPLY = 2
SUBTRACT = 1
class data_specification.enums.Commands(value, exec_function, doc='')

Bases: enum.Enum

Set of opcodes for the spec executor

ALIGN_WR_PTR = 101
ARITH_OP = 103
BLOCK_COPY = 69
BREAK = 0
BREAK_LOOP = 82
CONSTRUCT = 64
COPY_PARAM = 113
COPY_STRUCT = 112
DECLARE_RANDOM_DIST = 6
DECLARE_RNG = 5
ELSE = 86
END_CONSTRUCTOR = 37
END_IF = 87
END_LOOP = 83
END_SPEC = 255
END_STRUCT = 18
FREE = 3
GET_RANDOM_NUMBER = 7
GET_WR_PTR = 99
IF = 85
LOGIC_OP = 104
LOOP = 81
MV = 96
NOP = 1
PRINT_STRUCT = 130
PRINT_TXT = 129
PRINT_VAL = 128
READ = 65
READ_PARAM = 115
REFERENCE = 4
REFORMAT = 106
RESERVE = 2
SET_WR_PTR = 100
START_CONSTRUCTOR = 32
START_STRUCT = 16
STRUCT_ELEM = 17
SWITCH_FOCUS = 80
WRITE = 66
WRITE_ARRAY = 67
WRITE_PARAM = 114
WRITE_PARAM_COMPONENT = 116
WRITE_STRUCT = 68
class data_specification.enums.Condition(value, operator, doc='')

Bases: enum.Enum

Comparison Operations

EQUAL = 0
GREATER_THAN = 5
GREATER_THAN_OR_EQUAL = 4
LESS_THAN = 3
LESS_THAN_OR_EQUAL = 2
NOT_EQUAL = 1
class data_specification.enums.DataType

Bases: enum.Enum

Supported data types. Internally, these are actually tuples.

  1. an identifier for the enum class;
  2. the size in bytes of the type;
  3. the minimum possible value for the type;
  4. the maximum possible value for the type;
  5. the scale of the input value to convert it in integer;
  6. the pattern to use following the struct package encodings to convert the data in binary format;
  7. is whether to apply the scaling when converting to SpiNNaker’s binary format.
  8. the corresponding numpy type (or None to inhibit direct conversion via numpy, scaled conversion still supported);
  9. the text description of the type.

Note

Some types (notably 64-bit fixed-point and floating-point types) are not recommended for use on SpiNNaker due to complications with representability and lack of hardware/library support.

FLOAT_32 = 14
FLOAT_64 = 15
INT16 = 5
INT32 = 6
INT64 = 7
INT8 = 4
S015 = 21
S031 = 22
S063 = 23
S07 = 20
S1615 = 12
S3231 = 13
S87 = 11
U016 = 17
U032 = 18
U064 = 19
U08 = 16
U1616 = 9
U3232 = 10
U88 = 8
UINT16 = 1
UINT32 = 2
UINT64 = 3
UINT8 = 0
decode_array(values)[source]

Decodes a byte array into iterable of this type.

Parameters:values – the bytes to decode into this given data type
Return type:numpy array
decode_numpy_array(array)[source]

Decode the numpy array of SpiNNaker values according to this type.

Parameters:array (ndarray(uint32)) –
Return type:ndarray(uint32 or float64)
encode(value)[source]

Encode the Python value for SpiNNaker according to this type.

Parameters:value (float or int) –
Return type:bytes
encode_as_int(value)[source]

Returns the value as an integer, according to this type.

Parameters:value (float or int) –
Return type:int
encode_as_numpy_int(value)[source]

Returns the value as a numpy integer, according to this type.

Parameters:value (float or int) –
Return type:uint32
encode_as_numpy_int_array(array)[source]

Returns the numpy array as an integer numpy array, according to this type.

Parameters:array (ndarray) –
Return type:ndarray
max

The maximum possible value for the type.

Return type:Decimal
min

The minimum possible value for the type.

Return type:Decimal
numpy_typename

The corresponding numpy type, if one exists.

scale

The scale of the input value to convert it in integer.

Return type:Decimal
size

The size in bytes of the type.

Return type:int
struct_encoding

The encoding string used for struct. Scaling may also be required.

Return type:str
class data_specification.enums.LogicOperation(value, operator, doc='')

Bases: enum.Enum

Logic Operations

AND = 3
LEFT_SHIFT = 0
NOT = 5
OR = 2
RIGHT_SHIFT = 1
XOR = 4
class data_specification.enums.RandomNumberGenerator(value, doc='')

Bases: enum.Enum

Random number generator types

MERSENNE_TWISTER = 0