Parsing#
This module allows to parse configuration files, which use a modified YAML
syntax, to data and iteration trees, as defined in the
iteration module. In particular, it defines the
supported custom YAML types.
- phileas.parsing.load_data_tree_from_yaml_file(file: Path | str) iteration.DataTree[source]#
Parses a YAML configuration file (from its path or its content) into a data tree.
- phileas.parsing.load_iteration_tree_from_yaml_file(file: Path | str) IterationTree[source]#
Parses a YAML configuration file (from its path or its content) into an iteration tree. Iteration will be based on cartesian products, and iteration leaves can be specified with custom YAML types.
- class phileas.parsing.Configurations(configurations: dict[phileas.iteration.base.Key, Any], default: phileas.iteration.base.Key, move_up: bool, insert_name: bool)[source]#
Bases:
YamlCustomTypeConfigurations container. It holds a dictionary of configurations, and has three optional arguments:
_default,_move_upand_insert_name._defaultspecifies the name of the default configuration._move_upis a boolean defaulting toFalse. If it is set, the content of the chosen configuration will be moved one level up._insert_nameis a boolean defaulting toFalse. If it is set, the name of the chosen configuration will be inserted in the final :py:attr`~phileas.iteration.base.DataTree``. Ifmove_up, then it is assigned to the key that previously hold the!configurationsnode. Otherwise, it is inserted under the name"_configuration".See
Configurationsfor more details on the impact of_move_upand_insert_name.
- class phileas.parsing.CartesianProduct(children: dict[phileas.iteration.base.Key, Any] | list, order: list[phileas.iteration.base.Key] | None, lazy: bool, snake: bool)[source]#
Bases:
YamlCustomTypeCartesian product node, see
CartesianProductfor the supported arguments.
- class phileas.parsing.Union(children: dict[phileas.iteration.base.Key, Any] | list, order: list[phileas.iteration.base.Key] | None, lazy: bool, preset: Literal['first'] | Literal['default'] | None, common_preset: bool, reset: Literal['first'] | Literal['last'] | Literal['default'] | None)[source]#
Bases:
YamlCustomTypeUnion node, see
Unionfor the supported arguments.
- class phileas.parsing.Zip(children: dict[phileas.iteration.base.Key, Any] | list, order: list[phileas.iteration.base.Key] | None, lazy: bool, stops_at: Literal['shortest', 'longest'], ignore_fixed: bool)[source]#
Bases:
YamlCustomType
- class phileas.parsing.Shuffle(child: Any)[source]#
Bases:
YamlCustomTypeShuffle node, whose iteration returns a permutation of its only child. It has a single
childfield.
- class phileas.parsing.First(child: Any, size: int | None)[source]#
Bases:
YamlCustomTypeFirstnode, which only iterates over the first elements of its child.
- class phileas.parsing.Pick(children: dict[phileas.iteration.base.Key, Any], default_child: phileas.iteration.base.Key)[source]#
Bases:
YamlCustomTypePick node, whose iteration alternatively returns a single of its children. It contains a named mapping, with a
_default_childfield, containing the key of its default child.
- class phileas.parsing.Range(start: RT, end: RT, default: RT | None = None, steps: int | None = None, resolution: float | int | None = None, progression: Literal['linear', 'geometric'] = 'linear')[source]#
Bases:
YamlCustomType,Generic[RT]Range of numbers, that can optionally (but usually will) specify an iteration method. It can be converted to an iteration leaf using
to_iteration_tree().The
startandendattributes are mandatory, anddefaultcan be optionally specified.stepsorresolution(but not both) can be specified. If they are, andprogressionis not, or equals"linear", the range will representan
IntegerRangeifstartandendare integers andresolutionis used and is an integer;an
LinearRangeotherwise.
If
progressionisgeometric, theRangewill represent anGeometricRange.If neither
stepsnorresolutionis specified, the range will represent anNumericRange.
- class phileas.parsing.Sequence(elements: 'list[iteration.DataTree]', default: 'iteration.DataTree | None' = None)[source]#
Bases:
YamlCustomType
- class phileas.parsing.Random(distribution: 'str', parameters: 'dict[str, Any]', size: 'int | None' = None, default: 'iteration.DataTree | None' = None)[source]#
Bases:
YamlCustomType
- class phileas.parsing.UniformBigIntegerRng(high: 'int', low: 'int' = 0, size: 'int | None' = None, default: 'iteration.DataTree | None' = None)[source]#
Bases:
YamlCustomType
- class phileas.parsing.PrimeRng(high: 'int', low: 'int' = 0, size: 'int | None' = None, default: 'iteration.DataTree | None' = None)[source]#
Bases:
YamlCustomType