symforce.ops.interfaces.storage module¶
- class Storage[source]¶
Bases:
object
Interface for objects that implement the storage concept. Because this class is registered using
symforce.ops.impl.class_storage_ops.ClassStorageOps
(see bottom of this file), any object that inherits fromStorage
and that implements the functions defined in this class can be used with the StorageOps concept.E.g. calling:
ops.StorageOps.storage_dim(my_obj)
will return the same result as
my_obj.storage_dim()
ifmy_obj
inherits from this class.- StorageT = ~StorageT¶
- to_storage()[source]¶
Flat list representation of the underlying storage, length of
storage_dim()
. This is used purely for plumbing, it is NOT like a tangent space.
- classmethod from_storage(elements)[source]¶
Construct from a flat list representation. Opposite of
to_storage()
.
- simplify()[source]¶
Simplify each scalar element into a new instance.
- Parameters:
self (StorageT) –
- Return type:
StorageT
- classmethod symbolic(name, **kwargs)[source]¶
Construct a symbolic element with the given name prefix. Kwargs are forwarded to
sf.Symbol
(for example, sympy assumptions).
- __hash__()[source]¶
Hash this object in immutable form, by combining all their scalar hashes.
NOTE(hayk, nathan): This is somewhat dangerous because we don’t always guarantee that Storage objects are immutable (e.g. sf.Matrix). If you add this object as a key to a dict, modify it, and access the dict, it will show up as another key because it breaks the abstraction that an object will maintain the same hash over its lifetime.
- Return type: