From 076f80c20e6882a00df7d15c2a4762606681415a Mon Sep 17 00:00:00 2001
From: Tiago Freitas Pereira <tiagofrepereira@gmail.com>
Date: Mon, 30 Mar 2020 20:26:08 +0200
Subject: [PATCH] Make annotations not mandatory in the legacy Preprocessor

---
 bob/bio/base/pipelines/vanilla_biometrics/legacy.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/bob/bio/base/pipelines/vanilla_biometrics/legacy.py b/bob/bio/base/pipelines/vanilla_biometrics/legacy.py
index 41f6a4d8..fa64f218 100644
--- a/bob/bio/base/pipelines/vanilla_biometrics/legacy.py
+++ b/bob/bio/base/pipelines/vanilla_biometrics/legacy.py
@@ -182,11 +182,14 @@ class _NonPickableWrapper:
 
 
 class _Preprocessor(_NonPickableWrapper, TransformerMixin, BaseEstimator):
-    def transform(self, X, annotations):
-        return [self.instance(data, annot) for data, annot in zip(X, annotations)]
+    def transform(self, X, annotations=None):
+        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):
-        return {"stateless": True}
+        return {"stateless": True, "requires_fit": False}
 
 
 def _get_pickable_method(method):
@@ -199,11 +202,11 @@ def _get_pickable_method(method):
 
 
 class Preprocessor(CheckpointMixin, SampleMixin, _Preprocessor):
-    def __init__(self, callable, **kwargs):
+    def __init__(self, callable, transform_extra_arguments=(("annotations", "annotations"),), **kwargs):
         instance = callable()
         super().__init__(
             callable=callable,
-            transform_extra_arguments=(("annotations", "annotations"),),
+            transform_extra_arguments=transform_extra_arguments,
             load_func=_get_pickable_method(instance.read_data),
             save_func=_get_pickable_method(instance.write_data),
             **kwargs,
-- 
GitLab