State Class

class sgio.model.State(name='', data={}, label=[], location='')

Bases: object

A class to represent a state with associated data, labels, and location.

name

The name of the state.

Type:

str

data

The data associated with the state. It can be a list for point data or a dictionary for field data.

For point data:

data = [
    value_for_label_1,
    value_for_label_2,
    ...
]

For field data:

data = {
    1: [],  # Point data for note/element 1
    2: [],  # Point data for note/element 2
    ...
}
Type:

list or dict

label

The labels associated with the state.

Type:

list of str

location

The location type of the state, either ‘node’ or ‘element’.

Type:

str

addData(data: list, loc=None)

Add data to the state.

Parameters:
data : list

Data to be added.

loc : int, optional

Location index. Default is None.

at(locs: Iterable)

Get the state data at a list of given locations.

Parameters:
locs : list

List of note/element IDs.

Returns:

A copy of the State object with the data at the given locations.

Return type:

State

toDictionary()

Convert the State object to a dictionary.

Returns:

A dictionary representation of the State object.

{
    'name': name,
    'data': data,
    'label': label,
    'location': location
}

Return type:

dict