Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smoia committed Apr 18, 2023
1 parent 520f78e commit 09a74bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions nigsp/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,7 @@ def export_nifti(data, img, fname):
"Please see install instructions."
)

for e in EXT_NIFTI:
has_ext, fname, ext = check_ext(e, fname, remove=True)
if has_ext:
break
has_ext, fname, ext = check_ext(EXT_NIFTI, fname, remove=True)

if ext is None:
ext = ".nii.gz"
Expand Down Expand Up @@ -452,7 +449,7 @@ def export_txt(data, fname, ext=None):
else:
ext = ext_check
else:
if ext_check is None:
if ext is None:
LGR.warning("Extension not specified. Forcing export in TSV.GZ format.")
ext = ".tsv.gz"

Expand Down
4 changes: 2 additions & 2 deletions nigsp/tests/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def test_export_metrics_nifti(sc_mtx, atlas, sdi, testdir):
scgraph = SCGraph(mtx, ts, atlas=atlas_in, sdi=sdi_in)
blocks.export_metric(scgraph, ".nii.gz", join(testdir, "molly_"))

assert isfile(join(testdir, "molly_sdi.tsv"))
assert isfile(join(testdir, "molly_sdi.tsv.gz"))

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

assert isfile(join(testdir, "molly_sdi.tsv"))
assert isfile(join(testdir, "molly_sdi.tsv.gz"))
shutil.rmtree(testdir)
remove(sc_mtx)
remove(atlas)
Expand Down
6 changes: 3 additions & 3 deletions nigsp/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_check_ext():

assert has_ext is False
assert fname_out == fname
assert ext_out == ""
assert ext_out == None


@mark.parametrize("data", [(rand(3, 4)), (rand(3, 4, 1)), (rand(3, 1, 4))])
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_export_nifti(atlas):
(".1D", ".1D"),
(".csv", ".csv"),
(".tsv", ".tsv"),
("", ".csv"),
("", ".tsv.gz"),
(".mat", ".mat"),
],
)
Expand All @@ -147,7 +147,7 @@ def test_export_mtx(ext_in, ext_out):

if ext_out in [".csv"]:
data_in = genfromtxt(f"serenity{ext_out}", delimiter=",")
if ext_out in [".tsv", ".1D"]:
if ext_out in [".tsv", ".tsv.gz", ".1D"]:
data_in = genfromtxt(f"serenity{ext_out}")

if ext_out in [".mat"]:
Expand Down

0 comments on commit 09a74bd

Please sign in to comment.