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 from Storage 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() if my_obj inherits from this class.

StorageT = ~StorageT#
classmethod storage_dim()[source]#

Dimension of underlying storage

Return type:

int

__repr__()[source]#

String representation of this type.

Parameters:

self (StorageT) –

Return type:

str

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.

Parameters:

self (StorageT) –

Return type:

List[float]

classmethod from_storage(elements)[source]#

Construct from a flat list representation. Opposite of to_storage().

Parameters:

elements (Sequence[float]) –

Return type:

StorageT

__eq__(other)[source]#

Returns exact equality between self and other.

Parameters:
  • self (StorageT) –

  • other (Any) –

Return type:

bool

subs(*args, **kwargs)[source]#

Substitute given values of each scalar element into a new instance.

Parameters:
  • self (StorageT) –

  • args (Any) –

  • kwargs (Any) –

Return type:

StorageT

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).

Parameters:
  • name (str) –

  • kwargs (Any) –

Return type:

StorageT

evalf()[source]#

Numerical evaluation.

Parameters:

self (StorageT) –

Return type:

StorageT

__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:

int