concepts.dsl.tensor_state.NamedObjectStateMixin#

class NamedObjectStateMixin[source]#

Bases: object

A state type mixin with named objects.

Methods

get_nr_objects_by_type(typename)

Get the number of objects with the given type.

get_typed_index(name[, typename])

Get the typed index of the object with the given name.

get_typename(name)

Get the typename 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_nr_objects_by_type(typename)[source]#

Get the number of objects with the given type.

Parameters:

typename (str) –

Return type:

int

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 – 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

get_typename(name)[source]#

Get the typename of the object with the given name.

Parameters:

name (str) –

Return type:

str

property nr_objects: int#

The number of objects in the current state.