From 8e7c876099b8df7abb12777f0b18890693804d82 Mon Sep 17 00:00:00 2001 From: lmoresi Date: Thu, 30 Jul 2026 19:19:23 +1000 Subject: [PATCH] test(rotated-bc): assert the datum contract #458 actually shipped (#470) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two tests in test_0641 asserted that a non-zero rotated free-slip datum raises NotImplementedError. #458 implemented the prescribed wall-normal datum through the nonlinear SNES path, so it is now accepted — and those two tests have been red on development ever since that merge. Replaced with the contract that actually holds, read off the live behaviour rather than the docstring: conds = 1.0 -> _rotated_freeslip_datum["Top"] == 1.0 conds = Symbol("a") -> kept (is_zero is True only for a PROVABLE zero, so a field read or an expression must carry through) conds = 0.0 -> NO datum recorded (pure free-slip; a redundant datum would otherwise ride through every free-slip Newton loop) conds = Matrix([[0,1]]) -> still TypeError (the datum is the SCALAR wall-normal component, so a vector value is a real mistake) The last two are new: the zero case pins the other side of the same guard, and the vector case records what IS still refused, so "the datum is accepted now" cannot be over-read into "anything is accepted". `level_1 and tier_a`: 530 passed, 0 failed — development is green again. Underworld development team with AI support from Claude Code --- tests/test_0641_wave_c_api_shims.py | 36 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tests/test_0641_wave_c_api_shims.py b/tests/test_0641_wave_c_api_shims.py index 5ceb68ef2..b143ef893 100644 --- a/tests/test_0641_wave_c_api_shims.py +++ b/tests/test_0641_wave_c_api_shims.py @@ -152,14 +152,38 @@ def test_zero_datum_accepted_in_any_numeric_form(self, mesh, stokes): stokes.add_rotated_freeslip_bc(zero, "Top") assert stokes._rotated_freeslip_bcs[-1] == ("Top", None) - def test_nonzero_datum_not_implemented(self, mesh, stokes): - with pytest.raises(NotImplementedError): + def test_nonzero_datum_is_recorded(self, mesh, stokes): + # #458 implemented the prescribed wall-normal datum through the nonlinear + # SNES path, so a non-zero value is now ACCEPTED rather than refused. These + # two tests asserted the old NotImplementedError and were left red on + # development by that merge (#470). + with _no_deprecation(): stokes.add_rotated_freeslip_bc(1.0, "Top") + assert stokes._rotated_freeslip_datum["Top"] == 1.0 + assert stokes._rotated_freeslip_bcs[-1] == ("Top", None) - def test_symbolic_possibly_nonzero_datum_not_implemented(self, mesh, stokes): - # An expression sympy cannot prove zero must be rejected, not let through. - with pytest.raises(NotImplementedError): - stokes.add_rotated_freeslip_bc(sympy.Symbol("a"), "Top") + def test_symbolic_possibly_nonzero_datum_is_recorded(self, mesh, stokes): + # An expression sympy cannot PROVE zero must be kept as a datum, not + # silently folded into pure free-slip: `is_zero` is True only for a provable + # zero, so a field read or an expression is carried through. + a = sympy.Symbol("a") + with _no_deprecation(): + stokes.add_rotated_freeslip_bc(a, "Top") + assert stokes._rotated_freeslip_datum["Top"] == a + + def test_zero_datum_records_no_datum(self, mesh, stokes): + # The other side of the same guard: a provable zero is pure free-slip and + # must leave NO datum behind, or every free-slip solve would carry a + # redundant constraint through the Newton loop. + with _no_deprecation(): + stokes.add_rotated_freeslip_bc(0.0, "Top") + assert "Top" not in stokes._rotated_freeslip_datum + + def test_vector_datum_still_rejected(self, mesh, stokes): + # What IS still refused: the datum is the SCALAR wall-normal component, so a + # vector value is a genuine mistake and must not be silently reinterpreted. + with pytest.raises(TypeError): + stokes.add_rotated_freeslip_bc(sympy.Matrix([[0.0, 1.0]]), "Top") class TestConstraintBCValueFirst: