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 methodvalues.Values.from_storage_index()
Meant to be a python parallel to
index_entry_t
insymforce.lcm
For
entry: IndexEntry = v.index()[key]
forValues v
and stringkey
- Parameters:
- offset#
The index of
StorageOps.to_storage(v)
at whichStorageOps.to_storage(v[key])
begins- Type:
- shape#
If datatype() is np.ndarray or
sf.Matrix
, it’s the shape ofv[key]
. Otherwise, it’sNone
.- Type:
T.Optional[T.Tuple[int, …]]
- item_index#
v[key].index()
if datatype() isValues
, if datatype() is list or tuple, is dictd
whered[f"{key}_{i}"]
equals theIndexEntry
ofv[key][i]
, and otherwise is None- Type:
T.Optional[T.Dict[str, T.Any]]
- stored_datatype: dataclasses.InitVar[T.Type]#
- 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: