Skip to content
Snippets Groups Projects
Commit 076f80c2 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Make annotations not mandatory in the legacy Preprocessor

parent c0cd0dca
No related branches found
No related tags found
1 merge request!180[dask] Preparing bob.bio.base for dask pipelines
Pipeline #38541 failed
...@@ -182,11 +182,14 @@ class _NonPickableWrapper: ...@@ -182,11 +182,14 @@ class _NonPickableWrapper:
class _Preprocessor(_NonPickableWrapper, TransformerMixin, BaseEstimator): class _Preprocessor(_NonPickableWrapper, TransformerMixin, BaseEstimator):
def transform(self, X, annotations): def transform(self, X, annotations=None):
return [self.instance(data, annot) for data, annot in zip(X, annotations)] if annotations is None:
return [self.instance(data) for data in X]
else:
return [self.instance(data, annot) for data, annot in zip(X, annotations)]
def _more_tags(self): def _more_tags(self):
return {"stateless": True} return {"stateless": True, "requires_fit": False}
def _get_pickable_method(method): def _get_pickable_method(method):
...@@ -199,11 +202,11 @@ def _get_pickable_method(method): ...@@ -199,11 +202,11 @@ def _get_pickable_method(method):
class Preprocessor(CheckpointMixin, SampleMixin, _Preprocessor): class Preprocessor(CheckpointMixin, SampleMixin, _Preprocessor):
def __init__(self, callable, **kwargs): def __init__(self, callable, transform_extra_arguments=(("annotations", "annotations"),), **kwargs):
instance = callable() instance = callable()
super().__init__( super().__init__(
callable=callable, callable=callable,
transform_extra_arguments=(("annotations", "annotations"),), transform_extra_arguments=transform_extra_arguments,
load_func=_get_pickable_method(instance.read_data), load_func=_get_pickable_method(instance.read_data),
save_func=_get_pickable_method(instance.write_data), save_func=_get_pickable_method(instance.write_data),
**kwargs, **kwargs,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment