concepts.dsl.tensor_state.NamedObjectStateMixin#
- class NamedObjectStateMixin[source]#
Bases:
object
A state type mixin with named objects.
Methods
get_default_typename
(name)Get the typename of the object with the given name.
get_name
(typename, index)Get the name of the object with the given type and index.
get_nr_objects_by_type
(typename)Get the number of objects with the given type.
get_objects_by_type
(typename)Get the names of the objects with the given type.
get_state_object_list
(dtype[, indices, names])Get a list of object references with the given type and indices.
get_state_object_reference
(dtype[, index, name])Get the object reference with the given type and index.
get_typed_index
(name[, typename])Get the typed index of the object with the given name.
Attributes
The number of objects in the current state.
- __init__(object_names, object_types=None)[source]#
A state type mixin with named objects. The object names can be either a list of names, or a mapping from names to
ObjectType
’s.If the object_names is a list of names, then the user should also specify a list of object types.
If the object_names is a mapping from names to
ObjectType
’s, then the object_types argument should be None.
- Parameters:
object_names (Iterable[str] | Mapping[str, ObjectType]) – the object names.
object_types (Iterable[ObjectType] | None) – the object types.
- __new__(**kwargs)#
- get_state_object_list(dtype, indices=None, names=None)[source]#
Get a list of object references with the given type and indices.
- Parameters:
- Return type:
- get_state_object_reference(dtype, index=None, name=None)[source]#
Get the object reference with the given type and index.
- Parameters:
dtype (ObjectType | str)
index (int | None)
name (str | None)
- Return type:
- get_typed_index(name, typename=None)[source]#
Get the typed index of the object with the given name. There is an additional typename argument to specify the type of the object. Because the same object can have multiple types (due to inheritence), the object can have multiple typed indices, one for each type. When the typename is not specified, the default type of the object is used (i.e., the most specific type).