Repository navigation
Test suite: shared builders, guard tables, fewer duplicates - #774
Merged
Merged
Conversation
Ten standalone refusals of StatsSpec and collect in tests/test_stats.py
become two parametrised tables, and the cut-off crossing refusal in
tests/test_adiabatic.py becomes a row of the wave certificate's existing
table. Every call, exception class and match string is kept as a row;
the docstrings and comments stay as row comments.
Counts (before -> after):
tests/test_stats.py lines 875->855, tests 84->84, assert 54->54,
assert_* 28->28, raises 17->9, match= 19->11
tests/test_adiabatic.py lines 501->488, tests 34->34, assert 31->31,
assert_* 4->4, raises 12->11, match= 12->11
Every raises/match= drop is a site moved into a table row; all base
match= strings are present.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Nine capillary build/run refusals become BUILD_REFUSALS, placed in the refusals section. Seven prop_gnlse cheap() refusals become one table. The two SimulationSettings save-plane refusals become one table. Five mixture construct() refusals, three of them already parametrised, become CONSTRUCT_REFUSALS. Four compatible_groups refusals become GROUP_REFUSALS. Each row keeps its call, exception class and exact match string, and the comments that explained a guard move to its row. Per module (before -> after); tests, assert and assert_* are unchanged: test_prop_capillary 161 tests, raises 21->13, match= 29->21, lines 4520->4509 test_prop_gnlse 54 tests, raises 13->8, match= 13->8, lines 890->872 test_run 23 tests, raises 7->6, match= 7->6, lines 748->744 test_mixture_interface 35 tests, raises 10->6, match= 10->6, lines 445->441 test_batch 22 tests, raises 7->4, match= 7->4, lines 249->247 Every match= string removed is a literal in a table row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
The vector-field and mismatched-spectrum refusals of passes.raman_polarisation become one parametrised test. Each row keeps its field, spectrum and exact match, with its docstring reason as a comment. 56 tests, 42 asserts, 4 assert_* calls unchanged; raises 5->4, match= 5->4, lines 947->937. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
The one-call refusals of the quadrature rules, the mode collection, the dispersion helpers, the connection's step and the step-index root recovery become rows of one table each. Every row keeps its call, ModeError and exact match string, and the docstrings and comments that said why become comments on the row. Per module (lines, collected tests, assert, assert_*, raises, match=): - test_base.py 346->344, 30->30, 17->17, 9->9, 6->4, 6->4 - test_collection.py 350->340, 35->35, 41->41, 7->7, 8->2, 8->2 - test_modal_connection.py 769->767, 31->31, 33->33, 11->11, 7->6, 8->7 - test_quadrature.py 915->903, 94->94, 69->69, 28->28, 17->12, 19->14 - test_stepindex.py 1180->1177, 93->93, 69->69, 37->37, 25->24, 24->23 Each drop in raises/match= is a site merged into a table row; every base match string is still present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
bandpass's out-of-range bands and widths, _plane_field's two refusals and the style helpers' empty requests become one table each, with every call, exception and exact match string kept. Per module (lines, collected tests, assert, assert_*, raises, match=): - processing/test_axes.py 349->347, 66->66, 41->41, 0->0, 16->15, 15->14 - processing/test_spectra.py 278->276, 51->51, 27->27, 3->3, 11->9, 11->9 - plotting/test_style.py 215->213, 44->44, 31->31, 0->0, 5->3, 5->3 Each drop is a site merged into a table row; every base match string is still present. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
…illary Four modules opened numpy_ref, loaded the launch, hoisted to z = 0 and took the nonlinear stage with unit weights in the same eight lines. That body is now builders.launch_derivative, and the open-run-close wrapper two of them defined identically (stage_derivative) is builders.numpy_ref_launch_derivative. The call is the same code, so what each test measures is unchanged. test_dispersive_kerr.py's own capillary repeated backends/dispersive_cases.py's with one mode; it now calls that one with modes=1 (from_capillary's default). Pinned before the old copy was deleted: the configuration hash of the old and the new builder agree for every call shape the module makes (the four grid cases under three policies, the two mixtures, thg on and off, and the lossless replay's grid/schedule/integrator overrides) - 18 hashes equal. Counts (lines, tests, assert, assert_*, raises, match=), before -> after: backends/test_dispersive_kerr.py 415->378, 17->17, 14->14, 5->5, 3->3, 3->3 backends/test_dispersive_kerr_routes.py 995->981, 44->44, 59->59, 12->12, 6->6, 6->6 backends/test_radial_nonlinear.py 542->537, 64->64, 6->6, 9->9, 2->2, 2->2 optmat_parity.py 421->416, helper, 13->13 asserts builders.py new, 48 lines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Guards that make the same refusing call with different arguments become one parametrised table each, and one standalone guard joins the existing problem_from table. Every site keeps its exception class, call and exact match string as a table row, and the comments move onto their rows. (The old explicit KerrResponse(1.0, thg=True) is the default KerrResponse(1.0).) Collected tests, asserts and assert calls are unchanged per module: - nonlinear/test_plasma.py: lines 709->705, tests 51->51, assert 52->52, raises 14->11, match= 14->11 - nonlinear/test_responses.py: lines 315->303, tests 27->27, assert 17->17, raises 10->3, match= 10->3 - nonlinear/test_gnlse.py: lines 616->613, tests 61->61, assert 88->88, raises 13->12, match= 13->12 - nonlinear/test_envelope_plasma.py: lines 412->406, tests 55->55, assert 22->22, raises 19->16, match= 19->16 - physdata/test_optmat_bridge.py: lines 295->289, tests 29->29, assert 56->56, warns 7->5, match= 10->8 - physdata/test_sellmeier.py: lines 449->444, tests 235->235, assert 36->36, raises 7->4, match= 9->6 - physdata/test_raman_data.py: lines 173->169, tests 26->26, assert 10->10, raises 5->4, match= 4->3 Each dropped raises/warns/match= site is now a table row whose match string is a literal in the same file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Guards that rebuild the same constructor, assemble call or corrupted problem now share one parametrised body; each row keeps its call, exception and exact match. - test_problem.py: twenty validate_run refusals of a corrupted field become SPOILED rows (problem fixture, group, field, spoiled value, match), and nine assemble refusals join the existing bad-request table, with the state and the mode set as overridable entries. The non-contiguity assert is kept in its helper. 1676 -> 1555 lines; tests 99 -> 99; assert 107 -> 107; assert_* 5 -> 5; raises 56 -> 29; match= 54 -> 27. - test_compiled_responses.py: 4 CompiledResponses refusals -> one table (1009 -> 995 lines; tests 81 -> 81; assert 125 -> 125; raises 25 -> 22; match= 25 -> 22) - test_general_route.py: 3 general-route assemble refusals -> one table (1003 -> 987; tests 52 -> 52; assert 113 -> 113; raises 38 -> 36; match= 37 -> 35) - test_linop.py: 4 LinearOperator member refusals (5 cases) -> one table (1393 -> 1378; tests 87 -> 87; assert 140 -> 140; raises 18 -> 15; match= 18 -> 15) Collected tests, assert statements and assert_* calls are unchanged in each module and every base match= string is a row literal; no tolerance, marker or fixture changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
backends/dispersive_route_cases.py repeated dispersive_cases.py's `run` (open a backend, march to the last plane with no statistics, return the field and the run's summary) and `disagreement` (relative L2 difference, asserting a nonzero reference) token for token. The two modules that imported them from the route cases now import the dispersive cases' copy. Counts (lines, tests, assert, assert_*), before -> after: dispersive_route_cases.py 352->318, helper, assert 2->1 test_native_dispersive_routes.py 626->625, 103->103, 36->36, 21->21 test_native_dispersive_pathological.py 170->169, 6->6, 10->10, 3->3 The one assert dropped is `assert scale > 0` of the deleted copy; the same statement in dispersive_cases.disagreement runs on every call that ran it. 109 tests of the two modules pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Five recipe tests ran the script they wrote in the same eight lines: this interpreter, the script's path, captured text, cwd the script's folder, and an assert of a clean exit showing standard error. That is now builders.run_python(path), which asserts the exit status itself. Counts (lines, tests, assert), before -> after: recipe/test_examples.py 356->349, 81->81, 8->7 recipe/test_free_space.py 664->656, 40->40, 70->69 recipe/test_pins.py 424->409, 41->41, 44->42 recipe/test_waveguide.py 267->259, 10->10, 17->16 builders.py 48->68, +1 assert Each assert dropped is the `returncode == 0` check, now the one statement in run_python that every former site executes. 104 tests of the four modules pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Same-file near-duplicates (shingle overlap >= 0.55) merged where the result is shorter and as strong; every case keeps its inputs, bound and assertions. - output/test_checkpoints.py: the read and appended disagreeing-closing- record tests are one test over [read, appended]; a local stopped() writes the save-then-fail-with-checkpoint file six tests built inline. 669->637 lines, tests 45->45, assert 61->61, raises 16->15, match= 16->15 (the two "no matching execution outcome" sites are one site run for both cases). - driver/test_restart_record.py: warned_once_and_reset() holds the "one warning, history reset for <reason>" tail of five tests; its three asserts run for each of them. 420->403, tests 19->19, assert 73->61. - driver/test_plasma_band_propagation.py: the two reference-statistics refusals are one test over (statistic, match). 321->306, tests 13->13, raises 7->6, match= 7->6. - test_pulses.py: the clean time-record arrivals are three rows of the measured-record table (disturbance 0.0, so the record is bitwise the same; bound 5e-10 kept); one assert runs for all seven cases. 1321->1317, tests 161->161, assert 57->56. - driver/test_estimate.py: the low-storage soliton two tests built verbatim is low_storage_soliton(backend). 316->301, tests 13->13. - test_monitor.py: the two split-guard verdicts are one test over the share the split left (1.0, 1e-15). 1671->1667, tests 93->93, raises 19->18, match= 19->18. Collected tests are unchanged per module; every dropped assert or match= site is one shared statement executed for every former case. No test that writes records changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Three export tests prefixed the script they wrote with the same probe (a Simulation.run that prints the configuration hash and exits) and ran it the same way. The probe is builders.HASH_PROBE, and the run is builders.run_python: the same interpreter and script, run in the script's folder, with a clean exit asserted (check=True before). The hash each test compares is unchanged; the probe with its own JSON payload in test_recipe.py stays local. Counts (lines, tests, assert, raises, match=), before -> after: recipe/test_fibres.py 455->422, 28->28, 42->42, 6->6, 6->6 recipe/test_recipe.py 767->749, 67->67, 102->102, 26->26, 23->23 builders.py 68->87 94 tests of the two modules pass (one deselected by the default lane). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Near-duplicate tests whose shared setup was copied now share one helper or one parametrised body; every former case runs the same inputs, asserts and bounds. - test_native_edge_collar.py: the three line-current tests share _line_current (894->871 lines; tests 77->77; assert 82->76, the three scaffold asserts of three copies now one helper's, run for every case) - test_native_planar_statistics.py: the three split-step finish tests share _split_step_finish (245->233; tests 6->6; asserts unchanged; the xfail mark kept) - test_native_far_field.py: the two line parity tests become one test over LINE_APERTURES (859->855; tests 176->176; assert_* 20->19, one assert_matches for both; the partials assert now runs on both lines) - test_numpy_ref_multimode.py: the one-mode test and the convergence ladder become one (n_r, bound) table (716->706; tests 45->43; assert 36->35). The dropped case (one per backend) is the n_r = 24 rung at 1e-10, the same computation the one-mode test holds to 1e-14. Mutation check, Gauss-Kronrod weights in modes/quadrature.py scaled locally: x(1+1e-6) fails both the dropped rung and the kept case; x(1+1e-9) fails only the kept 1e-14 case. Reverted; src unchanged. - test_low_storage.py: the two noise tests share noisy_free_case (1823->1807; tests, asserts unchanged; called with the old lengths, seeds, step counts and responses) - sessions/test_group.py: the two window-failure tests share assert_drained_after_failure (875->870; tests 32->32; assert 149->141, assert calls 1->3: one helper's eleven asserts run for both, in each test's old place) No test that writes records changed. The modules pass (-n 2/4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
Documentation build overview
238 files changed ·
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
jtravs
added a commit
that referenced
this pull request
Nov 12, 2026
Brings in #770, #768 and #774 (main 33172a5). The TDSE changes of this branch move with #768's split of simulation.py: the numpy_ref-only rule of _admit_tdse_execution is gone from driver/settings.py, and driver/tdse_run.py takes the stop flag to the binding, the installed provider's revision for the consistency gate, no provider_pin in the archive context, and auto resolving to native. ADR-077 keeps main's text with ADR-078's amendment note; layers.svg is redrawn with docs/dev/figures/build.py. A docstring line in test_tdse_hacc_installed.py is rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. This is the test-reduction part of the lean-codebase plan (PR-6, "each lane, test reduction"). It adds shared builders in
tests/builders.py, turns guard tests into tables, and parametrises near-duplicate tests. No check is loosened. The saving is about 580 lines, far below the plan's estimate of 9 to 12k, because the measured duplication intests/does not support that estimate. The inventory below explains why.Inventory (main c5c16ed, before any change)
How each column was counted:
pytest --collect-only -m "", every marker.assertstatements,assert*calls,pytest.raisessites andmatch=keywords.Where the lines could come from:
tools/size_report.py's clone finder, run ontests/, finds 13.2 % of tokens in duplicated 50-token windows with names renamed, and 6.1 % as written.test_prop_freetest_prop_radial,test_free_ladderstest_radial_nonlinearand the Luna generator scripts.pytest.raisesaround one call. There are 1223 of them, 8.1k lines (translate 2.0k, driver 1.2k, top level 1.3k, backends 0.66k, nonlinear 0.65k, modes 0.65k).capillary(...)helpers (733 lines) each pick their own defaults.Simulation.from_capillarycalls (1728 lines) are 147 distinct calls.Why the yield is low:
with pytest.raises(...)around one call takes about 5 lines with its blank lines. Once ruff format has run, a table row takes 1 to 6 lines. Tabulating all 70 guards oftest_general_leaves.pymade it 21 lines longer. Tables pay only where many guards repeat a long scaffold, such asassemble(...), a corrupted problem or a hand-built group.prop_radial, free_laddersradial_nonlinear) write convergence or spatial-accuracy records. Each stored row keeps its writer's node id, andtest_every_row_was_written_by_a_test_that_still_existschecks that id, so those tests were left as they are.What changed
Each commit message gives the per-module counts and what every drop maps to.
Builders in
tests/builders.py:launch_derivativeandnumpy_ref_launch_derivative: the numpy_ref launch-derivative code that 4 modules repeated in 8 lines each.run_python: writes nothing itself; it runs a written script as a person would and asserts a clean exit. It replaces the copies in 5 recipe tests.HASH_PROBE: the export hash probe, shared by 3 tests.test_dispersive_kerr's copy now callsbackends/dispersive_cases.capillarywithmodes=1. Before the old copy was deleted, the old and new builders gave equal configuration hashes for all 18 call shapes the module uses. The duplicaterunanddisagreementindispersive_route_cases.pyare gone.Guard tables (every call, exception class and exact
match=string kept as a row):translate/test_problem.py: 20 corrupted-fieldvalidate_runrefusals and 9assemblerefusals.test_compiled_responses,test_general_route,test_linop,test_stats,test_adiabatic.Near-duplicates parametrised or given one shared scaffold:
One spent case deleted: the n_r = 24 rung of the multimode quadrature ladder at 1e-10, one per backend, which is why tests go 19944 → 19942. It ran the same computation that the one-mode test holds to 1e-14. A local mutation shows the kept case is the stronger check:
Loosening audit
test_numpy_ref_multimode(45 → 43, the spent case above).assertdrops each come from one of two changes. In every case the dropped statement is executed for every former case, now from one place:run_python), anddispersive_route_cases' copy ofdisagreement.raises/match=drops: each is a site that became a table row. Every basematch=string is still a literal in its module, or, fortest_checkpoints, one parametrised site run for both cases.tests/bounds.pyis untouched. The diff's tolerance lines are moves only.written_byintests/data/convergence/*.json, and none names a stored regression file.src/is unchanged and there are no pragmas.tests/data/shard_weights.jsonis per module, and no test module was added or removed (builders.pycollects nothing), so it needs no rebalance.Checks run
-n 2/-n 4.Left on purpose
prop_radial noise and resume tests, free_laddersradial_nonlinear parity, numpy_ref_soliton, and the coherent-capillary pinned pairs.test_general_leaves, thecompile_forguards, test_raman, test_pulses, test_boundaries, and the output and recipe guards.slab, moving_guidesplit_block, coupling plane~port.grin_provider,_spatial_output,written,pair_guide,cases.🤖 Generated with Claude Code
https://claude.ai/code/session_01HAYtF5P9QqEd3HQx3WJkA3