eradiate_disort.testing

Support components for testing.

Classes:

TestMode()

Runtime mode selector for notebook scripts shared across tutorials, tests, and benchmarks.

class eradiate_disort.testing.TestMode[source]

Bases: object

Runtime mode selector for notebook scripts shared across tutorials, tests, and benchmarks.

The active mode is read from the ERADIATE_TEST_MODE environment 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.

is_benchmark()

Return True when running as a benchmark.

is_test()

Return True when running under the test runner.

is_tutorial()

Return True when 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 get() str[source]

Return the current mode string.

static is_benchmark() bool[source]

Return True when running as a benchmark.

static is_test() bool[source]

Return True when running under the test runner.

static is_tutorial() bool[source]

Return True when running in tutorial (interactive) mode.

static plt()[source]

Return the appropriate pyplot-compatible object for the current mode.

In tutorial mode returns matplotlib.pyplot. When ERADIATE_SAVE_PLOTS is set (by the er_plt pytest fixture) returns a _PlotSaveWrapper that delegates to matplotlib.pyplot but suppresses show() and close() so that the fixture can collect and save open figures at teardown. In all other test/benchmark modes returns a PlotNull no-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).