Advanced operations of package variable types

The following types are globally available. E.g., in function variables, UserPyModules or other user code:

ByteStream

class ByteStream

The ByteStream type is used to represent byte sequences. The ByteStream type supports binary operations, sequence operations and checking for equality. For binary operations, the operation is applied bytewise. Therefor both operands must be of the same size.

This table lists all binary operations on ByteStreams:

Operation

Result

Example

x | y

bitwise or of x and y

A5:2B | 11:70 = B5:7B

x ^ y

bitwise exclusive or of x and y

A5:2B ^ 11:70 = B4:5B

x & y

bitwise and of x and y

A5:2B & 11:70 = 01:20

~x

the bits of x inverted

~A5:2B = 5A:D4

This table lists all sequence operations on ByteStreams:

Operation

Result

Example

s + t

the concatenation of s and t

A5:2B + 11:70 = A5:2B:11:70

s[i]

i-th byte of s (returns a BitStream)

A5:2B[1] = bits(0x2B, 8)

s[i:j]

slice of s form i to j

A5:2B:11:70[1:-1] = 2B:11

len(s)

length of s

len(A5:2B:11:70) = 4

This table shows the indexing of bits and bytes in ByteStreams:

HexValue

0x

5B

C0

…

67

2E

Byte

0

1

…

6

7

BinValue

0

1

0

1

1

0

1

1

1

0

1

0

0

0

0

0

…

0

1

1

0

0

1

1

1

0

0

2

0

1

1

1

0

Bit

7

…

0

15

…

8

…

55

…

48

63

…

56

If you want to encode an ascii string as ByteStream or decode a string from ByteStream the following two code snippets might be helpful:

  • String to ByteStream: ByteStream('test'.encode('ascii')) save as myByteStream

  • ByteStream to string: myByteStream.RawString().decode('ascii') save as test

Count(otherByteStream, start=0, end=Ellipsis)

Return the number of occurrences of another ByteStream.

Parameters:
otherByteStream : ByteStream

Searched pattern

Returns:

Number of occurrences

Return type:

int

Find(otherByteStream, start=0, end=Ellipsis)

Return the lowest index in the ByteStream where another ByteStream is found.

Parameters:
otherByteStream : ByteStream

Searched pattern

start : int

Start byte

end : int

End byte

Returns:

Index or -1 if not found

Return type:

int

classmethod FromIntelWordList(wordList)

Creates a new ByteStream object from a List of 16 bit words. The bytes are ordered in Intel (little endian) format: 0x1234 becomes 34:12

Parameters:
wordList : list

A list of 16 bit words

Returns:

A new ByteStream object

Return type:

ByteStream

classmethod FromMotorolaWordList(wordList)

Creates a new ByteStream object from a List of 16 bit words. The bytes are ordered in Motorola (big endian) format: 0x1234 becomes 12:34

Parameters:
wordList : list

A list of 16 bit words

Returns:

A new ByteStream object

Return type:

ByteStream

classmethod FromRawString(rawString)

Creates a new ByteStream object from a bytes object.

Parameters:
rawString : bytes

A bytes object

Returns:

A new ByteStream object

Return type:

ByteStream

HexString()

Creates a string representation for this ByteStream. Each byte is displayed as hex number (with leading 0x) and separated by a space.

Returns:

String representation

Return type:

str

IBits(startBit=None, bitLen=None)

Extracts a BitStream beginning from startBit and with a length of bitLen using Intel byte order.

Parameters:
startBit : int

Start bit

bitLen : int

Bits

Returns:

BitStream

Return type:

BitStream

Index(otherByteStream, start=0, end=Ellipsis)

Like Find() but raises ValueError if the other ByteStream wasn’t found.

Parameters:
otherByteStream : ByteStream

Searched pattern

start : int

Start byte

end : int

End byte

Returns:

Index or -1 if not found

Return type:

int

IntelWordList()

Creates a word list representation for this Byte Stream, interpreted in Intel (little endian) format. Each pair of bytes is converted to a word: 12:34 becomes 0x3412. The Byte Stream must contain an even number of bytes.

Returns:

Word list representation

Return type:

list

Ints()

Converts this ByteStream into a list of positive integers (<256)

Returns:

List of positive integers

Return type:

list<int>

Legacy(hexPrefix=None)

Converts this ByteStream into a old-style hex string representation, e.g. “0123affe” or “0x0123affe”

Parameters:
hexPrefix : boolean

Enable/disable hex prefix 0x

Returns:

Hex string representation

Return type:

str

MBits(startBit=None, bitLen=None)

Extracts a BitStream beginning from startBit and with a length of bitLen using Motorola byte order.

Parameters:
startBit : int

Start bit

bitLen : int

Bit length

Returns:

BitStream

Return type:

BitStream

Match(expectedPattern)

Checks if the given string representation of a bytestream pattern matches this Bytesream.

Allowed wildcard characters for the string bytestream pattern are:

Wildcard

Description

?

wildcard character for one half-byte

*

wildcard character for 0..N arbitrary bytes

Example

Result

ByteStream(“FF:F0:11”).Match(“FF:F0:11”)

True

ByteStream(“FF:F0:11”).Match(“FF:F0:12”)

False

ByteStream(“FF:F0:11”).Match(“FF:??:11”)

True

ByteStream(“FF:A0:10:11”).Match(“F?:A0:?0:*”)

True

ByteStream(“FF:F0:01:A9:11”).Match(”*:01:*”)

True

ByteStream(“FF:A0:19:10:11”).Match(“F?:*:1?:1?”)

True

ByteStream(“FF:A0:29:10”).Match(“F?:*:1?:??”)

False

Parameters:
expectedPattern : str

A string bytestream pattern

Returns:

Match Result

Return type:

boolean

MotorolaWordList()

Creates a word list representation for this Byte Stream, interpreted in Motorola (big endian) format. Each pair of bytes is converted to a word: 12:34 becomes 0x1234 The Byte Stream must contain an even number of bytes.

Returns:

Word list representation

Return type:

list

RawString()

Returns the corresponding bytes object for this ByteStream.

Returns:

Bytes object of this ByteStream

Return type:

bytes

Reverse()

Returns a new ByteStream object with its bytes in reversed order.

Returns:

A new ByteStream object

Return type:

ByteStream

SetIBits(startBit, bits)

Constructs a new ByteStream from this ByteStream, replacing its content from startBit for len(bits) with the content of the BitStream bits using Intel byte order.

Parameters:
startBit : int

Start bit

bits : BitStream

Bits

Returns:

A new ByteStream object

Return type:

ByteStream

SetMBits(startBit, bits)

Constructs a new ByteStream from this ByteStream, replacing its content from startBit for len(bits) with the content of the BitStream bits using Motorola byte order.

Parameters:
startBit : int

Start bit

bits : BitStream

BitStream

Returns:

A new ByteStream object

Return type:

ByteStream

bsClass

alias of BitStream

BitStream

class BitStream

The BitStream type is used to represent binary data. It is possible to represent leading zeros (in contrast to plain integers), as BitStream objects have a defined length. The BitStream type supports binary operations (in contrast to plain strings), sequence operations and checking for equality. When a binary operator has operands with different size, it pads the “shorter” BitStream with zeros until its size matches the size of the “larger” BitStream.

Example usage:

  • b = BitStream(0, 16)  # a 16-bit BitStream with all zeros: 0000000000000000

  • b = BitStream(0xff, 16)  # a 16-bit BitStream representing 0000000011111111

  • b = BitStream(0xff, 12)  # a 12-bit BitStream representing 000011111111

  • b = BitStream(0b1010, 4)  # a 4-bit BitStream representing 1010

  • b = BitStream([0xff, 0xaa])  # a 16-bit BitStream representing 1111111110101010

  • b = BitStream('ffaa')  # a 16-bit BitStream representing 1111111110101010

This table lists all bit operations on BitStreams:

Operation

Result

Example

x | y

bitwise or of x and y

011001 | 0011 = 011011

x ^ y

bitwise exclusive or of x and y

011001 ^ 0011 = 011010

x & y

bitwise and of x and y

011001 & 0011 = 000001

~x

the bits of x inverted

~011001 = 100110

This table lists all sequence operations on BitStreams:

Operation

Result

Example

s + t

the concatenation of s and t

011001 + 0011 = 0110010011

s[i]

i-th bit of s (0 is on the right)

011001[1] = 0

s[i:j]

slice of s form i to j

011001[1:-1] = 1100

len(s)

length of s

len(011001) = 6

Furthermore, there are many methods for BitStream creation, export and manipulation.

This table shows the indexing of bits and bytes in BitStreams:

HexValue

0x

5B

C0

…

67

2E

Byte

0

1

…

6

7

BinValue

0

1

0

1

1

0

1

1

1

0

1

0

0

0

0

0

…

0

1

1

0

0

1

1

1

0

0

2

0

1

1

1

0

Bit

63

…

56

55

…

48

…

15

…

8

7

…

0

Bin()

Exports this BitStream object as a bit string. This bit string will be a sequence of 0 and 1.

Returns:

bit string representation of this BitStream

Return type:

str

Double()

Exports this BitStream object as a float. Raises RuntimeError if the length of this BitStream is not 64.

Returns:

double representation of this BitStream

Return type:

float

Float()

Exports this BitStream object as a float. Raises RuntimeError if the length of this BitStream is not 32.

Returns:

float representation of this BitStream

Return type:

float

classmethod FromBin(value)

Creates a new BitStream object from a bit string. This string must not contain any character but 0 and 1.

Parameters:
value : str

arbitrary sequence of 0 and 1

Returns:

a new BitStream object

Return type:

BitStream

classmethod FromDouble(value)

Creates a new BitStream object with a length of 64 from a float.

Parameters:
value : float

A Double (64bit)

Returns:

a new BitStream object

Return type:

BitStream

classmethod FromFloat(value)

Creates a new BitStream object with a length of 32 from a float.

Parameters:
value : float

A Float (32bit)

Returns:

a new BitStream object

Return type:

BitStream

classmethod FromInt(value, length=32)

Creates a new BitStream object from an integer (value). This integer must be greater than or equal to -(2 ** (length - 1)) and smaller than 2 ** (length - 1). Negative numbers are represented using the twos complement.

Parameters:
value : int

an integer (-(2 ** (length - 1) <= value < 2 ** (length - 1))

length : int

length of the resulting BitStream

Returns:

a new BitStream object

Return type:

BitStream

classmethod FromRawString(rawString, length=None)

Creates a new BitStream object from a binary string object.

Parameters:
rawString : bytes | bytearray

a binary string object

length : int

length of the resulting BitStream

Returns:

a new BitStream object

Return type:

BitStream

classmethod FromUInt(value, length=32)

Creates a new BitStream object from an integer (value). This integer must be greater than or equal to zero and fit into length bits.

Parameters:
value : int

an integer greater than or equal to zero

length : int

length of the resulting BitStream

Returns:

a new BitStream object

Return type:

BitStream

IBytes(padding=0)

Converts this BitStream object (8-bit-padded) in a new ByteStream object using Intel Byteorder.

Returns:

the ByteStream representation of this BitStream using Intel Byteorder

Return type:

ByteStream

Int()

Exports this BitStream object as an integer. This integer will be greater than or equal to -(2 ** (length - 1)) and smaller than 2 ** (length - 1). If the MSB is set, this BitStream object will be interpreted as a negative number in twos complement.

Returns:

integer representation of this BitStream

Return type:

BitStream

MBytes(padding=0)

Converts this BitStream object (8-bit-padded) in a new ByteStream object using Motorola Byteorder.

Returns:

the ByteStream representation of this BitStream using Motorola Byteorder

Return type:

ByteStream

Pad(value=None, multipleOf=4)

Paddes the bitstream with 0’s or 1’s so that its length is a multiple of multipleOf.

Parameters:
value : bool

value used for padding (True or False)

multipleOf : int

multiplier for padding

Returns:

a padded copy of this BitStream object

Return type:

BitStream

Pad4(value=None)

Equivalent to calling Pad(value, 4)

Pad8(value=None)

Equivalent to calling Pad(value, 8)

UInt()

Exports this BitStream object as an integer. This integer will be positive (or 0) for any BitStream.

Returns:

integer representation of this BitStream

Return type:

int

bsClass

alias of ByteStream

Vector

class Vector
Parameters:
iterable : list

List of values

Creates a Vector object from a given iterable, i.e. a list or tuple.

Example usage: Vector([1,2,3])

GetDimension()

Returns the length of the vector.

Returns:

dimension

Return type:

int

SetValue(x, value)

Sets the value of the given position.

Parameters:
x : int

index

value : int, float, string, etc.

value

GetValue(x=0)

Returns the value of the given position.

Parameters:
x : int

index

Returns:

value

Return type:

int, float, string, etc.

DeleteValue(x)

Deletes the value of the given position.

Parameters:
x : int

index

List()

Returns a list representation of the Vector.

Returns:

list representation of the Vector

Return type:

list

ToNumpyArray(dtype=<class 'float'>)

Returns a numpy array representation of the Vector.

Parameters:
dtype : see numpy documentation

data-type

Returns:

numpy array representation of the Vector

Return type:

ndarray

__add__(toAdd)

This method is called automatically in an expression of the form x+y when x is an instance of this class.

Adds a scalar, a vector or a curve to a vector or a curve. The dimensions in the two latter cases have to be identical. The distribution of a curve is only adopted if the curve is the first operand.

__sub__(toSub)

This method is called automatically in an expression of the form x-y when x is an instance of this class.

Subtracts a scalar, a vector or a curve from a vector or a curve. The dimensions in the two latter cases have to be identical. The distribution of a curve is only adopted if the curve is the first operand.

__mul__(toMul)

This method is called automatically in an expression of the form x*y when x is an instance of this class.

Multiplies a vector or a curve with a scalar, a vector or a curve. The dimensions in the two latter cases have to be identical. The distribution of a curve is only adopted if the curve is the first operand.

__truediv__(toDiv)

This method is called automatically in an expression of the form x/y when x is an instance of this class.

Divides a vector or a curve by a scalar, a vector or a curve. The dimensions in the two latter cases have to be identical. The distribution of a curve is only adopted if the curve is the first operand.

Matrix

class Matrix
Parameters:
iterable : list

Two dimensional list of values

Creates a Matrix object from a given two dimensional iterable, i.e. a nested list. Matrices are stored in the column layout. This entails that to index a matrix variable, the column is specified first and subsequently the row.

Example usage: Matrix([[1,2,3],[11,22,33]]), creates a matrix with two columns and three rows.

GetXDimension()

Returns the dimension of x.

Returns:

dimension

Return type:

int

GetYDimension()

Returns the dimension of y.

Returns:

dimension

Return type:

int

GetValue(x, y)

Returns the value of the given position.

Parameters:
x : int

index x

y : int

index y

Returns:

value

Return type:

float

SetValue(x, y, value)

Sets the value of the given position.

Parameters:
x : int

index x

y : int

index y

value : any

value

DeleteValue(x, y)

Deletes the value of the given position.

Parameters:
x : int

index x

y : int

index y

GetRow(y)

Returns the row of the given index.

Parameters:
y : int

row

Returns:

row as a list of the values

Return type:

list

GetCol(x)

Returns the column of the given index.

Parameters:
x : int

column

Returns:

column as a list of the values

Return type:

list

List()

Returns a two-dimensional list representation of the matrix.

Returns:

list representation of the matrix

Return type:

list

ToNumpyArray(dtype=<class 'float'>)

Returns a two-dimensional numpy array representation of the matrix.

Parameters:
dtype : see numpy documentation

data-type

Returns:

numpy array representation of the matrix

Return type:

ndarray

__add__(toAdd)

This method is called automatically in an expression of the form x+y when x is an instance of this class.

Adds a scalar, a matrix or a map to a matrix or a map. The dimensions in the two latter cases have to be identical. The distributions of a map are only adopted if the map is the first operand.

__sub__(toSub)

This method is called automatically in an expression of the form x-y when x is an instance of this class.

Subtracts a scalar, a matrix or a map from a matrix or a map. The dimensions in the two latter cases have to be identical. The distributions of a map are only adopted if the map is the first operand.

__mul__(toMul)

This method is called automatically in an expression of the form x*y when x is an instance of this class.

Multiplies a matrix or a map with a scalar, a matrix or a map. The dimensions in the two latter cases have to be identical. The distributions of a map are only adopted if the map is the first operand.

__truediv__(toDiv)

This method is called automatically in an expression of the form x/y when x is an instance of this class.

Divides a matrix or a map by a scalar, a matrix or a map. The dimensions in the two latter cases have to be identical. The distributions of a map are only adopted if the map is the first operand.

Curve

class Curve
Parameters:
values : list

List of values

distribution : list

List of distribution

Creates a curve from 2 iterables representing the values and the distribution which may be lists, tuples or vectors, respectively.

Example usage: Curve([1,2,3],[11,22,33])

SetDistributionValue(x, value)

Sets the distribution level of the given position.

Parameters:
x : int

index

value : Expression

distribution level value

GetDistributionValue(x)

Gets the distribution level of the given position.

Parameters:
x : int

index

Returns:

distribution level value

Return type:

Expression

DeleteDistributionValue(x)

Deletes the distribution level of the given position.

Parameters:
x : int

index

GetDistribution()

Returns the distribution vector.

Returns:

distribution vector

Return type:

Vector

List()

Returns a list representation of the values of the curve.

Returns:

list representation of the values of the curve

Return type:

list

Interpolate(xCoord)

Calculates the value for a given x-coordinate by means of linear interpolation. The x-axis of the curve should already be sorted in ascending order.

In order to use a custom interpolation, you can retrieve the axis as a Vector via GetDistribution() and call ToNumpyArray() both on the axis and on the Curve object itself (for the z-vector) to obtain numpy arrays.

Parameters:
xCoord : float

coordinate x

Returns:

interpolated value

Return type:

float

GetDimension()

Returns the length of the vector.

Returns:

dimension

Return type:

int

GetValue(x=0)

Returns the value of the given position.

Parameters:
x : int

index

Returns:

value

Return type:

int, float, string, etc.

SetValue(x, value)

Sets the value of the given position.

Parameters:
x : int

index

value : int, float, string, etc.

value

ToNumpyArray(dtype=<class 'float'>)

Returns a numpy array representation of the Vector.

Parameters:
dtype : see numpy documentation

data-type

Returns:

numpy array representation of the Vector

Return type:

ndarray

EnumDefinition

class EnumDefinition

Is returned when accessing the attribute enum of an EnumValue.

__iter__()

Iterator over the EnumValue objects of the EnumDefinition.

__getattr__(item)

Flexible access of EnumValue

  • myEnumDef.strName

  • myEnumDef.enum.strName

The returning EnumValue is initialized with the corresponding int value of the string value and does not hold an EnumDefinition. Therefore, second access of the enum-attribute from the EnumValue is not possible (no recursion possible).

  • not possible: myEnumDef.enum.strName.enum

Parameters:
item : str

Some string Enum value

Returns:

EnumValue initialized with int

Raises:

AttributeError. Otherwise, the builtin function getattr(enumDef,'strVal', None) does not work .

Return type:

EnumValue

__getitem__(item)

Flexible access of EnumValue

  • myEnumDef['strName']

  • myEnumDef.enum['strName']

The returning EnumValue is initialized with the corresponding int value of the string value and does not hold an EnumDefinition. Therefore, second access of the enum-attribute from the EnumValue is not possible (no recursion possible).

  • not possible: myEnumDef.enum.strName.enum

Parameters:
item : str

Some string Enum value (with possible white spaces)

Returns:

EnumValue initialized with int

Return type:

EnumValue

EnumValue

class EnumValue

Represents an individual enum value with its string and integer representation and can be used to access the EnumDefinition.

__eq__(other)

EnumValue is compared flexibly to either str or int.

Parameters:
other : str or int

str or int value of the EnumValue to compare with

int
Returns:

Numerical representation of the EnumValue.

str
Returns:

Textual representation of the EnumValue.

enum
Returns:

The EnumDefinition which corresponds to the EnumValue.

Exception:

AttributeError

Map

class Map
Parameters:
values : list

Two dimensional list of values

xDistribution : list

List of X distribution

yDistribution : list

List of Y distribution

Creates a Map from a given Matrix or nested two dimensional list/tuple with distributions from given vectors or one dimensional list/tuples.

Example usage: Map([[1,2,3],[6,7,8]], [11,22], [12,13,14])

GetXDistribution()

Returns the X distribution vector.

Returns:

X distribution vector

Return type:

Vector

GetYDistribution()

Returns the X distribution vector.

Returns:

X distribution vector

Return type:

Vector

GetXDistributionValue(x)

Gets the x-distribution level of the given position.

Parameters:
x : int

index

Returns:

x-distribution level value

Return type:

any

DeleteXDistributionValue(x)

Deletes the x-distribution level of the given position.

Parameters:
x : any

index

GetYDistributionValue(y)

Gets the y-distribution level of the given position.

Parameters:
y : int

index

Returns:

y-distribution level value

Return type:

any

DeleteYDistributionValue(y)

Deletes the y-distribution level of the given position.

Parameters:
y : int

index

SetXDistributionValue(x, value)

Sets the x-distribution level of the given position.

Parameters:
x : int

index

value : any

x-distribution level value

SetYDistributionValue(y, value)

Sets the x-distribution level of the given position.

Parameters:
y : int

index

value : any

y-distribution level value

List()

Returns a two dimensional list representation of the values of the map.

Returns:

list representation of the values of the map

Return type:

list

Interpolate(xCoord, yCoord)

Calculates the value of a given pair of coordinates by means of linear interpolation, first along the x-axis and then along the y-axis. The x- and y-axis of the map should already be sorted in ascending order.

In order to use a custom interpolation, you can retrieve the x-axis and y-axis as Vectors via GetXDistribution() and GetYDistribution(), and call ToNumpyArray() on both axes as well as ToNumpyArray() on the Map object itself (for the z-matrix) to obtain numpy arrays.

Parameters:
xCoord : float

x-coordiate

yCoord : float

y-coordinate

Returns:

interpolated value

Return type:

float

GetXDimension()

Returns the dimension of x.

Returns:

dimension

Return type:

int

GetYDimension()

Returns the dimension of y.

Returns:

dimension

Return type:

int

GetValue(x, y)

Returns the value of the given position.

Parameters:
x : int

index x

y : int

index y

Returns:

value

Return type:

float

SetValue(x, y, value)

Sets the value of the given position.

Parameters:
x : int

index x

y : int

index y

value : any

value

ToNumpyArray(dtype=<class 'float'>)

Returns a two-dimensional numpy array representation of the matrix.

Parameters:
dtype : see numpy documentation

data-type

Returns:

numpy array representation of the matrix

Return type:

ndarray

StructuredSignal

class StructuredSignal

Creates a StructuredSignal if dtype is structured or a StructuredSignalLeaf if dtype is not structured (“flat”).

Parameters:
shape : tuple

Main dimension of the signal that specifies how many structured samples should be included. Structured scalar values have a shape of ().

dtype : numpy.dtype

Structured NumPy dtype describing the whole structure.

values : list

Optional. Values with which the signal is to be initialized. The values must be passed analog to the dtype of nested arrays - for two attributes e.g. a list with two arrays.

Example usage:

structuredDtype = numpy.dtype([
    ('StructA', [
        ('SubStructA', [
            ('SubArrayA', int, (4,)),
            ('SubScalarA', int)])],
     (3,))
])
s = StructuredSignal(shape=(5,), dtype=structuredDtype)

A StructuredSignal can contain any number of StructuredSignalLeaf or further nested StructuredSignal. In the example the StructuredSignalLeaf s.SubStructA.SubArrayA contains an array of shape (5, 3, 4).

An example for valid initial values looks like this:

values=[[[
    numpy.arange(5 * 3 * 4).reshape((5, 3, 4)),  # SubArrayA
    numpy.arange(5 * 3).reshape((5, 3)),         # SubScalarA
]]]

The depth is the same as in the dtype definition. (Tip: Count the number of opening square brackets up to the concerning leaf in the dtype definition.)

Alternatively, a StructuredSignal can be constructed empty and inititialized later on:

s[0].StructA[0].SubStructA.SubScalarA = 12
s[1].StructA.SubStructA.SubArrayA[1] = 2             # initializes all elements of StructA
s[2].StructA[1].SubStructA.SubArrayA = [1, 2, 3, 4]
s[2].StructA[2].SubStructA.SubArrayA = [1, 2, 3]     # SubArray[3:5] remains empty (masked)
GetName()

Returns the name of the structured element. (Is None for the top level structure.)

GetElementNames()

Returns a list containing the names of the direct child elements.

IterElements()

Iterates over the direct child elements by returning a tuple of the name and the element itself.

StructuredSignalLeaf

class StructuredSignalLeaf

Represents a leaf element of a StructuredSignal. Should not be created directly, but by creating a StructuredSignal with a dtype representing a “flat structure”.

See StructuredSignal for an example.

Working with raw values: Raw values can be added and accessed using the _raw attribute. Valid node values take precedence over raw values during processing. If node values are masked, e.g. because of a failed conversion, raw values are used if present.

min(*args, **kwargs)

Return the minimum.

Return type:

int|float

max(*args, **kwargs)

Return the maximum.

Return type:

int|float

any(*args, **kwargs)

Returns True if any of the elements evaluate to True.

Return type:

bool

all(*args, **kwargs)

Returns True if all of the elements evaluate to True.

Return type:

bool

FullArray()

Returns the full array represented by this leaf element, which allows regular indexing considering all dimensions.

By default, indexing a leaf element only considers the dimensions of the leaf element itself, not the dimensions originating from parent structure elements.

Example:

structuredDtype = numpy.dtype([
    ('StructA', [('SubArrayA', int, (3,)),])
])
s = StructuredSignal(shape=(2,), dtype=structuredDtype,
                     values=[[numpy.array([[1, 2, 3], [4, 5, 6]])]])
leaf = s.StructA.SubArrayA
# even though the shape of leaf is (2, 3), leaf[0] indexes SubArrayA
# returning the first element of each of the 2 SubArrayA in StructA
assert all(leaf[0] == numpy.array([1, 4]))
assert len(leaf[0]) == 2
# leaf.FullArray() returns a regular array of the shape (2, 3),
# thus leaf[0] returns the whole first SubArrayA
assert all(leaf.FullArray()[0] == numpy.array([1, 2, 3]))
assert len(leaf.FullArray()[0]) == 3
GetName()

Returns the name of the structured element. (Is None for the top level structure.)

GetElementNames()

Returns a list containing the names of the direct child elements.

Since StructuredSignalLeaf is the final node there are no direct child elements and so this method just returns an empty list.

IterElements()

Returns an empty iterator.

See StructuredSignalLeaf.GetElementNames().

Inbox

class Inbox
IsEmpty()

Checks if inbox is empty.

Returns:

True if inbox is empty else False

Return type:

boolean

GetCount()

Returns the number of messages in the inbox.

Returns:

number of messages

Return type:

int

FetchNext(timeout=None)

Fetches the next message in the inbox.

Parameters:
timeout : int

timeout in milliseconds to wait for the next message income. If None the standard timeout is used. The Value -1 defines no timeout equal to infinte waiting.

Returns:

next message

Return type:

object

LookUpNext(timeout=None)

Looks for next message in inbox without fetching it.

Parameters:
timeout : int

timeout in milliseconds to wait for the next message income. If None the standard timeout is used. The Value -1 defines no timeout equal to infinte waiting.

Returns:

message name

Return type:

string

Outbox

class Outbox
Post(value)

Sends a message to the connected outbox.

Parameters:
value : object

message

IsConnected()

Checks if outbox is connected to a target.

Returns:

True if outbox is connected, else None.

Return type:

boolean