Skip to content
Snippets Groups Projects
Verified Commit 11f464e1 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

fix: Database now contains an expected all_samples

Corresponds to the bob.bio.base equivalent, allowing use of pad datasets
with bio commands (like bob bio annotate).
parent 0d80c535
No related branches found
No related tags found
No related merge requests found
from __future__ import annotations
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from bob.pipelines import Sample
class Database(metaclass=ABCMeta): class Database(metaclass=ABCMeta):
"""Base database class for PAD experiments.""" """Base database class for PAD experiments."""
@abstractmethod @abstractmethod
def fit_samples(self): def fit_samples(self) -> list[Sample]:
"""Returns :any:`bob.pipelines.Sample`'s to train a PAD model. """Returns :any:`bob.pipelines.Sample`'s to train a PAD model.
Returns Returns
...@@ -16,7 +20,7 @@ class Database(metaclass=ABCMeta): ...@@ -16,7 +20,7 @@ class Database(metaclass=ABCMeta):
pass pass
@abstractmethod @abstractmethod
def predict_samples(self, group="dev"): def predict_samples(self, group: str = "dev") -> list[Sample]:
"""Returns :any:`bob.pipelines.Sample`'s to be scored. """Returns :any:`bob.pipelines.Sample`'s to be scored.
Parameters Parameters
...@@ -30,3 +34,20 @@ class Database(metaclass=ABCMeta): ...@@ -30,3 +34,20 @@ class Database(metaclass=ABCMeta):
List of samples to be scored. List of samples to be scored.
""" """
pass pass
def all_samples(
self, groups: str | list[str] | None = None
) -> list[Sample]:
"""Returns all the samples of the database in one list.
Giving ``groups`` will restrict the ``predict_samples`` to those groups.
"""
samples = self.fit_samples()
if groups is not None:
if type(groups) is str:
groups = [groups]
for group in groups:
samples.extend(self.predict_samples(group=group))
else:
samples.extend(group=None)
return samples
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment