Commit 8bcdefc3 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira

Merge branch 'delayedsample-fix' into 'master'

Get SampleSet to accept DelayedSample

Closes #9

See merge request !20
parents de866405 17f77d5a
Pipeline #38739 failed with stages
in 7 minutes and 49 seconds
......@@ -93,18 +93,11 @@ class SampleSet(MutableSequence):
return self.samples.__getitem__(item)
def __setitem__(self, key, item):
if not isinstance(item, Sample):
raise ValueError(f"item should be of type Sample, not {item}")
return self.samples.__setitem__(key, item)
def __delitem__(self, item):
return self.samples.__delitem__(item)
def insert(self, index, item):
if not isinstance(item, Sample):
raise ValueError(f"item should be of type Sample, not {item}")
# if not item in self.samples:
self.samples.insert(index, item)
from bob.pipelines.sample import Sample, SampleSet, DelayedSample
import numpy
from nose.tools import assert_raises
import copy
......@@ -23,17 +22,9 @@ def test_sampleset_collection():
del sampleset[0]
assert len(sampleset) == n_samples
# Testing exception
with assert_raises(ValueError):
sampleset.insert(1, 10)
# Testing set
sampleset[0] = copy.deepcopy(sample)
# Testing exception
with assert_raises(ValueError):
sampleset[0] = "xuxa"
# Testing iterator
for i in sampleset:
assert isinstance(i, Sample)
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