Skip to content

Commit 868d7ae

Browse files
committed
ENH: Catch warning when loaded text file contains no data in test
Catch warning when loaded text file contains no data in test. Fixes: ``` nireports/tests/test_reportlets.py::test_plot_melodic_components /home/runner/work/nireports/nireports/nireports/reportlets/xca.py:128: UserWarning: loadtxt: input contained no data: "/tmp/pytest-of-runner/pytest-0/popen-gw0/test_plot_melodic_components0/noise_none.csv" noise_components = np.loadtxt(noise_components_file, dtype=int, delimiter=",", ndmin=1) ``` raised for example in: https://github.com/nipreps/nireports/actions/runs/12681153218/job/35344304375#step:12:347
1 parent d88ca78 commit 868d7ae

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

nireports/tests/test_reportlets.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"""Test reportlets module."""
2424

2525
import os
26+
import warnings
2627
from functools import partial
2728
from itertools import permutations
2829
from pathlib import Path
@@ -237,14 +238,20 @@ def test_plot_melodic_components(tmp_path, outdir):
237238
out_file=all_noise,
238239
)
239240
# run command with no noise components
240-
plot_melodic_components(
241-
str(melodic_dir),
242-
in_fname,
243-
tr=2.0,
244-
report_mask=report_fname,
245-
noise_components_file=nocomps_file,
246-
out_file=no_noise,
247-
)
241+
with warnings.catch_warnings():
242+
warnings.filterwarnings(
243+
"ignore",
244+
message="loadtxt: input contained no data",
245+
category=UserWarning,
246+
)
247+
plot_melodic_components(
248+
str(melodic_dir),
249+
in_fname,
250+
tr=2.0,
251+
report_mask=report_fname,
252+
noise_components_file=nocomps_file,
253+
out_file=no_noise,
254+
)
248255

249256
# run command without noise components file
250257
plot_melodic_components(

0 commit comments

Comments
 (0)