Skip to content

Commit 9de2e78

Browse files
committed
Fixed casting
1 parent a9163f0 commit 9de2e78

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

nipype/utils/nipype_cmd.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ def run_instance(interface, options):
3333
print "setting function inputs"
3434
for input_name, _ in interface.inputs.items():
3535
if getattr(options, input_name) != None:
36-
str_value = getattr(options, input_name)
37-
casted_value = getattr(interface.inputs, input_name)(str_value)
38-
setattr(interface.inputs, input_name,
39-
casted_value)
36+
value = getattr(options, input_name)
37+
#traits cannot cast from string to float or int
38+
try:
39+
value = float(value)
40+
except:
41+
pass
42+
43+
try:
44+
setattr(interface.inputs, input_name,
45+
value)
46+
except ValueError, e:
47+
print "Error when setting the value of %s: '%s'"%(input_name, str(e))
48+
4049
print interface.inputs
4150
res = interface.run()
4251
print res.outputs

0 commit comments

Comments
 (0)