rtCommon.structDict

StructDictClass - contains classes StructDict and MatlabStructDict to make it

possible to access a dictionary with syntax struct.field.

Module Contents

Classes

StructDict

Class that adds a structure type syntax to dictionaries,

MatlabStructDict

Subclass dictionary so that elements can be accessed either as dict['key']

Functions

copy_toplevel(data)

recurseCreateStructDict(data)

Given a recursive dictionary, i.e. a dictionary that has

recurseSDtoDict(data)

Given a recursive StructDict, i.e. that has child StructDicts

convertStructuredArrayToDict(sArray)

Convert a NumPy structured array to a dictionary.

isStructuredArray(var) → bool

Return True if var is a numpy structured array

Attributes

structDictType

class rtCommon.structDict.StructDict

Bases: dict

Class that adds a structure type syntax to dictionaries, i.e. ‘dict.field’ will invoke dict[‘field’]

__getattr__(self, key)

Implement getattr to support syntax “data.field”

__setattr__(self, key, val)

Implement setattr to support syntax “data.field=x”

__delattr__(self, key)

Implement delattr to support syntax “del data.field”

__getstate__(self)

Needed for pickling, return the underlying dictionary

__setstate__(self, dict_entries)

Needed for pickling, set the underlying dictionary

copy(self)

D.copy() -> a shallow copy of D

rtCommon.structDict.copy_toplevel(data)
rtCommon.structDict.recurseCreateStructDict(data)

Given a recursive dictionary, i.e. a dictionary that has child dictionaries or lists of dictionaries, convert each child dictionary to a StructDict.

rtCommon.structDict.structDictType
rtCommon.structDict.recurseSDtoDict(data)

Given a recursive StructDict, i.e. that has child StructDicts or lists of StructDict, convert each child StructDict to a Dictionary.

class rtCommon.structDict.MatlabStructDict(dictionary, name=None)

Bases: StructDict

Subclass dictionary so that elements can be accessed either as dict[‘key’] of dict.key. If elements are of type NumPy structured arrays, convert them to dictionaries and then to MatlabStructDict also.

__getattr__(self, key)

Implement getattr to support syntax x=data.field

__setattr__(self, key, val)

Implement setattr to support syntax data.field=x

copy(self)

D.copy() -> a shallow copy of D

fields(self)

list all fields including subfields of the special ‘name’ field

rtCommon.structDict.convertStructuredArrayToDict(sArray)

Convert a NumPy structured array to a dictionary.

rtCommon.structDict.isStructuredArray(var) bool

Return True if var is a numpy structured array