ParsedVariable¶
- class component_model.variable_naming.ParsedVariable(varname: str, convention: Enum | None = VariableNamingConvention.structured)¶
Bases:
objectParse the varname with respect to the given VariableNamingConvention.
- Note: The parent hierarchy (if present) is expected to refer to the objects owning the various variables,
It does not refer to variable names, as the FMI examples suggest.
- Results:
dict containing the keys parent (full
parent: full parent name or None,
var: basic variable name,
indices: list of indices (int) as defined in FMI standard or empty list,
der: unsigned integer, defining the derivation order. 0 for no derivation
- __init__(varname: str, convention: Enum | None = VariableNamingConvention.structured)¶
Methods
__init__(varname[, convention])as_string([include, simplified, primitive, ...])Re-construct the variable name, including what is requested and optionally adapting.
as_tuple()Return all fields as tuple.
disect_indices(txt)- static disect_indices(txt: str) tuple[str, list[int]]¶
- as_string(include: tuple[str, ...] = ('parent', 'var', 'indices', 'der'), simplified: bool = True, primitive: bool = False, index: str = '')¶
Re-construct the variable name, including what is requested and optionally adapting.
- Parameters:
include (tuple) – list of strings of what to incdule of “parent”, “var”, “indices”, “der”
simplified (bool) – Optionally change the style to also including superfluous info
primitive (bool) – If true, ‘der’ included and >0, determines the name of the primitive.
index (str) – If !=”” and ‘indices’ included, specifies the index to use
This is convenient to e.g. leave out indices (vector variables) or finding parent names of derivatives.
- as_tuple()¶
Return all fields as tuple.