Skip to content

Commit a9feb80

Browse files
committed
add from_file, add test
1 parent f1725c1 commit a9feb80

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

nipype/interfaces/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,18 @@ class BaseInterface(Interface):
758758
_additional_metadata = []
759759
_redirect_x = False
760760

761-
def __init__(self, **inputs):
761+
def __init__(self, from_file=None, **inputs):
762762
if not self.input_spec:
763763
raise Exception('No input_spec in class: %s' %
764764
self.__class__.__name__)
765765
self.inputs = self.input_spec(**inputs)
766766
self.estimated_memory_gb = 1
767767
self.num_threads = 1
768768

769+
if from_file is not None:
770+
self.load_inputs_from_json(from_file)
771+
772+
769773
@classmethod
770774
def help(cls, returnhelp=False):
771775
""" Prints class help

nipype/interfaces/tests/test_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ def __init__(self, **inputs):
480480
bif2.load_inputs_from_json(tmp_json)
481481
yield assert_equal, inputs_dict, bif2.inputs.get()
482482

483+
bif3 = DerivedInterface(from_file=tmp_json)
484+
yield assert_equal, inputs_dict, bif3.inputs.get()
483485

484486
def assert_not_raises(fn, *args, **kwargs):
485487
fn(*args, **kwargs)

0 commit comments

Comments
 (0)