eradiate_disort.testing¶
Support components for testing.
Classes:
|
Runtime mode selector for notebook scripts shared across tutorials, tests, and benchmarks. |
- class eradiate_disort.testing.TestMode[source]¶
Bases:
objectRuntime mode selector for notebook scripts shared across tutorials, tests, and benchmarks.
The active mode is read from the
ERADIATE_TEST_MODEenvironment variable. When the variable is absent (e.g. in an interactive JupyterLab session), the mode defaults to"tutorial".Modes:
"tutorial"Low sample counts, interactive plotting. Default in Jupyter.
"test"Full sample counts, no interactive plots. Set by the test runner.
"benchmark"Sample counts optimised for timing stability. Set by the bench task.
Examples
Typical usage in a notebook setup cell:
from eradiate_disort.testing import TestMode SPP = TestMode.spp(tutorial=256, test=4_096)
Methods:
get()Return the current mode string.
Return
Truewhen running as a benchmark.is_test()Return
Truewhen running under the test runner.Return
Truewhen running in tutorial (interactive) mode.plt()Return the appropriate pyplot-compatible object for the current mode.
spp(*[, tutorial, test, benchmark])Return the samples-per-pixel count appropriate for the current mode.
- static plt()[source]¶
Return the appropriate pyplot-compatible object for the current mode.
In tutorial mode returns
matplotlib.pyplot. WhenERADIATE_SAVE_PLOTSis set (by theer_pltpytest fixture) returns a_PlotSaveWrapperthat delegates tomatplotlib.pyplotbut suppressesshow()andclose()so that the fixture can collect and save open figures at teardown. In all other test/benchmark modes returns aPlotNullno-op.
- static spp(*, tutorial: int = 256, test: int = 4096, benchmark: int = 4096) int[source]¶
Return the samples-per-pixel count appropriate for the current mode.
- Parameters:
tutorial – SPP for interactive tutorial runs (default: 256).
test – SPP for automated test runs (default: 4 096).
benchmark – SPP for benchmark runs (default: 4 096).