Commit 70c5c4c2 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Merge branch 'fix-parent' into 'master'

Fix parent's delayed_attributes modified by child

See merge request !68
parents bce3b1d0 39779c2f
Pipeline #52292 passed with stages
in 17 minutes and 7 seconds
......@@ -120,7 +120,8 @@ class DelayedSample(_ReprMixin):
def __init__(self, load, parent=None, delayed_attributes=None, **kwargs):
self.__running_init__ = True
# Merge parent's and param's delayed_attributes
self._delayed_attributes = getattr(parent, "_delayed_attributes", None)
parent_attr = getattr(parent, "_delayed_attributes", None)
self._delayed_attributes = None if parent_attr is None else parent_attr.copy()
if self._delayed_attributes is not None and delayed_attributes is not None:
self._delayed_attributes.update(delayed_attributes)
elif self._delayed_attributes is None:
......
......@@ -139,6 +139,8 @@ def test_delayed_samples():
child_sample = DelayedSample(
load_data, parent=delayed_sample, delayed_attributes=new_delayed_attr
)
assert delayed_sample._delayed_attributes == dict(annot=load_annot)
assert child_sample.data == 0, child_sample.data
assert child_sample.annot == "annotation_variant", child_sample.annot
assert child_sample.new_annot == "annotation", child_sample.new_annot
......
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