How to use the pydra.engine.helpers_state.splitter2rpn function in pydra

To help you get started, we’ve selected a few pydra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nipype / pydra / pydra / engine / state.py View on Github external
def set_input_groups(self, state_fields=True):
        """Evaluate groups, especially the final groups that address the combiner."""
        right_splitter_rpn = hlpst.splitter2rpn(
            self.right_splitter,
            other_states=self.other_states,
            state_fields=state_fields,
        )
        # merging groups from previous nodes if any input come from previous the nodes
        if self.inner_inputs:
            self._merge_previous_groups()
        keys_f, group_for_inputs_f, groups_stack_f, combiner_all = hlpst.splits_groups(
            right_splitter_rpn,
            combiner=self.right_combiner,
            inner_inputs=self.inner_inputs,
        )
        self._right_combiner_all = combiner_all
        if self.left_splitter and state_fields:  # if splitter has also the left part
            self._right_keys_final = keys_f
            self._right_group_for_inputs_final = group_for_inputs_f
github nipype / pydra / pydra / engine / state.py View on Github external
def prepare_states_combined_ind(self, elements_to_remove_comb):
        """Prepare the final list of dictionaries with indices after combiner."""
        partial_rpn_compact = hlpst.remove_inp_from_splitter_rpn(
            deepcopy(self.splitter_rpn_compact), elements_to_remove_comb
        )
        # combiner can have parts from the left splitter, so have to have rpn with states
        partial_rpn = hlpst.splitter2rpn(
            hlpst.rpn2splitter(partial_rpn_compact), other_states=self.other_states
        )
        combined_rpn = hlpst.remove_inp_from_splitter_rpn(
            deepcopy(partial_rpn), self.right_combiner_all + self.left_combiner_all
        )
        if combined_rpn:
            val_r, key_r = hlpst.splits(
                combined_rpn,
                self.inputs,
                inner_inputs=self.inner_inputs,
                cont_dim=self.cont_dim,
            )
            values = list(val_r)
        else:
            values = []
            key_r = []
github nipype / pydra / pydra / engine / state.py View on Github external
def _left_right_check(self, splitter_part, check_nested=True):
        """
        Check if splitter_part is purely Left, Right
        or [Left, Right] if the splitter_part is a list (outer splitter)

        String is returned.

        If the splitter_part is mixed exception is raised.

        """
        rpn_part = hlpst.splitter2rpn(
            splitter_part, other_states=self.other_states, state_fields=False
        )
        inputs_in_splitter = [i for i in rpn_part if i not in ["*", "."]]
        others_in_splitter = [
            True if el.startswith("_") else False for el in inputs_in_splitter
        ]
        if all(others_in_splitter):
            return "Left"
        elif (not all(others_in_splitter)) and (not any(others_in_splitter)):
            return "Right"
        elif (
            isinstance(self.splitter, list)
            and check_nested
            and self._left_right_check(self.splitter[0], check_nested=False) == "Left"
            and self._left_right_check(self.splitter[1], check_nested=False) == "Right"
        ):
github nipype / pydra / pydra / engine / state.py View on Github external
def splitter_rpn(self):
        _splitter_rpn = hlpst.splitter2rpn(
            self.splitter, other_states=self.other_states
        )
        return _splitter_rpn
github nipype / pydra / pydra / engine / state.py View on Github external
def _complete_left(self, left=None):
        """Add all splitters from previous nodes (completing the Left part)."""
        if left:
            rpn_left = hlpst.splitter2rpn(
                left, other_states=self.other_states, state_fields=False
            )
            for name, (st, inp) in list(self.other_states.items())[::-1]:
                if f"_{name}" not in rpn_left and st.splitter_final:
                    left = [f"_{name}", left]
        else:
            left = [f"_{name}" for name in self.other_states]
            if len(left) == 1:
                left = left[0]
        return left
github nipype / pydra / pydra / engine / state.py View on Github external
def left_splitter_rpn(self):
        if self.left_splitter:
            left_splitter_rpn = hlpst.splitter2rpn(
                self.left_splitter, other_states=self.other_states
            )
            return left_splitter_rpn
        else:
            return []
github nipype / pydra / pydra / engine / state.py View on Github external
def splitter_rpn_compact(self):
        if self.other_states:
            _splitter_rpn_compact = hlpst.splitter2rpn(
                self.splitter, other_states=self.other_states, state_fields=False
            )
            return _splitter_rpn_compact
        else:
            return self.splitter_rpn