From 38f8cdf7bebb2028daec16f99dedcfc671cf2d62 Mon Sep 17 00:00:00 2001 From: janik Date: Fri, 17 Jul 2026 13:29:39 +0700 Subject: [PATCH] Regression tests for the pulled fixes (f59ada9) - test_stitching_pad_mid_plane_close: solder-filled THT stitching pad mid-pour, adaptive vs uniform. Fails at 13.8% low on the pre-pinning adaptive path, passes at <0.1% with it. - normalize_decimal / parse_frequency: decimal commas parse, thousands- separator patterns raise instead of silently scaling 1000x. Co-Authored-By: Claude Fable 5 --- tests/test_adaptive.py | 26 ++++++++++++++++++++++++++ tests/test_skin.py | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/test_adaptive.py b/tests/test_adaptive.py index 32806ed..c7f10d6 100644 --- a/tests/test_adaptive.py +++ b/tests/test_adaptive.py @@ -166,6 +166,32 @@ def test_part_currents_and_ac(monkeypatch): assert ada.rs_ratios == ref.rs_ratios +def test_stitching_pad_mid_plane_close(monkeypatch): + """A solder-filled THT stitching pad mid-pour leaves no keep-fine + marker of its own (mouth not cut, thick_scale untouched, no copper + boundary nearby): without the barrel-attachment pinning its links + landed in a coarse equipotential leaf and the local spreading + resistance vanished - R read ~20% low on this exact case.""" + sq = [(0, 0), (40, 0), (40, 40), (0, 40)] + + def prob(): + p = make_multilayer( + [[(sq, [])], [(sq, [])]], + rect1_mm=(0, 15, 2, 25), rect2_mm=(38, 15, 40, 25), + contact1="L0", contact2="L1", + vias_mm=[(20, 20)], gap_mm=1.6, drill_mm=1.0) + v = p.vias[0] + v.kind = "pad" + v.pad_nm = int(1.8 * NM) + v.solder_filled = True + return p + + ref = _run(prob(), 0.15, adaptive=False, monkeypatch=monkeypatch) + ada = _run(prob(), 0.15, adaptive=True, monkeypatch=monkeypatch) + assert ada.n_free < 0.4 * ref.n_free # pour still coarsens + assert ada.R_ohm == pytest.approx(ref.R_ohm, rel=2e-3) + + def test_auto_cell_size_finer_with_adaptive(monkeypatch): """The auto sizer affords a larger fine-cell budget (finer h) when the adaptive grid is on.""" diff --git a/tests/test_skin.py b/tests/test_skin.py index 2b3e643..d25c4b4 100644 --- a/tests/test_skin.py +++ b/tests/test_skin.py @@ -64,6 +64,24 @@ def test_parse_frequency(): skin.parse_frequency("-5k") +def test_normalize_decimal(): + """European decimal commas parse; thousands-separator patterns are + rejected ('1,500' silently becoming 1.5 was a 1000x input error).""" + assert skin.normalize_decimal("1,5") == "1.5" + assert skin.normalize_decimal("0,25") == "0.25" + assert skin.normalize_decimal("1,5000") == "1.5000" # 4 digits: decimal + assert skin.normalize_decimal("2.5") == "2.5" + for bad in ("1,500", "1.500,5", "1,000,000", "12,345"): + with pytest.raises(ValueError, match="separator"): + skin.normalize_decimal(bad) + + +def test_parse_frequency_decimal_comma(): + assert skin.parse_frequency("1,5k") == 1500.0 + with pytest.raises(ValueError): + skin.parse_frequency("1,500") # ambiguous, not 1.5 Hz + + def test_single_layer_ac_scales_exactly(): """Uniform conductance scaling leaves the field shape unchanged: R_AC = R_DC * factor to solver precision."""