Domain

Definitions

This module describes the domain class which represents the space of the solution.

The variable definitions are internally stored in a member variable which support three different TYPES:

  • BASIC: Includes support for the basic types INTEGER, REAL and CATEGORICAL which are definitions of int, float and list respectively.

    • INTEGER: Support integer possitive/negative numerical values.

    • REAL: Support floating point possitive/negative numerical values.

    • CATEGORICAL: Support list of int, float and str values. Every component in the category must have the same type.

  • VECTOR: Support an list of numerical values (INTEGER or REAL) with fixed range. The VECTOR also support for variable size definition.

  • LAYER: Support complex structures as a dictionary. The layer defines some variables (string) which value may be the previously described.

Every variable has a different definition depending of its TYPE using the tuple: .. code-block:: python

(TYPE, *args)

where TYPE represents any type defined previously, while args are the specific configuration depending of its TYPE.

Structure for BASIC definition ( BASICDEF )

  • INTEGERDEF: (INTEGER, Maximum value [int], Minimum value [int], Step[int])

  • REALDEF: (REAL, Maximum value [float], Minimum value [float], Step[float])

  • CATEGORICALDEF: (CATEGORICAL, Categories[list(BASIC)*])

Internal structure for LAYER definition ( LAYERDEF )

(LAYER, {"ATTRIBUTE": BASICDEF, "ATTRIBUTE": VECTORDEF, …})

Internal structure for VECTOR definition ( VECTORDEF )

  • (VECTOR, Maximum size [int], Minimum size [int], Step size [int], [INTEGERDEF, …])

  • (VECTOR, Maximum size [float], Minimum size [float], Step size [float], [REALDEF, …])

  • (VECTOR, Maximum size [float], Minimum size [float], Step size [float], [CATEGORICALDEF, …])

  • (VECTOR, Maximum size [float], Minimum size [float], Step size [float], [LAYERDEF, …])

The details of the definition are described in the Core.

Domain class

__init__([connector])

This class encompasses the domain of the problem by defining a set of variables and its possible values.

define_integer(name, min_value, max_value[, ...])

It defines an INTEGER variable receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

define_real(name, min_value, max_value[, step])

It defines a REAL variable receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

define_categorical(name, categories)

It defines a CATEGORICAL variable receiving a name as its identifier, and a list with the categories that it will be able to have.

define_group(name)

It defines a GROUP variable receiving a name as its identifier, and a list with the categories that it will be able to have.

define_integer_in_group(group, name, ...[, step])

It defines an INTEGER variable in an already defined group, receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

define_real_in_group(group, name, min_value, ...)

It defines an REAL variable in an already defined group, receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

define_categorical_in_group(group, name, ...)

It defines a CATEGORICAL variable in an already defined group, receiving a name as its identifier, and a list with the categories that it will be able to have.

link_variable_to_group(group, var[, remember])

Include a defined variable to a defined group.

define_dynamic_structure(name, min_len, max_len)

It defines an DynamicStructure variable receiving a name as its identifier, the minimum and maximum size that it will be able to have, and the step size to traverse the size.

define_static_structure(name, length[, var, ...])

It defines an StaticStructure variable receiving a name as its identifier, the size that it will be able to have, and the step size to traverse the size.

set_structure_to_integer(name, min_value, ...)

It defines an INTEGER as the base type for a Static or Dynamic Structure, receiving the name of the structure, the minimum and maximum values that the values will be able to have, and the step size to traverse the interval.

set_structure_to_real(name, min_value, max_value)

It defines an REAL as the base type for a Static or Dynamic Structure, receiving the name of the structure, the minimum and maximum values that the values will be able to have, and the step size to traverse the interval.

set_structure_to_variable(name, var[, remember])

It defines an already defined variable the base type for a Static or Dynamic Structure, receiving the name of the structure and the variable.

get_core()

It returns the core which contains the all the defined variables.

class Domain(connector: ~metagen.framework.connector.connector.BaseConnector = <metagen.framework.connector.connector.BaseConnector object>)

Bases: object

This class encompasses the domain of the problem by defining a set of variables and its possible values. The user must instantiate the class, then, define the variables using the member methods of the class.

Example:

>>> new_domain = Domain()
>>> new_domain.define_integer("IntegerValue", 0, 10)
>>> new_domain.define_categorical("CategoricalValue", ["C1","C2","C3"])
>>> new_domain.define_real("RealValue", 0, 1)
>>> new_domain.define_group("Group")
>>> new_domain.link_variable_to_group("Group", "RealValue")
define_integer(name: str, min_value: int, max_value: int, step: int | None = None)

It defines an INTEGER variable receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

Parameters:
  • name (str) – The variable name.

  • min_value (int) – The minimum value.

  • max_value (int) – The maximum value.

  • step (int) – The step size.

define_real(name: str, min_value: float, max_value: float, step: float | None = None)

It defines a REAL variable receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

Parameters:
  • name (str) – The variable name.

  • min_value (float) – The minimum value.

  • max_value (float) – The maximum value.

  • step (float) – The step size.

define_categorical(name: str, categories: List[int] | List[float] | List[str])

It defines a CATEGORICAL variable receiving a name as its identifier, and a list with the categories that it will be able to have.

Parameters:
  • name (str) – The variable name.

  • categories (list of int, float or str) – The list of categories.

define_group(name: str)

It defines a GROUP variable receiving a name as its identifier, and a list with the categories that it will be able to have.

Parameters:

name (str) – The group name.

define_integer_in_group(group: str, name: str, min_value: int, max_value: int, step: int | None = None)

It defines an INTEGER variable in an already defined group, receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

Parameters:
  • group (str) – The group name.

  • name (str) – The variable name.

  • min_value (int) – The minimum value.

  • max_value (int) – The maximum value.

  • step (int) – The step size.

define_real_in_group(group: str, name: str, min_value: float, max_value: float, step: float | None = None)

It defines an REAL variable in an already defined group, receiving a name as its identifier, the minimum and maximum values that it will be able to have, and the step size to traverse the interval.

Parameters:
  • group (str) – The group name.

  • name (str) – The variable name.

  • min_value (float) – The minimum value.

  • max_value (float) – The maximum value.

  • step (float) – The step size.

define_categorical_in_group(group: str, name: str, categories: List[int] | List[float] | List[str])

It defines a CATEGORICAL variable in an already defined group, receiving a name as its identifier, and a list with the categories that it will be able to have.

Parameters:
  • group (str) – The group name.

  • name (str) – The variable name.

  • categories (list of int, float or str) – The list of categories.

Include a defined variable to a defined group. Note that only one level of grouping is allowed.

Parameters:
  • group (str) – The group name.

  • var – The variable name.

  • remember (bool) – TODO

define_dynamic_structure(name: str, min_len: int, max_len: int, step_len: int | None = None, var: str | None = None, remember: bool = False)

It defines an DynamicStructure variable receiving a name as its identifier, the minimum and maximum size that it will be able to have, and the step size to traverse the size.

Parameters:
  • name (str) – The variable name.

  • min_len (int) – The minimum length of the Structure.

  • max_len (int) – The maximum length of the Structure.

  • step_len (int) – The step size.

define_static_structure(name: str, length: int, var: str | None = None, remember: bool = False)

It defines an StaticStructure variable receiving a name as its identifier, the size that it will be able to have, and the step size to traverse the size.

Parameters:
  • name (str) – The variable name.

  • length (int) – The length of the Structure.

set_structure_to_integer(name: str, min_value: int, max_value: int, step: int | None = None)

It defines an INTEGER as the base type for a Static or Dynamic Structure, receiving the name of the structure, the minimum and maximum values that the values will be able to have, and the step size to traverse the interval.

Parameters:
  • name (str) – The structure name.

  • min_value (int) – The minimum value.

  • max_value (int) – The maximum value.

  • step (int) – The step size.

set_structure_to_categorical(name: str, categories: List[int] | List[float] | List[str])

It defines an CATEGORICAL as the base type for a Static or Dynamic Structure, and a list with the categories that it will be able to have.

Parameters:
  • name (str) – The structure name.

  • categories (list of int, float or str) – The list of categories.

set_structure_to_real(name: str, min_value: float, max_value: float, step: float | None = None)

It defines an REAL as the base type for a Static or Dynamic Structure, receiving the name of the structure, the minimum and maximum values that the values will be able to have, and the step size to traverse the interval.

Parameters:
  • name (str) – The structure name.

  • min_value (float) – The minimum value.

  • max_value (float) – The maximum value.

  • step (float) – The step size.

set_structure_to_variable(name: str, var: str, remember: bool = False)

It defines an already defined variable the base type for a Static or Dynamic Structure, receiving the name of the structure and the variable. :param name: The structure name. :param var: The variable value. :type name: str :type var: str

get_core() BaseDefinition

It returns the core which contains the all the defined variables.

get_connector() BaseConnector

It returns the defined connector for this domain.

Core

digraph inheritance4667489bb0 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Base" [URL="#metagen.framework.domain.core.Base",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Abstract base class for metagen definitions with a common interface."]; "BaseDefinition" [URL="#metagen.framework.domain.core.BaseDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="The BaseDefinition class represents a definition of a set of variables."]; "Base" -> "BaseDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseStructureDefinition" [URL="#metagen.framework.domain.core.BaseStructureDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A base abstract class that defines the structure of a definition"]; "CategoricalDefinition" [URL="#metagen.framework.domain.core.CategoricalDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents a categorical attribute with a set of allowed categories."]; "Base" -> "CategoricalDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Definition" [URL="#metagen.framework.domain.core.Definition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Definition is a named collection of variables with their respective definitions."]; "BaseDefinition" -> "Definition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "DynamicStructureDefinition" [URL="#metagen.framework.domain.core.DynamicStructureDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A class representing a dynamic structure definition."]; "Base" -> "DynamicStructureDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseStructureDefinition" -> "DynamicStructureDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "IntegerDefinition" [URL="#metagen.framework.domain.core.IntegerDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents an integer type with defined minimum, maximum and step values."]; "Base" -> "IntegerDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "RealDefinition" [URL="#metagen.framework.domain.core.RealDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Represents a real number type with defined minimum, maximum and step values."]; "Base" -> "RealDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "StaticStructureDefinition" [URL="#metagen.framework.domain.core.StaticStructureDefinition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Class representing a static structure definition."]; "Base" -> "StaticStructureDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "BaseStructureDefinition" -> "StaticStructureDefinition" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Base

class Base(meta_type: Literal['DEFINITION', 'INTEGER', 'REAL', 'CATEGORICAL', 'DYNAMIC', 'STATIC'])

Bases: ABC

Abstract base class for metagen definitions with a common interface.

Note

This class is abstract and should not be instantiated directly.

Initializes a new instance assigning the metagen internal type.

Parameters:

meta_type (METAGEN_TYPE) – The metagen internal type.

abstractmethod check_value(value: Any) bool

Abstract method to check the validity of the values in the definition.

Parameters:

value (Any) – The value to be checked.

Returns:

True if the value is valid, False otherwise.

Return type:

bool

abstractmethod get_attributes() Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | Tuple[Literal['DYNAMIC'], int, int, int | None, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None] | Tuple[Literal['STATIC'], int, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None]

Abstract method to obtain the internal attributes which constitutes the definition.

Returns:

The internal attributes of the definition.

Return type:

Attributes

get_type() Literal['DEFINITION', 'INTEGER', 'REAL', 'CATEGORICAL', 'DYNAMIC', 'STATIC']

Return the internal type of the definition which can be one of: I, R, C, D or S.

Returns:

The internal type of the definition.

Return type:

METAGEN_TYPE

class BaseDefinition

Bases: Base

The BaseDefinition class represents a definition of a set of variables.

Returns:

An instance of the BaseDefinition class.

Initializes a new instance of the BaseDefinition class.

check_value(value: Any) bool

Checks whether a given value is valid based on the current definition.

Parameters:

value – A dictionary representing the variable and its value.

Returns:

A boolean indicating whether the given value is valid based on the current definition.

get_attributes() Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]

Returns the attributes of the current definition.

Returns:

A tuple containing the type and attributes of the current definition.

define(name: str, definition: Base)

Defines a new variable and its definition.

Parameters:
  • name – A string representing the name of the variable.

  • definition – An instance of a Base class representing the definition of the variable.

delete(name: str)

Deletes a variable from the current definition.

Parameters:

name – A string representing the name of the variable.

get(name: str) Base

Returns the definition of a variable.

Parameters:

name – A string representing the name of the variable.

Returns:

An instance of a Base class representing the definition of the variable.

get_by_index(index: int) Base

Returns the definition of a variable by its index in the variable list.

Parameters:

index – An integer representing the index of the variable.

Returns:

An instance of a Base class representing the definition of the variable.

check(name: str, value: MetaVal) bool

Checks whether a given value is valid for a variable.

Parameters:
  • name – A string representing the name of the variable.

  • value – A value representing the value of the variable.

Returns:

A boolean indicating whether the given value is valid for the variable.

is_variable(name: str) bool

Check if a variable with the given name exists in the definition.

Parameters:

name (str) – The name of the variable to check.

Returns:

True if the variable exists, False otherwise.

Return type:

bool

variable_list() List[str]

Get a list of all variable names defined in the definition.

Returns:

A list of all variable names.

Return type:

List[str]

to_string(level: int) str

Get a string representation of the definition at the given level of indentation.

Parameters:

level (int) – The level of indentation to use.

Returns:

A string representation of the definition.

Return type:

str

class BaseStructureDefinition(base: Base | None)

Bases: ABC

A base abstract class that defines the structure of a definition with a base type.

Parameters:

base – An instance of a base type.

abstractmethod check_length(value: Any) bool

Abstract method to check if the value has the correct length.

Parameters:

value – The value to check the length for.

Returns:

True if the length is correct, otherwise False.

check_value(value: Any) bool

Check if the value is valid in the definition.

Parameters:

value – The value to check.

Returns:

True if the value is valid, otherwise False.

get_base() Base

Get the base type for the definition.

Returns:

The base type.

set_base(base: Base)

Set the base type.

Parameters:

base – The base type to set.

is_base()

Check if the base type is defined.

Returns:

True if the base type is defined, otherwise False.

check_base_value(val: MetaVal) bool

Check if the base type value is valid.

Parameters:

val – The value to check.

Returns:

True if the value is valid, otherwise False.

IntegerDefinition

class IntegerDefinition(min_value: int, max_value: int, step: int | None = None)

Bases: Base

Represents an integer type with defined minimum, maximum and step values.

Parameters:
  • min_value (int) – The minimum value allowed for the integer type.

  • max_value (int) – The maximum value allowed for the integer type.

  • step (int or None) – The step value for the integer type. Defaults to None if not provided.

Raises:

ValueError – If the min_value, max_value or step values do not meet the integer range requirements.

Variables:
  • __min_value – The minimum value allowed for the integer type.

  • __max_value – The maximum value allowed for the integer type.

  • __step – The step value for the integer type. Defaults to None if not provided.

Returns:

An instance of the IntegerDefinition class.

Return type:

IntegerDefinition

Initializes an instance of the IntegerDefinition class with the provided minimum, maximum and step values.

Parameters:
  • min_value (int) – The minimum value allowed for the integer type.

  • max_value (int) – The maximum value allowed for the integer type.

  • step (int or None) – The step value for the integer type. Defaults to None if not provided.

Raises:

ValueError – If the min_value, max_value or step values do not meet the integer range requirements.

get_attributes() Tuple[Literal['INTEGER'], int, int, int | None]

Returns the integer attributes of the IntegerDefinition instance.

Returns:

A tuple containing the integer type, minimum value, maximum value and step value of the IntegerDefinition instance.

Return type:

IntAttr

check_value(value: Any) bool

Checks if the provided value is a valid integer within the range of the IntegerDefinition instance.

Parameters:

value (Any) – The value to be checked.

Returns:

True if the value is a valid integer within the range of the IntegerDefinition instance, False otherwise.

Return type:

bool

RealDefinition

class RealDefinition(min_value: float, max_value: float, step: float | None = None)

Bases: Base

Represents a real number type with defined minimum, maximum and step values.

Parameters:
  • min_value (float) – The minimum value allowed for the real number type.

  • max_value (float) – The maximum value allowed for the real number type.

  • step (float or None) – The step value for the real number type. Defaults to None if not provided.

Raises:

ValueError – If the min_value, max_value or step values do not meet the real number range requirements.

Variables:
  • __min_value – The minimum value allowed for the real number type.

  • __max_value – The maximum value allowed for the real number type.

  • __step – The step value for the real number type. Defaults to None if not provided.

Returns:

An instance of the RealDefinition class.

Return type:

RealDefinition

Initializes an instance of the RealDefinition class with the provided minimum, maximum and step values.

Parameters:
  • min_value (float) – The minimum value allowed for the real number type.

  • max_value (float) – The maximum value allowed for the real number type.

  • step (float or None) – The step value for the real number type. Defaults to None if not provided.

Raises:

ValueError – If the min_value, max_value or step values do not meet the real number range requirements.

get_attributes() Tuple[Literal['REAL'], float, float, float | None]

Returns the real number attributes of the RealDefinition instance.

Returns:

A tuple containing the real number type, minimum value, maximum value and step value of the RealDefinition instance.

Return type:

RealAttr

check_value(value: Any) bool

Checks if the provided value is a valid real number within the range of the RealDefinition instance.

Parameters:

value (Any) – The value to be checked.

Returns:

True if the value is a valid real number within the range of the RealDefinition instance, False otherwise.

Return type:

bool

CategoricalDefinition

class CategoricalDefinition(categories: List[int] | List[float] | List[str])

Bases: Base

Represents a categorical attribute with a set of allowed categories.

Parameters:

categories (CatVal) – a list or set of allowed categories.

Raises:

ValueError – if categories is empty or not a list or set.

Returns:

An instance of the CategoricalDefinition class.

Return type:

CategoricalDefinition

Initialize the CategoricalDefinition instance.

Parameters:

categories (CatVal) – a list or set of allowed categories.

Raises:

ValueError – if categories is empty or not a list or set.

get_attributes() Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]]

Return the categorical type C and the allowed categories __categories.

Returns:

a tuple containing the categorical type C and the allowed categories __categories.

Return type:

CatAttr

check_value(value: Any) bool

Check if the given value is in the allowed categories.

Parameters:

value (Any) – the value to be checked.

Returns:

True if the value is in the allowed categories, False otherwise.

Return type:

bool

DynamicStructureDefinition

class DynamicStructureDefinition(name: str, base: Base | None, min_length: int, max_length: int, step_length: int | None = None)

Bases: Base, BaseStructureDefinition

A class representing a dynamic structure definition.

Parameters:
  • name (str) – A string representing the name of the dynamic structure definition.

  • base (Base or None) – A Base representing the base type of the dynamic structure definition.

  • min_length (int) – An integer representing the minimum length of the dynamic structure definition.

  • max_length (int) – An integer representing the maximum length of the dynamic structure definition.

  • step_length (int or None) – An optional integer representing the step length of the dynamic structure definition.

Raises:

ValueError – If the base type is not defined.

Initializes a DynamicStructureDefinition object with the given name, base type, minimum length, maximum length, and step length.

Parameters:
  • name (str) – A string representing the name of the dynamic structure definition.

  • base (Base or None) – A Base representing the base type of the dynamic structure definition.

  • min_length (int) – An integer representing the minimum length of the dynamic structure definition.

  • max_length (int) – An integer representing the maximum length of the dynamic structure definition.

  • step_length (int or None) – An optional integer representing the step length of the dynamic structure definition.

check_value(value: StrVal) bool

Checks whether the given value is a valid dynamic structure definition.

Parameters:

value (StrVal) – A string value to be checked.

Returns:

A boolean value indicating whether the given value is a valid dynamic structure definition.

Return type:

bool

get_attributes() Tuple[Literal['DYNAMIC'], int, int, int | None, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None]

Returns the attributes of the dynamic structure definition.

Returns:

A tuple representing the attributes of the dynamic structure definition.

Return type:

DymAttr

check_length(value: StrVal) bool

Checks whether the length of the given value is within the minimum and maximum length of the dynamic structure definition.

Parameters:

value (StrVal) – A string value to be checked.

Returns:

A boolean value indicating whether the length of the given value is within the minimum and maximum length of the dynamic structure definition.

Return type:

bool

StaticStructureDefinition

class StaticStructureDefinition(name: str, base: Base | None, length: int)

Bases: Base, BaseStructureDefinition

Class representing a static structure definition.

Parameters:
  • name (str) – Name of the structure definition.

  • base (Base or None) – Base type of the structure definition.

  • length (int) – Length of the structure definition.

Constructs a new StaticStructureDefinition object.

Parameters:
  • name (str) – Name of the structure definition.

  • base (Base or None) – Base type of the structure definition.

  • length (int) – Length of the structure definition.

check_value(value: StrVal) bool

Checks if the given value is a valid value for this StaticStructureDefinition.

Parameters:

value (StrVal) – The value to check.

Returns:

True if the given value is valid for this StaticStructureDefinition, False otherwise.

Return type:

bool

get_attributes() Tuple[Literal['STATIC'], int, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None]

Gets the attributes of this StaticStructureDefinition.

Returns:

The attributes of this StaticStructureDefinition.

Return type:

Tuple[str, int, Dict[str, Any]]

check_length(value: StrVal) bool

Checks if the given value has the correct length for this StaticStructureDefinition.

Parameters:

value (StrVal) – The value to check.

Returns:

True if the given value has the correct length for this StaticStructureDefinition, False otherwise.

Return type:

bool

Definition

class Definition(name: str)

Bases: BaseDefinition

A Definition is a named collection of variables with their respective definitions.

Inherits from BaseDefinition.

Parameters:

name – A string representing the name of the definition.

Initializes a Definition instance with the specified name.

Parameters:

name – A string representing the name of the definition.

get_name() str

Returns the name of the Definition instance.

Returns:

A string representing the name of the Definition instance.

get_definition() Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | Tuple[Literal['DYNAMIC'], int, int, int | None, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None] | Tuple[Literal['STATIC'], int, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | Tuple[Literal['DEFINITION'], Mapping[str, Tuple[Literal['INTEGER'], int, int, int | None] | Tuple[Literal['REAL'], float, float, float | None] | Tuple[Literal['CATEGORICAL'], List[int] | List[float] | List[str]] | DefAttr]]]] | None]]

Returns a dictionary representing the attributes of the Definition instance.

Returns:

A dictionary representing the attributes of the Definition instance.