brain_pipe.pipeline.base.PipelineStep¶
- class PipelineStep(copy_data_dict=False)¶
Bases:
ABC
A preprocessing step.
This class is the base PreprocessingStep class.
The PreprocessingStep is the base building block of all preprocessing pipelines in this repository.
In essence, it is a functor (a class that can be called like a function) that takes a data dictionary and performs some preprocessing on it. The data dictionary can be modified in-place or a copy can be returned.
Some convenient methods are provided to make it easier to write preprocessing steps like the
parse_dict_keys()
method that can be used to parse a key or a sequence of keys.If you want to create your own PreprocessingStep, you can inherit from this class (or another, existing class). For more info about the structure of PreprocessingSteps and how to write them, see Overview.
- __init__(copy_data_dict=False)¶
Initialize the PreprocessingStep.
- Parameters:
copy_data_dict (bool) – Controls whether the input data dict is copied before any operations are applied. If False, the data_dict will be modified in place.
Methods
__init__
([copy_data_dict])Initialize the PreprocessingStep.
parse_dict_keys
(key[, name, ...])Parse a key or a sequence of keys.
- parse_dict_keys(key: str | Sequence[str] | Mapping[str, str], name='key', require_ordered_dict=False) OrderedDict[str, str] ¶
Parse a key or a sequence of keys.
- Parameters:
- Returns:
A mapping of input keys to output keys.
- Return type:
- Raises:
TypeError – If the key is not a string, a sequence of strings or a mapping of strings. If the key is a mapping but require_ordered_dict is True and the mapping is not an OrderedDict.