Skip to content

Commit e3c3a1e

Browse files
committed
reverted traits change
1 parent 039cb6b commit e3c3a1e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

nipype/interfaces/base.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,6 @@ def _get_sorteddict(self, object, dictwithhash=False, hash_method=None, hash_fil
499499
out = object
500500
return out
501501

502-
def __getstate__(self):
503-
state = super(BaseTraitedSpec, self).__getstate__()
504-
inst_traits = self._instance_traits()
505-
state['__instance_traits__'] = inst_traits
506-
return state
507-
508-
def __setstate__(self, state):
509-
inst_traits = state.pop('__instance_traits__', {})
510-
for attr, trait in inst_traits.iteritems():
511-
self.add_trait(attr, trait)
512-
super(BaseTraitedSpec, self).__setstate__(state)
513502

514503
class DynamicTraitedSpec(BaseTraitedSpec):
515504
""" A subclass to handle dynamic traits
@@ -524,9 +513,20 @@ def __deepcopy__(self, memo):
524513
id_self = id(self)
525514
if id_self in memo:
526515
return memo[id_self]
527-
dup_dict = deepcopy(self.__getstate__(), memo)
516+
dup_dict = deepcopy(self.get(), memo)
517+
# access all keys
518+
for key in self.copyable_trait_names():
519+
_ = getattr(self, key)
520+
# clone once
528521
dup = self.clone_traits(memo=memo)
529-
dup.__setstate__(dup_dict)
522+
for key in self.copyable_trait_names():
523+
try:
524+
_ = getattr(dup, key)
525+
except:
526+
pass
527+
# clone twice
528+
dup = self.clone_traits(memo=memo)
529+
dup.set(**dup_dict)
530530
return dup
531531

532532

0 commit comments

Comments
 (0)