Skip to content

Commit 47d7ff0

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 47d7ff0

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

nireports/tests/test_reportlets.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,20 @@ def test_plot_melodic_components(tmp_path, outdir):
237237
out_file=all_noise,
238238
)
239239
# 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-
)
240+
with warnings.catch_warnings():
241+
warnings.filterwarnings(
242+
"ignore",
243+
message="loadtxt: input contained no data",
244+
category=UserWarning,
245+
)
246+
plot_melodic_components(
247+
str(melodic_dir),
248+
in_fname,
249+
tr=2.0,
250+
report_mask=report_fname,
251+
noise_components_file=nocomps_file,
252+
out_file=no_noise,
253+
)
248254

249255
# run command without noise components file
250256
plot_melodic_components(

0 commit comments

Comments
 (0)