Skip to content

Commit 775633d

Browse files
committed
fix tests, use get_traitsfree, etc
1 parent 7b05e48 commit 775633d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

nipype/interfaces/base.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,22 +1163,20 @@ def load_inputs_from_json(self, json_file, overwrite=True):
11631163
with open(json_file) as fhandle:
11641164
inputs_dict = json.load(fhandle)
11651165

1166-
for key, newval in list(inputs_dict.items()):
1167-
if not hasattr(self.inputs, key):
1168-
continue
1169-
val = getattr(self.inputs, key)
1170-
if overwrite or not isdefined(val):
1171-
setattr(self.inputs, key, newval)
1166+
def_inputs = []
1167+
if not overwrite:
1168+
def_inputs = list(self.inputs.get_traitsfree().keys())
1169+
1170+
new_inputs = list(set(list(inputs_dict.keys())) - set(def_inputs))
1171+
for key in new_inputs:
1172+
if hasattr(self.inputs, key):
1173+
setattr(self.inputs, key, inputs_dict[key])
11721174

11731175
def save_inputs_to_json(self, json_file):
11741176
"""
11751177
A convenient way to save current inputs to a JSON file.
11761178
"""
1177-
inputs = self.inputs.get()
1178-
for key, val in list(inputs.items()):
1179-
if not isdefined(val):
1180-
inputs.pop(key, None)
1181-
1179+
inputs = self.inputs.get_traitsfree()
11821180
iflogger.debug('saving inputs {}', inputs)
11831181
with open(json_file, 'w') as fhandle:
11841182
json.dump(inputs, fhandle, indent=4)

0 commit comments

Comments
 (0)