sdynpy.core.sdynpy_array.SdynpyArray

class SdynpyArray(shape, dtype=<class 'float'>, buffer=None, offset=0, strides=None, order=None)[source]

Bases: ndarray

Superclass of the core SDynPy objects

The core SDynPy object arrays inherit from this class. The class is a subclass of numpy’s ndarray. The underlying data structure is stored as a structured array, but the class’s implementation allows accessing the array fields as if they were attributes.

__init__()

Methods

assemble_mat_dict()

Assembles a dictionary of fields

load(filename)

Load in the specified file into a SDynPy array object

ndenumerate()

Enumerates over all entries in the array

save(filename)

Save the array to a numpy file

savemat(filename)

Save array to a Matlab *.mat file.

Attributes

fields

Returns the fields of the structured array.

assemble_mat_dict()[source]

Assembles a dictionary of fields

Returns

output_dict – A dictionary of contents of the file

Return type

dict

property fields

Returns the fields of the structured array.

These fields can be accessed through attribute syntax.

classmethod load(filename)[source]

Load in the specified file into a SDynPy array object

Parameters

filename (str) – Filename specifying the file to load. If the filename has extension .unv or .uff, it will be loaded as a universal file. Otherwise, it will be loaded as a NumPy file.

Raises

AttributeError – Raised if a unv file is loaded from a class that does not have a from_unv attribute defined.

Returns

SDynpy array of the appropriate type from the loaded file.

Return type

cls

ndenumerate()[source]

Enumerates over all entries in the array

Yields
  • tuple – indices corresponding to each entry in the array

  • array – entry in the array corresponding to the index

save(filename: str)[source]

Save the array to a numpy file

Parameters

filename (str) – Filename that the array will be saved to. Will be appended with .npy if not specified in the filename

savemat(filename)[source]

Save array to a Matlab *.mat file.

Parameters

filename (str) – Name of the file in which the data will be saved

Return type

None.