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

nr_objects

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:
__new__(**kwargs)#
get_default_typename(name)[source]#

Get the typename of the object with the given name.

Parameters:

name (str)

Return type:

str

get_name(typename, index)[source]#

Get the name of the object with the given type and index.

Parameters:
Return type:

str

get_nr_objects_by_type(typename)[source]#

Get the number of objects with the given type.

Parameters:

typename (str)

Return type:

int

get_objects_by_type(typename)[source]#

Get the names of the objects with the given type.

Parameters:

typename (str)

Return type:

List[str]

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:

StateObjectList

get_state_object_reference(dtype, index=None, name=None)[source]#

Get the object reference with the given type and index.

Parameters:
Return type:

StateObjectReference

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

Parameters:
  • name (str) – the name of the object.

  • typename (str | None) – the typename of the object. If not specified, the default type of the object is used (i.e. the most specific type).

Returns:

the typed index of the object.

Return type:

int

property nr_objects: int#

The number of objects in the current state.