Commit 2b69f538 authored by Yannick DAYER's avatar Yannick DAYER

Prevent propagation of 'annotations' to SampleSets

parent d647dc76
Pipeline #52238 passed with stage
in 19 minutes and 32 seconds
......@@ -20,28 +20,49 @@ from bob.pipelines.sample_loaders import CSVToSampleLoader
logger = logging.getLogger(__name__)
def _empty_attribute():
return None
def convert_samples_to_samplesets(samples, group_by_reference_id=True, references=None):
override_delayed_attributes = dict(annotations=_empty_attribute)
if group_by_reference_id:
# Grouping sample sets
sample_sets = dict()
for s in samples:
if s.reference_id not in sample_sets:
# Create a parent with overridden delayed_attributes
substitute_parent = DelayedSample(
load=None,
parent=s,
delayed_attributes=override_delayed_attributes,
)
sample_sets[s.reference_id] = (
SampleSet([s], parent=s)
SampleSet([s], parent=substitute_parent)
if references is None
else SampleSet([s], parent=s, references=references)
else SampleSet([s], parent=substitute_parent, references=references)
)
else:
sample_sets[s.reference_id].append(s)
return list(sample_sets.values())
else:
return (
[SampleSet([s], parent=s) for s in samples]
if references is None
else [SampleSet([s], parent=s, references=references) for s in samples]
)
sample_sets = list()
for s in samples:
# Create a parent with overridden delayed_attributes
substitute_parent = DelayedSample(
load=None,
parent=s,
delayed_attributes=override_delayed_attributes,
)
sample_sets.append(
SampleSet([s], parent=substitute_parent)
if references is None
else SampleSet([s], parent=substitute_parent, references=references)
)
return sample_sets
class LSTToSampleLoader(CSVToSampleLoader):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment