Skip to content

Commit 0430c85

Browse files
committed
RF+ENH(TST): use %s instead of %f when rendering cmdline float point args
This way makes it easier to test cmdline formation so we have 4.9 and not 4.90000
1 parent fe6a12e commit 0430c85

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,24 @@ class LaplacianThicknessInputSpec(ANTSCommandInputSpec):
208208
keep_extension=True,
209209
hash_files=False)
210210
smooth_param = traits.Float(
211-
argstr='%f',
211+
argstr='%s',
212212
desc='Sigma of the Laplacian Recursive Image Filter (defaults to 1)',
213213
position=4)
214214
prior_thickness = traits.Float(
215-
argstr='%f',
215+
argstr='%s',
216216
desc='Prior thickness (defaults to 500)',
217217
position=5)
218218
dT = traits.Float(
219-
argstr='%f',
219+
argstr='%s',
220220
desc='Time delta used during integration (defaults to 0.01)',
221221
position=6)
222222
sulcus_prior = traits.Float(
223-
argstr='%f',
223+
argstr='%s',
224224
desc='Positive floating point number for sulcus prior. '
225225
'Authors said that 0.15 might be a reasonable value',
226226
position=7)
227227
tolerance = traits.Float(
228-
argstr='%f',
228+
argstr='%s',
229229
desc='Tolerance to reach during optimization (defaults to 0.001)',
230230
position=8)
231231

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
4+
from ..segmentation import LaplacianThickness
5+
from .test_resampling import change_dir
6+
7+
import os
8+
import pytest
9+
10+
11+
@pytest.fixture()
12+
def change_dir(request):
13+
orig_dir = os.getcwd()
14+
filepath = os.path.dirname(os.path.realpath(__file__))
15+
datadir = os.path.realpath(os.path.join(filepath, '../../../testing/data'))
16+
os.chdir(datadir)
17+
18+
def move2orig():
19+
os.chdir(orig_dir)
20+
21+
request.addfinalizer(move2orig)
22+
23+
24+
@pytest.fixture()
25+
def create_lt():
26+
lt = LaplacianThickness()
27+
# we do not run, so I stick some not really proper files as input
28+
lt.inputs.input_gm = 'diffusion_weighted.nii'
29+
lt.inputs.input_wm = 'functional.nii'
30+
return lt
31+
32+
33+
def test_LaplacianThickness_defaults(change_dir, create_lt):
34+
lt = create_lt
35+
base_cmd = 'LaplacianThickness functional.nii diffusion_weighted.nii functional_thickness.nii'
36+
assert lt.cmdline == base_cmd
37+
lt.inputs.smooth_param = 4.5
38+
assert lt.cmdline == base_cmd + " 4.5"
39+
lt.inputs.prior_thickness = 5.9
40+
assert lt.cmdline == base_cmd + " 4.5 5.9"

0 commit comments

Comments
 (0)