Repository navigation
Conversation
calibrate(..., laplace=LaplaceConfig(dtmax=...)) rebuilt the reactor from (model, conditions, settings), which fails for a BiofilmReactor whose geometry is required. It now takes a with_dtmax copy, which shares with_adjoint's clone helper and keeps the geometry and any swapped adjoint. The typing fixes: ASTNode declares its dataclass shape without making it a dataclass; RateFunction declares FUNCTION_NAME; the kernel table walks RateFunction's subclasses; Protocols replace the kpis() and DIMENSION probes; one rhs and one recycle G instead of two redeclared closures; annotations for build_bsm2, the dispersion and a cfd cache; reasoned ignores for the diffrax atol and scipy jac stub mismatches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_settings_of takes a class; unit_ports asserts the built object is a Unit before reading its ports; the IFAS unit passes n_locations=1 explicitly instead of letting a condition dict fill it; the YAML 1.2 bool constructor is a typed function. pyright now reports no errors over aquakin, and the check_types ratchet records none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ctdegroot
added this pull request to the merge queue
Dec 4, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
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.
Finishes the pyright reduction:
pyright aquakinreports no errors, and thescripts/check_types.pyratchet now records none, so any new error fails it.Summary
A bug found on the way, fixed here.
calibrate(reactor, ..., laplace=LaplaceConfig(dtmax=...))failed with aTypeErrorfor aBiofilmReactor. The tighter-capped reactor for the Laplace Hessian was rebuilt astype(reactor)(model, conditions, settings=...), which drops a biofilm reactor's required geometry (n_layers,thickness, ...). Pyright flagged that call becauseConditionedReactoris a Protocol with no constructor. The fix is a newwith_dtmax(reactor, dtmax)besidewith_adjointinintegrate/_config.py. Both share one_clone_reactorhelper: a shallow copy with the attributes set and empty compile caches. The copy also keeps an adjoint thatcalibrateswapped in after construction. For a batch reactor, the only one this path worked for before, the copy carries the same settings and adjoint as the rebuild did.The typing fixes, by pattern:
core/nodes.py,parser.py,registry.py,vector_kernel.py):ASTNodedeclares__dataclass_fields__/__dataclass_params__as annotations with no value. Pyright now sees the dataclass shape every concrete node has, whileis_dataclassstays false on an undecorated subclass, whichregister_rate_functionstill refuses.RateFunctiondeclaresFUNCTION_NAMEthe same way.RateFunction.__subclasses__(): every operator node is one, and the four leaves have noKIND. The table is identical tomain's.scenarios._kpis_ofnow checks a_KpiReportProtocol.DIMENSIONthrough a_DeclaresDimensionProtocol.make_chemistry_rhsdefines onerhsthat appliesrate_scalewhen given.Gthat branches onresolve_T.build_bsm2(asm1_model, adm1_model)takeCompiledModel | Noneandtemperature_modeltakesTemperatureModel | None, as their docstrings already said._dispersionisArrayLike, and a cfd cache is typedCallable.np.all(..., axis=1)replaces.all(axis=1), which the stubs type as a scalar.dict(stoich).assertdocuments that exactly one dispersion argument is given.# pyright: ignore[reportArgumentType]with the reason on the line.VeryChord(atol=)asfloat, but its check broadcasts a per-species array.least_squares(jac=)._settings_oftakes atype.unit_portsasserts the built object is aUnitbefore it reads the ports; an influent has already returned by then.n_locations=1(the default) explicitly, so the conditions dict cannot fill it.located()setspositionon any language's exception class throughvars(exc), since most of those classes declare no such attribute.Things a reviewer should know
with_dtmaxis exported fromintegrate/_common.py, and the pinned export list intests/unit/test_common_exports.pygains it.ConditionedReactoran__init__. The reactors' constructors differ (a PFR takesn_points,lengthandvelocity), so a Protocol constructor would be untrue.vars(exc)["position"]write avoidssetattrwith a constant, which ruff'sB010refuses. The other typed option was a sharedLocatedErrorbase class for every expression language. That changes those exceptions' class hierarchy, andtokenize's defaultValueErrorwould need replacing, so I left it.full-ci: the change touchesintegrate/_solver.py,plant/recycle.pyand the calibration modules.Testing
test_laplace_dtmax_keeps_a_biofilm_reactors_geometry(fast tier, about 10 s). Onmain'sproblem.pyit fails withTypeError: BiofilmReactor.__init__() missing 5 required keyword-only arguments; with the fix it passes.test_with_dtmax_keeps_what_the_reactor_was_built_withchecks four things:main(PYTHONPATHset to this checkout, both runs confirmed to import it):recycle_tolset, with and without a temperature-carrying influent (the twoGbranches);rate_scale;main: 5,835 passed, 1 skipped, 0 failed. I ran it in ten chunks with--cov-append, because a run in the background was lost to two container restarts.ruff check,ruff format --checkandscripts/check_types.pyare clean, andpyright aquakinreports 0 errors.sphinx-build -W --keep-going, offline): clean.slowandvalidationsuites (full-ciruns them).Patch coverage
python scripts/patch_coverage.py: 100.00% of 52 changed lines.Rule proposals
_ReactorForwardModel.with_dtmaxrebuilt a reactor from(model, conditions, settings). That fails for any reactor whose constructor takes more, and it silently resets anything set after construction..claude/rules/integration.md(it loads foraquakin/integrate/**, where the rebuild was written): "Make a variant of an existing reactor (another adjoint, another step cap) withwith_adjoint/with_dtmax, a copy. Do not rebuild it from(model, conditions, settings): the reactor constructors take different arguments, and a rebuild drops what was set after construction."Generated by Claude Code