Skip to content

Commit 09a74bd

Browse files
committed
Fix tests
1 parent 520f78e commit 09a74bd

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

nigsp/io.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,7 @@ def export_nifti(data, img, fname):
408408
"Please see install instructions."
409409
)
410410

411-
for e in EXT_NIFTI:
412-
has_ext, fname, ext = check_ext(e, fname, remove=True)
413-
if has_ext:
414-
break
411+
has_ext, fname, ext = check_ext(EXT_NIFTI, fname, remove=True)
415412

416413
if ext is None:
417414
ext = ".nii.gz"
@@ -452,7 +449,7 @@ def export_txt(data, fname, ext=None):
452449
else:
453450
ext = ext_check
454451
else:
455-
if ext_check is None:
452+
if ext is None:
456453
LGR.warning("Extension not specified. Forcing export in TSV.GZ format.")
457454
ext = ".tsv.gz"
458455

nigsp/tests/test_blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ def test_export_metrics_nifti(sc_mtx, atlas, sdi, testdir):
7070
scgraph = SCGraph(mtx, ts, atlas=atlas_in, sdi=sdi_in)
7171
blocks.export_metric(scgraph, ".nii.gz", join(testdir, "molly_"))
7272

73-
assert isfile(join(testdir, "molly_sdi.tsv"))
73+
assert isfile(join(testdir, "molly_sdi.tsv.gz"))
7474

7575
sys.modules["nibabel"] = None
7676
scgraph = SCGraph(mtx, ts, atlas=atlas_in, img=img, sdi=sdi_in)
7777
blocks.export_metric(scgraph, ".nii.gz", join(testdir, "molly_"))
7878
sys.modules["nibabel"] = nibabel
7979

80-
assert isfile(join(testdir, "molly_sdi.tsv"))
80+
assert isfile(join(testdir, "molly_sdi.tsv.gz"))
8181
shutil.rmtree(testdir)
8282
remove(sc_mtx)
8383
remove(atlas)

nigsp/tests/test_io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_check_ext():
4848

4949
assert has_ext is False
5050
assert fname_out == fname
51-
assert ext_out == ""
51+
assert ext_out == None
5252

5353

5454
@mark.parametrize("data", [(rand(3, 4)), (rand(3, 4, 1)), (rand(3, 1, 4))])
@@ -135,7 +135,7 @@ def test_export_nifti(atlas):
135135
(".1D", ".1D"),
136136
(".csv", ".csv"),
137137
(".tsv", ".tsv"),
138-
("", ".csv"),
138+
("", ".tsv.gz"),
139139
(".mat", ".mat"),
140140
],
141141
)
@@ -147,7 +147,7 @@ def test_export_mtx(ext_in, ext_out):
147147

148148
if ext_out in [".csv"]:
149149
data_in = genfromtxt(f"serenity{ext_out}", delimiter=",")
150-
if ext_out in [".tsv", ".1D"]:
150+
if ext_out in [".tsv", ".tsv.gz", ".1D"]:
151151
data_in = genfromtxt(f"serenity{ext_out}")
152152

153153
if ext_out in [".mat"]:

0 commit comments

Comments
 (0)