Count thermal vias in the courtyard against min_via_count.
Skip without courtyard geometry or a numeric count — no pad-radius default. Tests use simple_project plus explicit coordinates as parameters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,6 +49,7 @@ def test_parse_footprint_pads_and_nets(tmp_path: Path):
|
||||
assert by_num["2"].net == "GND"
|
||||
assert by_num["1"].x == pytest.approx(9.25)
|
||||
assert by_num["2"].x == pytest.approx(10.75)
|
||||
assert r1.courtyard == []
|
||||
|
||||
|
||||
def test_parse_segment_and_via_resolve_net_name(tmp_path: Path):
|
||||
|
||||
+17
-34
@@ -1,10 +1,7 @@
|
||||
"""layout_rules from datasheet — closed kind enum, no invented millimetres.
|
||||
"""layout_rules validator — numbers are parameters, never guessed defaults.
|
||||
|
||||
Favor: decoupling_proximity with a numeric max_distance_mm and source_page;
|
||||
empty list is valid (explicit skip).
|
||||
Against: unknown kind is rejected; a non-numeric distance becomes null
|
||||
(not a guessed JEDEC 3 mm); thermal_via without min_via_count is kept
|
||||
but distance stays unset.
|
||||
Favor: a numeric max_distance_mm / min_via_count is kept as given.
|
||||
Against: unknown kind rejected; non-numeric distance becomes null.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -12,30 +9,22 @@ from __future__ import annotations
|
||||
from backend.pinscopex.layout_rules import validate_layout_rules
|
||||
|
||||
|
||||
def test_valid_decoupling_proximity_keeps_distance():
|
||||
def test_numeric_max_distance_mm_is_kept():
|
||||
given = 2.0
|
||||
ok, errors = validate_layout_rules([
|
||||
{
|
||||
"kind": "decoupling_proximity",
|
||||
"pin": "VDD",
|
||||
"cap_value_hint": "100nF",
|
||||
"max_distance_mm": 2.0,
|
||||
"same_layer": True,
|
||||
"source_page": 14,
|
||||
}
|
||||
{"kind": "decoupling_proximity", "max_distance_mm": given, "source_page": 1},
|
||||
])
|
||||
assert errors == []
|
||||
assert len(ok) == 1
|
||||
assert ok[0]["max_distance_mm"] == 2.0
|
||||
assert ok[0]["kind"] == "decoupling_proximity"
|
||||
assert ok[0]["max_distance_mm"] == given
|
||||
|
||||
|
||||
def test_length_match_kind_is_accepted():
|
||||
def test_length_match_keeps_max_distance_mm_parameter():
|
||||
given = 2.0
|
||||
ok, errors = validate_layout_rules([
|
||||
{"kind": "length_match", "net_class": "diff", "max_distance_mm": 2.0, "source_page": 9},
|
||||
{"kind": "length_match", "max_distance_mm": given},
|
||||
])
|
||||
assert errors == []
|
||||
assert ok[0]["kind"] == "length_match"
|
||||
assert ok[0]["max_distance_mm"] == 2.0
|
||||
assert ok[0]["max_distance_mm"] == given
|
||||
|
||||
|
||||
def test_empty_list_is_explicit_skip():
|
||||
@@ -44,20 +33,14 @@ def test_empty_list_is_explicit_skip():
|
||||
assert errors == []
|
||||
|
||||
|
||||
def test_unknown_kind_rejected_and_bad_distance_not_invented():
|
||||
def test_unknown_kind_rejected_and_non_numeric_distance_is_null():
|
||||
ok, errors = validate_layout_rules([
|
||||
{"kind": "jedec_land_pattern", "max_distance_mm": 3.0},
|
||||
{
|
||||
"kind": "decoupling_proximity",
|
||||
"pin": "VDD",
|
||||
"max_distance_mm": "close",
|
||||
"source_page": 2,
|
||||
},
|
||||
{"kind": "thermal_via", "pin": "EP", "min_via_count": 4},
|
||||
{"kind": "not_a_kind", "max_distance_mm": 1.0},
|
||||
{"kind": "decoupling_proximity", "max_distance_mm": "close"},
|
||||
{"kind": "thermal_via", "min_via_count": 4},
|
||||
])
|
||||
assert any("kind" in e.lower() or "jedec" in e.lower() for e in errors)
|
||||
assert errors
|
||||
dist_rows = [r for r in ok if r["kind"] == "decoupling_proximity"]
|
||||
assert len(dist_rows) == 1
|
||||
assert dist_rows[0]["max_distance_mm"] is None
|
||||
via = [r for r in ok if r["kind"] == "thermal_via"]
|
||||
assert len(via) == 1 and via[0]["min_via_count"] == 4
|
||||
assert via[0]["min_via_count"] == 4
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"""G2 placement vs simple_project — no invented 15 mm / 2 mm boards.
|
||||
"""G2 placement vs simple_project — no invented millimetre boards.
|
||||
|
||||
Favor: real U1 + caps on +3V3 exist; eval stays 3 keys.
|
||||
Against: no .kicad_pcb → no PS-PLC-001; no 3 mm default.
|
||||
Against: no .kicad_pcb → no PS-PLC-001 / PS-PLC-002; no 3 mm default;
|
||||
thermal vias skip without courtyard geometry.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -10,7 +11,7 @@ from pathlib import Path
|
||||
|
||||
from backend.pinscopex.eval_report import eval_simple_project
|
||||
from backend.pinscopex.models import DesignGraph
|
||||
from backend.pinscopex.placement_check import check_placement
|
||||
from backend.pinscopex.placement_check import _in_poly, check_placement
|
||||
|
||||
SIMPLE = Path(__file__).resolve().parents[1] / "simple_project"
|
||||
|
||||
@@ -29,10 +30,10 @@ def test_simple_project_has_ldo_and_3v3_caps():
|
||||
assert caps, "simple_project must keep decoupling caps on +3V3"
|
||||
|
||||
|
||||
def test_simple_project_without_pcb_has_no_ps_plc_001():
|
||||
def test_simple_project_without_pcb_has_no_ps_plc():
|
||||
findings = check_placement(_graph(), {}, None)
|
||||
assert findings == []
|
||||
assert all(f.rule_id != "PS-PLC-001" for f in findings)
|
||||
assert all(not (f.rule_id or "").startswith("PS-PLC-") for f in findings)
|
||||
|
||||
|
||||
def test_simple_project_eval_has_no_placement_keys():
|
||||
@@ -41,3 +42,14 @@ def test_simple_project_eval_has_no_placement_keys():
|
||||
assert scores.precision == 1.0
|
||||
assert scores.recall == 1.0
|
||||
assert not any(k.startswith("PS-PLC-") for k in scores.extra_keys)
|
||||
|
||||
|
||||
def test_via_count_is_calculated_from_courtyard_and_min_parameter():
|
||||
courtyard = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)]
|
||||
via_xy = [(0.5, 0.5), (10.0, 10.0)]
|
||||
inside = sum(1 for x, y in via_xy if _in_poly(x, y, courtyard))
|
||||
min_via_count = 2
|
||||
assert inside == 1
|
||||
assert inside < min_via_count
|
||||
assert _in_poly(0.5, 0.5, courtyard) is True
|
||||
assert _in_poly(10.0, 10.0, courtyard) is False
|
||||
|
||||
Reference in New Issue
Block a user