- class sakkara.relation.representation.Representation#
Abstract class for a representation, i.e., class that transforms variables and other elements between different shapes.
- abstract get_member_array(group: Group) ndarray[Any, dtype[Any]]#
Get an array shaped as a variable with this representation, where each value correspond to the member of the input group.
- abstract get_member_tuples() List[Tuple[Any, ...]]#
Get a (flat) list of all member tuples of this representation
- abstract get_members() Tuple[ndarray[Any, dtype[ScalarType]], ...]#
Get member arrays for all groups of this representation. For documentation of a member array, see
Representation.get_member_array().
- abstract get_shape() Tuple[int, ...]#
Get the shape of a variable corresponding to a component with this representation
- abstract map(element: Any, target_representation: Representation) Any#
Map/transform an element (variable or equivalent) corresponding to this representation to a target representation.
- Parameters:
element – The object/variable to transform.
target_representation – The representation that corresponds to the shape the variable should be in.
- Returns:
The element but transformed to target representation.
- class sakkara.relation.representation.UnrepeatableRepresentation#
Simple representation for elements that always have a single value and that can not be repeated.
- get_member_array(group: Group) ndarray[Any, dtype[Any]]#
Get an array shaped as a variable with this representation, where each value correspond to the member of the input group.
- get_member_tuples() List[Tuple[Any, ...]]#
Get a (flat) list of all member tuples of this representation
- get_members() Tuple[ndarray[Any, dtype[ScalarType]], ...]#
Get member arrays for all groups of this representation. For documentation of a member array, see
Representation.get_member_array().
- get_shape() Tuple[int, ...]#
Get the shape of a variable corresponding to a component with this representation
- map(element: object, target_representation: Representation)#
Map/transform an element (variable or equivalent) corresponding to this representation to a target representation.
- Parameters:
element – The object/variable to transform.
target_representation – The representation that corresponds to the shape the variable should be in.
- Returns:
The element but transformed to target representation.
- class sakkara.relation.representation.TensorRepresentation(*groups: Group)#
Class for representation shapes corresponding to sequneces of groups.
- Parameters:
*groups –
Groupobjects to include in representation
- get_group_mapping(target: Representation) Dict[Group, Tuple[Group, ...]]#
Check if representation is mappable to another representation, i.e., groups of the other representation have twins or parents among the groups of this representation.
- Returns:
True is self is mappable to target
- get_member_array(group: Group) ndarray[Any, dtype[Any]]#
Get an array shaped as a variable with this representation, where each value correspond to the member of the input group.
- get_member_tuples() List[Tuple[Any, ...]]#
Get a (flat) list of all member tuples of this representation
- get_members() Tuple[ndarray[Any, dtype[ScalarType]], ...]#
Get member arrays for all groups of this representation. For documentation of a member array, see
Representation.get_member_array().
- get_shape() Tuple[int, ...]#
Get the shape of a variable corresponding to a component with this representation
- map(element: Any, target: Representation) Any#
Map/transform an element (variable or equivalent) corresponding to this representation to a target representation.
- Parameters:
element – The object/variable to transform.
target_representation – The representation that corresponds to the shape the variable should be in.
- Returns:
The element but transformed to target representation.
- class sakkara.relation.representation.MinimalTensorRepresentation(*groups: Group)#
Tensor representation that always keeps the minimal set of groups needed. E.g., groups will not be added to this representation if there already is a twin or a child in the representation. When adding a group that has a parent in the representation, the group will be added and the parent will be removed. This class is currently the only implementation of TensorRepresentation.