Skip to content

Read a stream's organism density from the cached sweep; test the BSM2 evaluation wrapper in the fast tier - #1101

Open
ctdegroot wants to merge 3 commits into
mainfrom
claude/epic-edison-7nfoit
Open

ctdegroot wants to merge 3 commits into
mainfrom
claude/epic-edison-7nfoit

Conversation

@ctdegroot

Copy link
Copy Markdown
Member

Part of #1036: the coverage follow-up to #1093. What remains of #1036 is step 3 (the evaluate study kind) and step 4 (the docs page).

Summary

  • plant.stream takes a stream's indicator-organism density from the cached sweep. Each call used to resolve the whole plant again, outside jit, to ask whether the stream carries an organism density. That is a fixed property of the plant's structure. The one vectorized sweep now collects the density beside the temperature, and _reconstruct_stream_org is gone (plant.py is 31 lines shorter). For a plant whose digester solves its pH in every resolve, this was the bulk of the cost: an evaluate_bsm2 on three held states read 17 streams in 148 s, and now takes 23 s. Almost all of the 23 s is one compile of the sweep.

  • A fast-tier test of the evaluate_bsm2 wrapper. It runs on three held states of a bypass plant, in about 18 s, and checks two things against formulas written out in the test:

    • the OCI is the published BSM2 sum of the components the wrapper returns;
    • the effluent BOD is the flow-weighted mix of the treated overflow (BOD5 = 0.25 of its biodegradable COD) and the bypassed influent (0.65).

    Before this, only the slow suite covered the wrapper.

Things a reviewer should know

  • Needs the full-ci label: the change is in plant/plant.py.
  • The new test is over the 10 s fast-tier guideline. Its docstring gives the reason: it is the only fast test of the wrapper's wiring, and its time is one compile of the BSM2 stream sweep.
  • Two branches of evaluate_bsm2 stay covered by the slow suite alone: an explicitly given effluent_port, and a plant without a bypass. Covering them in the fast tier would add a second BSM2 compile.

Testing

  • The new test was seen to fail with the bypass correction disabled (BOD 67.9 against the expected 164.6).
  • tests/unit: 2886 passed.
  • Integration tests: test_bsm2_evaluation (the fast tests), test_disinfection, test_recycle_cached_map, test_performance and tests/unit/test_mixed_scalars.py all passed. The organism and temperature stream tests are among them.
  • Ruff, scripts/check_types.py and scripts/check_test_integrity.py are clean.
  • Not run: the slow and validation suites.

Patch coverage

100% of 11 changed lines.


Generated by Claude Code

plant.stream resolved the whole plant again, outside jit, on every call
to ask whether the stream carries an indicator-organism density. The
one vectorized sweep now collects that density beside the temperature,
so a sequence of reads costs one reconstruction: a held BSM2
evaluation (17 stream reads, each with the digester's pH solve) drops
from about 150 s to 23 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On three held states of a bypass plant: the OCI is the published sum of
the components the wrapper returns, and the effluent BOD is the
flow-weighted mix of the treated overflow and the bypassed influent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cached sweep holds the streams, their temperatures and their organism
densities since the sweep took over the organism read; the test that
inspects the cache unpacked two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Member Author

The fast gate's only failure on 940cdaa is the full-ci label check: every test shard passed. The change is in plant/plant.py, which is convergence-sensitive, so the gate waits for the owner to apply full-ci (it re-runs when the label is applied).

The earlier shard failure on fdbf041 was this PR's: test_stream_reconstruction_is_cached_on_the_solution unpacked the stream cache as two parts, and the sweep now caches three (streams, temperatures, organism densities). 940cdaa fixes the test.


Generated by Claude Code

@ctdegroot ctdegroot added the full-ci Run the full slow+validation suite on this PR (opt-in pre-merge check) label Dec 4, 2026

This branch has not been deployed

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

Labels

full-ci Run the full slow+validation suite on this PR (opt-in pre-merge check)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants