Skip to content

Commit

Permalink
ENH: Catch warning when loaded text file contains no data in test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jhlegarreta committed Jan 9, 2025
1 parent d88ca78 commit 47d7ff0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions nireports/tests/test_reportlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,20 @@ def test_plot_melodic_components(tmp_path, outdir):
out_file=all_noise,
)
# run command with no noise components
plot_melodic_components(
str(melodic_dir),
in_fname,
tr=2.0,
report_mask=report_fname,
noise_components_file=nocomps_file,
out_file=no_noise,
)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message="loadtxt: input contained no data",
category=UserWarning,
)
plot_melodic_components(
str(melodic_dir),
in_fname,
tr=2.0,
report_mask=report_fname,
noise_components_file=nocomps_file,
out_file=no_noise,
)

# run command without noise components file
plot_melodic_components(
Expand Down

0 comments on commit 47d7ff0

Please sign in to comment.