Skip to content

The sympy.diff census guards the flux laws too - #832

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/jit-census-scope
Oct 7, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
bugfix/jit-census-scope

Conversation

@lmoresi

@lmoresi lmoresi commented Oct 7, 2026

Copy link
Copy Markdown
Member

A one-line follow-up to #830, from reviewing it after merge.

test_no_solver_differentiates_with_plain_sympy_diff scans petsc_generic_snes_solvers.pyx and systems/*.py. It does not scan constitutive_models.py — which is where its own stated risk gets written. Its docstring:

A site written with sympy.diff would pass every other test here until a law put an Abs or a sign of a field in its flux.

A law is authored in constitutive_models.py. The census did not look there.

Nothing is wrong today. That file has no sympy.diff( or sympy.derive_by_array( call — only three comments mentioning the name without a following paren, which the census already discriminates correctly (it matches on the paren, which is why the seven comment mentions across the tree do not trip it). The gap is prospective: the next flux law is unguarded.

Shown to fail, since a census that cannot fail is not a census:

# appended to constitutive_models.py
_probe = None  # sympy.diff(_probe, _probe)
FAILED tests/test_0023_field_realness_and_derivatives.py::test_no_solver_differentiates_with_plain_sympy_diff

Green again once removed. Note the planted line is itself a comment — it trips the test because it contains sympy.diff( with the paren, which is the right sensitivity for a source census and worth knowing if someone later writes that string in prose.

Underworld development team with AI support from Claude Code

test_no_solver_differentiates_with_plain_sympy_diff (#830) scans
petsc_generic_snes_solvers.pyx and systems/*.py. It does not scan
constitutive_models.py, which is where its own stated risk is authored: the
docstring says a plain sympy.diff site "would pass every other test here until
a law put an Abs or a sign of a field in its flux", and a law is written in
constitutive_models.py, not in the solvers.

Nothing is wrong today -- that file has no sympy.diff( or
sympy.derive_by_array( call, only three comments that mention the name without
a paren, which the census already discriminates correctly. The gap is that
tomorrow's law is unguarded.

Shown to fail: appending a commented-out `sympy.diff(_probe, _probe)` call to
constitutive_models.py turns the test red, and it is green again once removed.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The functional change is correct; the only finding is a non-blocking grammatical issue.

1 open finding
What changed in this PR

Extends the derivative-source census to cover constitutive flux laws.

Changes:

  • Adds constitutive_models.py to the forbidden plain-SymPy derivative scan.
File Description
tests/​test_0023_field_realness_and_derivatives.py Expands source coverage for the derivative census.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

every other test here until a law put an Abs or a sign of a field in its flux."""
src = pathlib.Path(__file__).parents[1] / "src" / "underworld3"
sources = [src / "cython" / "petsc_generic_snes_solvers.pyx",
# The flux laws, which is where this test's own stated risk gets
@lmoresi
lmoresi merged commit 743fbe7 into development Oct 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants