Skip to content

Commit 3bbaaf9

Browse files
committed
Replace deprecated HasTraits.set with trait_set
1 parent acb37ce commit 3bbaaf9

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

nipype/caching/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __call__(self, **kwargs):
7070
kwargs = modify_paths(kwargs, relative=False)
7171
interface = self.interface()
7272
# Set the inputs early to get some argument checking
73-
interface.inputs.set(**kwargs)
73+
interface.inputs.trait_set(**kwargs)
7474
# Make a name for our node
7575
inputs = interface.inputs.get_hashval()
7676
hasher = hashlib.new('md5')

nipype/interfaces/afni/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def aggregate_outputs(self, runtime=None, needed_outputs=None):
171171
m = re.search(pattern, line)
172172
if m:
173173
d = m.groupdict()
174-
for k in list(d.keys()):
175-
d[k] = int(d[k])
176-
outputs.set(**d)
174+
outputs.trait_set(**{k, int(d[k]) for k in d.keys()})
177175
return outputs
178176

179177

nipype/interfaces/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def __init__(self, **kwargs):
367367
undefined_traits[trait] = Undefined
368368
self.trait_set(trait_change_notify=False, **undefined_traits)
369369
self._generate_handlers()
370-
self.set(**kwargs)
370+
self.trait_set(**kwargs)
371371

372372
def items(self):
373373
""" Name, trait generator for user modifiable traits
@@ -650,7 +650,7 @@ def __deepcopy__(self, memo):
650650
pass
651651
# clone twice
652652
dup = self.clone_traits(memo=memo)
653-
dup.set(**dup_dict)
653+
dup.trait_set(**dup_dict)
654654
return dup
655655

656656

@@ -1060,7 +1060,7 @@ def run(self, **inputs):
10601060
results : an InterfaceResult object containing a copy of the instance
10611061
that was executed, provenance information and, if successful, results
10621062
"""
1063-
self.inputs.set(**inputs)
1063+
self.inputs.trait_set(**inputs)
10641064
self._check_mandatory_inputs()
10651065
self._check_version_requirements(self.inputs)
10661066
interface = self.__class__

nipype/interfaces/utility/base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, fields=None, mandatory_inputs=True, **inputs):
7272
# Adding any traits wipes out all input values set in superclass initialization,
7373
# even it the trait is not in the add_traits argument. The work-around is to reset
7474
# the values after adding the traits.
75-
self.inputs.set(**inputs)
75+
self.inputs.trait_set(**inputs)
7676

7777
def _add_output_traits(self, base):
7878
return add_traits(base, self._fields)
@@ -319,7 +319,7 @@ class Split(IOBase):
319319
320320
>>> from nipype.interfaces.utility import Split
321321
>>> sp = Split()
322-
>>> _ = sp.inputs.set(inlist=[1, 2, 3], splits=[2, 1])
322+
>>> _ = sp.inputs.trait_set(inlist=[1, 2, 3], splits=[2, 1])
323323
>>> out = sp.run()
324324
>>> out.outputs.out1
325325
[1, 2]
@@ -373,12 +373,12 @@ class Select(IOBase):
373373
374374
>>> from nipype.interfaces.utility import Select
375375
>>> sl = Select()
376-
>>> _ = sl.inputs.set(inlist=[1, 2, 3, 4, 5], index=[3])
376+
>>> _ = sl.inputs.trait_set(inlist=[1, 2, 3, 4, 5], index=[3])
377377
>>> out = sl.run()
378378
>>> out.outputs.out
379379
4
380380
381-
>>> _ = sl.inputs.set(inlist=[1, 2, 3, 4, 5], index=[3, 4])
381+
>>> _ = sl.inputs.trait_set(inlist=[1, 2, 3, 4, 5], index=[3, 4])
382382
>>> out = sl.run()
383383
>>> out.outputs.out
384384
[4, 5]

nipype/pipeline/engine/nodes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,14 @@ def _save_results(self, result, cwd):
489489
outputs = result.outputs.get()
490490
except TypeError:
491491
outputs = result.outputs.dictcopy() # outputs was a bunch
492-
result.outputs.set(**modify_paths(outputs, relative=True,
493-
basedir=cwd))
492+
result.outputs.trait_set(**modify_paths(outputs, relative=True,
493+
basedir=cwd))
494494

495495
savepkl(resultsfile, result)
496496
logger.debug('saved results in %s', resultsfile)
497497

498498
if result.outputs:
499-
result.outputs.set(**outputs)
499+
result.outputs.trait_set(**outputs)
500500

501501
def _load_resultfile(self, cwd):
502502
"""Load results if it exists in cwd
@@ -543,9 +543,9 @@ def _load_resultfile(self, cwd):
543543
except TypeError:
544544
outputs = result.outputs.dictcopy() # outputs == Bunch
545545
try:
546-
result.outputs.set(**modify_paths(outputs,
547-
relative=False,
548-
basedir=cwd))
546+
result.outputs.trait_set(**modify_paths(outputs,
547+
relative=False,
548+
basedir=cwd))
549549
except FileNotFoundError:
550550
logger.debug('conversion to full path results in '
551551
'non existent file')
@@ -561,7 +561,7 @@ def _load_results(self, cwd):
561561
logger.debug('aggregating results')
562562
if attribute_error:
563563
old_inputs = loadpkl(op.join(cwd, '_inputs.pklz'))
564-
self.inputs.set(**old_inputs)
564+
self.inputs.trait_set(**old_inputs)
565565
if not isinstance(self, MapNode):
566566
self._copyfiles_to_wd(cwd, True, linksonly=True)
567567
aggouts = self._interface.aggregate_outputs(
@@ -1121,7 +1121,7 @@ def _make_nodes(self, cwd=None):
11211121
base_dir=op.join(cwd, 'mapflow'),
11221122
name=nodename)
11231123
node.plugin_args = self.plugin_args
1124-
node._interface.inputs.set(
1124+
node._interface.inputs.trait_set(
11251125
**deepcopy(self._interface.inputs.get()))
11261126
for field in self.iterfield:
11271127
if self.nested:
@@ -1246,7 +1246,7 @@ def _get_inputs(self):
12461246
old_inputs = self._inputs.get()
12471247
self._inputs = self._create_dynamic_traits(self._interface.inputs,
12481248
fields=self.iterfield)
1249-
self._inputs.set(**old_inputs)
1249+
self._inputs.trait_set(**old_inputs)
12501250
super(MapNode, self)._get_inputs()
12511251

12521252
def _check_iterfield(self):

0 commit comments

Comments
 (0)