Skip to content

Commit c841285

Browse files
authored
Merge pull request #11 from nipype/develop
debugged unittests
2 parents 1a76879 + 3281689 commit c841285

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [ubuntu-latest]
19-
python-version: ["3.7", "3.11"]
19+
python-version: ["3.8", "3.11"]
2020
fail-fast: false
2121
runs-on: ${{ matrix.os }}
2222
defaults:

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.venv
1+
.venv*
22
/.project
33
/.pydevproject
44
*.pyc

example-specs/task/ants_n4_bias_field_correction.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ tests:
164164
dimension: '3'
165165
input_image:
166166
bspline_fitting_distance: '300'
167+
save_bias: 'False'
168+
copy_header: 'False'
167169
shrink_factor: '3'
168170
n_iterations: '[50,50,30,20]'
169171
imports: &id001
@@ -186,6 +188,10 @@ tests:
186188
# dict[str, str] - values to provide to inputs fields in the task initialisation
187189
# (if not specified, will try to choose a sensible value)
188190
convergence_threshold: 1e-6
191+
n_iterations: '[50,50,30,20]'
192+
input_image:
193+
save_bias: 'False'
194+
copy_header: 'False'
189195
imports:
190196
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
191197
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -205,6 +211,10 @@ tests:
205211
# dict[str, str] - values to provide to inputs fields in the task initialisation
206212
# (if not specified, will try to choose a sensible value)
207213
bspline_order: '5'
214+
bspline_fitting_distance: 10
215+
save_bias: 'False'
216+
copy_header: 'False'
217+
input_image:
208218
imports:
209219
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
210220
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -225,6 +235,7 @@ tests:
225235
# (if not specified, will try to choose a sensible value)
226236
input_image:
227237
save_bias: 'True'
238+
copy_header: 'False'
228239
dimension: '3'
229240
imports:
230241
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
@@ -247,6 +258,8 @@ tests:
247258
input_image:
248259
dimension: '3'
249260
histogram_sharpening: (0.12, 0.02, 200)
261+
save_bias: 'False'
262+
copy_header: 'False'
250263
imports:
251264
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
252265
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -274,6 +287,8 @@ doctests:
274287
bspline_fitting_distance: '300'
275288
shrink_factor: '3'
276289
n_iterations: '[50,50,30,20]'
290+
save_bias: 'False'
291+
copy_header: 'False'
277292
imports: *id001
278293
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
279294
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -286,6 +301,9 @@ doctests:
286301
# If the field is of file-format type and the value is None, then the
287302
# '.mock()' method of the corresponding class is used instead.
288303
convergence_threshold: 1e-6
304+
n_iterations: '[50,50,30,20]'
305+
save_bias: 'False'
306+
copy_header: 'False'
289307
imports:
290308
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
291309
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -298,6 +316,8 @@ doctests:
298316
# If the field is of file-format type and the value is None, then the
299317
# '.mock()' method of the corresponding class is used instead.
300318
bspline_order: '5'
319+
save_bias: 'False'
320+
copy_header: 'False'
301321
imports:
302322
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
303323
# consisting of 'module', 'name', and optionally 'alias' keys
@@ -311,6 +331,7 @@ doctests:
311331
# '.mock()' method of the corresponding class is used instead.
312332
input_image:
313333
save_bias: 'True'
334+
copy_header: 'False'
314335
dimension: '3'
315336
imports:
316337
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
@@ -324,6 +345,8 @@ doctests:
324345
# If the field is of file-format type and the value is None, then the
325346
# '.mock()' method of the corresponding class is used instead.
326347
input_image:
348+
save_bias: 'False'
349+
copy_header: 'False'
327350
dimension: '3'
328351
histogram_sharpening: (0.12, 0.02, 200)
329352
imports:

nipype2pydra/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
from pathlib import Path
99
from fileformats.core import FileSet
1010

11+
try:
12+
from typing import GenericAlias
13+
except ImportError:
14+
from typing import _GenericAlias as GenericAlias
15+
1116
from importlib import import_module
1217

1318

@@ -70,7 +75,7 @@ def add_to_sys_path(path: Path):
7075
def is_fileset(tp: type):
7176
return (
7277
inspect.isclass(tp)
73-
and type(tp) is not ty.GenericAlias
78+
and type(tp) is not GenericAlias
7479
and issubclass(tp, FileSet)
7580
)
7681

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ test = [
6060
"pytest >=6.2.5",
6161
"pytest-env>=0.6.2",
6262
"pytest-cov>=2.12.1",
63+
"fileformats-medimage-extras",
6364
]
6465
docs = [
6566
"packaging",

tests/test_task.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import yaml
33
from conftest import show_cli_trace
44
import pytest
5-
import shutil
65
import logging
76
from nipype2pydra.cli import task as task_cli
87
from nipype2pydra.utils import add_to_sys_path
@@ -18,7 +17,6 @@
1817
"trait_modified",
1918
"environ",
2019
"output_type",
21-
"crop_list",
2220
]
2321

2422

@@ -48,7 +46,7 @@ def test_task_conversion(task_spec_file, cli_runner, work_dir, gen_test_conftest
4846
pydra_module = import_module(output_module_path)
4947
pydra_task = getattr(pydra_module, task_spec["task_name"])
5048
nipype_interface = getattr(
51-
import_module(task_spec["nipype_module"]), task_spec["task_name"]
49+
import_module(task_spec["nipype_module"]), task_spec["nipype_name"]
5250
)
5351

5452
nipype_trait_names = nipype_interface.input_spec().all_trait_names()

0 commit comments

Comments
 (0)