pydra.engine.helpers_state module

Additional functions used mostly by the State class.

exception pydra.engine.helpers_state.PydraStateError(value)[source]

Bases: Exception

Custom error for Pydra State

pydra.engine.helpers_state.add_name_combiner(combiner, name)[source]

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

pydra.engine.helpers_state.add_name_splitter(splitter, name)[source]

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

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

Combine the final groups.


Return fields for each axis and number of all groups.

Requires having axes for all the input fields.


group_for_inputs – specified axes (groups) for each input

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

Flatten a list of values.

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

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)[source]

Convert type.Inputs to dictionary.

pydra.engine.helpers_state.iter_splits(iterable, keys)[source]

Generate splits.

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

generate a dictionary of inputs prescribed by the splitter.

pydra.engine.helpers_state.remove_inp_from_splitter_rpn(splitter_rpn, inputs_to_remove)[source]

Remove inputs due to combining.

Mutates a splitter.

  • splitter_rpn – The splitter in reverse polish notation

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


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.


splitter_rpn – splitter in reverse polish notation


splitter in the standard/original form

Return type


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

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)[source]

Translate user-provided splitter into reverse polish notation.

The reverse polish notation is imposed by State.

  • 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