pydra.engine.helpers_state module

Additional functions used mostly by the State class.

exception pydra.engine.helpers_state.PydraStateError(value)

Bases: Exception

Custom error for Pydra State

pydra.engine.helpers_state.add_name_combiner(combiner, name)

adding a node’s name to each field from the combiner

pydra.engine.helpers_state.add_name_splitter(splitter: str | List[str] | Tuple[str, ...] | None, name: str) List[str] | None

adding a node’s name to each field from the splitter

pydra.engine.helpers_state.combine_final_groups(combiner, groups, groups_stack, keys)

Combine the final groups.

pydra.engine.helpers_state.converter_groups_to_input(group_for_inputs)

Return fields for each axis and number of all groups.

Requires having axes for all the input fields.

Parameters:

group_for_inputs – specified axes (groups) for each input

pydra.engine.helpers_state.flatten(vals, cur_depth=0, max_depth=None)

Flatten a list of values.

pydra.engine.helpers_state.input_shape(inp, cont_dim=1)

Get input shape, depends on the container dimension, if not specify it is assumed to be 1

pydra.engine.helpers_state.inputs_types_to_dict(name, inputs)

Convert type.Inputs to dictionary.

pydra.engine.helpers_state.iter_splits(iterable, keys)

Generate splits.

pydra.engine.helpers_state.map_splits(split_iter, inputs, cont_dim=None)

generate a dictionary of inputs prescribed by the splitter.

pydra.engine.helpers_state.remove_inp_from_splitter_rpn(splitter_rpn, inputs_to_remove)

Remove inputs due to combining.

Mutates a splitter.

Parameters:
  • splitter_rpn – The splitter in reverse polish notation

  • inputs_to_remove – input names that should be removed from the splitter

pydra.engine.helpers_state.rpn2splitter(splitter_rpn)

Convert from splitter_rpn to splitter.

Recurrent algorithm to perform the conversion. Every time combines pairs of input in one input, ends when the length is one.

Parameters:

splitter_rpn – splitter in reverse polish notation

Returns:

splitter in the standard/original form

Return type:

splitter

pydra.engine.helpers_state.splits_groups(splitter_rpn, combiner=None, inner_inputs=None)

splits inputs to groups (axes) and creates stacks for these groups This is used to specify which input can be combined.

pydra.engine.helpers_state.splitter2rpn(splitter, other_states=None, state_fields=True)

Translate user-provided splitter into reverse polish notation.

The reverse polish notation is imposed by State.

Parameters:
  • splitter – splitter (standard form)

  • other_states – other states that are connected to the state

  • state_fields (bool) – if False the splitter from the previous states are unwrapped

pydra.engine.helpers_state.unwrap_splitter(splitter: str | List[str] | Tuple[str, ...]) Iterable[str]

Unwraps a splitter into a flat list of fields that are split over, i.e. [(“a”, “b”), “c”] -> [“a”, “b”, “c”]

Parameters:

splitter (str or list[str] or tuple[str, …]) – the splitter spec to unwrap

Returns:

unwrapped – the field names listed in the splitter

Return type:

ty.Iterable[str]