symforce.values.index_entry module

class IndexEntry(offset, storage_dim, stored_datatype, shape=None, item_index=None)[source]

Bases: object

Contains the structural information needed to reconstruct a single value of a values.Values from storage in method values.Values.from_storage_index()

Meant to be a python parallel to index_entry_t in symforce.lcm

For entry: IndexEntry = v.index()[key] for Values v and string key

Parameters:
  • offset (int) –

  • storage_dim (int) –

  • stored_datatype (dataclasses.InitVar[T.Type]) –

  • shape (T.Optional[T.Tuple[int, ...]]) –

  • item_index (T.Optional[T.Dict[str, T.Any]]) –

offset

The index of StorageOps.to_storage(v) at which StorageOps.to_storage(v[key]) begins

Type:

int

storage_dim

The length of StorageOps.to_storage(v[key])

Type:

int

shape

If datatype() is np.ndarray or sf.Matrix, it’s the shape of v[key]. Otherwise, it’s None.

Type:

T.Optional[T.Tuple[int, …]]

item_index

v[key].index() if datatype() is Values, if datatype() is list or tuple, is dict d where d[f"{key}_{i}"] equals the IndexEntry of v[key][i], and otherwise is None

Type:

T.Optional[T.Dict[str, T.Any]]

offset: int
storage_dim: int
stored_datatype: dataclasses.InitVar[T.Type]
shape: T.Optional[T.Tuple[int, ...]] = None
item_index: T.Optional[T.Dict[str, T.Any]] = None
datatype()[source]

Returns the type indexed by self

Example:

IndexEntry(offset, storage_dim, stored_datatype).datatype()

returns stored_datatype

Precondition:

The datatype stored must have had its module loaded (i.e., if the stored datatype is sf.Rot3, symforce.geo must have been imported). The datatype must also be accessible from the module (dynamically created types do not do this. For example, the sf.Matrix types with more than 10 rows or columns)

Return type:

Type