Skip to content
Snippets Groups Projects
Verified Commit 4db20087 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 2ffed364
No related branches found
No related tags found
1 merge request!112fix: Database now contains an expected all_samples
from __future__ import annotations
from abc import ABCMeta, abstractmethod
from bob.pipelines import Sample
class Database(metaclass=ABCMeta):
"""Base database class for PAD experiments."""
@abstractmethod
def fit_samples(self):
def fit_samples(self) -> list[Sample]:
"""Returns :any:`bob.pipelines.Sample`'s to train a PAD model.
Returns
......@@ -16,7 +20,7 @@ class Database(metaclass=ABCMeta):
pass
@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.
Parameters
......@@ -30,3 +34,20 @@ class Database(metaclass=ABCMeta):
List of samples to be scored.
"""
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