Skip to content

test: cover the front ends of the explorer - #149

Merged
m-fehr merged 3 commits into
masterfrom
test/explorer-coverage
Oct 15, 2026
Merged

m-fehr merged 3 commits into
masterfrom
test/explorer-coverage

Conversation

@m-fehr

@m-fehr m-fehr commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

The test job installed neither ipywidgets nor matplotlib, so the notebook front end and the plots of the explorer could not be imported in the tests, and the terminal front ends were only partly tested. The CI now installs the notebook extras, and new tests cover all front ends of the explorer.

File before after
notebook.py 0 % 88 %
plots.py 0 % 100 %
fields.py 14 % 95 %
tui.py 51 % 98 %
cli.py 63 % 97 %

Total coverage locally: 67 % → 80 %.

Tests

  • fields: frames compared with Slice.to_global (one mesh, three meshes, cell-centred), a cell-centred slice on a mesh border with two sides, value ranges from the .bnd files and from the frames. Nodes shared by two meshes, where the explorer keeps the first mesh and to_global the upper one, are recorded as a strict xfail.
  • plots: series with one and two units, device activation, slices in all render modes.
  • notebook: loading a case, time bar, render and scale modes, switching slices, a case with nothing to show, the directory browser and its error messages.
  • cli: slices as text, JSON, saving pictures and animations and the errors when that is not possible, handing over to the interactive view, python -m fdsreader.explorer.
  • tui: the curses side (key names, colours, the list picker, drawing, the main loop) on a fake window that plays back keys.

Fixes found on the way

  • The notebook overview was built before the slices were read, so it did not count them (or showed the count of the previous simulation).
  • Saving curves without a slice gave a figure with an empty left panel.
  • save_figure switched matplotlib to Agg for the whole process, which stops plots in a notebook that calls it; it now uses a figure with its own Agg canvas, which is also closed when writing an animation fails.
  • The notebook drew the curves twice when loading a simulation.

The touched explorer test files are formatted with ruff by the pre-commit hook.

🤖 Generated with Claude Code

m-fehr and others added 3 commits October 15, 2026 23:00
The CI installed neither ipywidgets nor matplotlib, so notebook.py and plots.py
could not be imported in the tests and fields.py was barely reached; the test
job now installs the notebook extras.

- fields: planar slices only, frames equal to Slice.to_global (one mesh, three
  meshes, cell-centred), a cell-centred slice on a mesh border with two sides,
  value ranges from the .bnd files and from the frames.
- plots: series with one and two units, device activation, slices in all
  render modes.
- notebook: loading a case, the time bar, render and scale modes, switching
  slices, a case with nothing to show, the directory browser and its errors.

The overview of a loaded simulation is now built after its slices are read, so
it counts them instead of showing the previous simulation's count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- cli: a slice drawn as text, with a curve, out of range and as JSON; saving
  pictures and animations, and the errors when that is not possible; handing
  over to the interactive view; running as python -m fdsreader.explorer; the
  lazy exports of the package.
- tui: key names, clipped writing, colour pairs for 8 and 256 colours, the
  list picker, drawing the screen and the help, and the main loop, on a fake
  window that plays back keys.

save_figure now closes the figure when writing an animation fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tching the backend

- save_figure counted a slice panel even without a slice, so saving curves
  alone gave an empty left panel; it now builds its figures with their own Agg
  canvas instead of switching matplotlib to Agg for the whole process, which
  would stop plots in a notebook that calls it.
- The notebook explorer draws the curves once when loading a simulation.

Tests: the number of panels of saved figures, the backend after saving, a
strict xfail for the mesh-border nodes where the explorer and to_global
differ, a skip for the curses tests where curses is missing, shared helpers
and fixtures for the explorer tests (the touched test files are now formatted
with ruff), and one copy of the case for the CLI tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-fehr
m-fehr merged commit 7f14a27 into master Oct 15, 2026
9 checks passed
@m-fehr
m-fehr deleted the test/explorer-coverage branch October 15, 2026 21:13
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
fdsreader/explorer/notebook.py 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant