Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions nipype/interfaces/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def __init__(self, interface, runtime, inputs=None, outputs=None):
def version(self):
return self._version


class BaseTraitedSpec(traits.HasTraits):
"""Provide a few methods necessary to support nipype interface api

Expand Down Expand Up @@ -374,7 +375,6 @@ def _deprecated_warn(self, obj, name, old, new):
self.__class__.__name__.split('InputSpec')[0])
msg2 = ('Will be removed or raise an error as of release %s') % \
trait_spec.deprecated
self.trait_set(trait_change_notify=False, **{'%s' % name: Undefined})
if trait_spec.new_name:
if trait_spec.new_name not in self.copyable_trait_names():
raise TraitError(msg1 + ' Replacement trait %s not found' %
Expand All @@ -387,7 +387,12 @@ def _deprecated_warn(self, obj, name, old, new):
raise TraitError(msg)
else:
warn(msg)

if trait_spec.new_name:
warn('Unsetting %s and setting %s.' % (name,
trait_spec.new_name))
self.trait_set(trait_change_notify=False,
**{'%s' % name: Undefined,
'%s' % trait_spec.new_name: new})

def _hash_infile(self, adict, key):
""" Inject file hashes into adict[key]"""
Expand Down
14 changes: 13 additions & 1 deletion nipype/interfaces/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DeprecationSpec1(nib.TraitedSpec):
set_foo = lambda : setattr(spec_instance, 'foo', 1)
yield assert_raises, nib.TraitError, set_foo
class DeprecationSpec1numeric(nib.TraitedSpec):
foo = nib.traits.Int(deprecated=0.1)
foo = nib.traits.Int(deprecated='0.1')
spec_instance = DeprecationSpec1numeric()
set_foo = lambda : setattr(spec_instance, 'foo', 1)
yield assert_raises, nib.TraitError, set_foo
Expand All @@ -158,6 +158,18 @@ class DeprecationSpec3(nib.TraitedSpec):
except nib.TraitError:
not_raised = False
yield assert_true, not_raised
class DeprecationSpec3(nib.TraitedSpec):
foo = nib.traits.Int(deprecated='1000', new_name='bar')
bar = nib.traits.Int()
spec_instance = DeprecationSpec3()
not_raised = True
try:
spec_instance.foo = 1
except nib.TraitError:
not_raised = False
yield assert_true, not_raised
yield assert_equal, spec_instance.foo, Undefined
yield assert_equal, spec_instance.bar, 1

def checknose():
"""check version of nose for known incompatability"""
Expand Down