[test] data_to_ports should accurately preserve ports from a scaled ref

This commit is contained in:
Jan Petykiewicz 2026-03-30 21:19:10 -07:00
commit c2ef3e4217

View file

@ -55,3 +55,22 @@ def test_data_to_ports_hierarchical() -> None:
assert_allclose(parent.ports["A"].offset, [100, 105], atol=1e-10)
assert parent.ports["A"].rotation is not None
assert_allclose(parent.ports["A"].rotation, numpy.pi / 2, atol=1e-10)
def test_data_to_ports_hierarchical_scaled_ref() -> None:
lib = Library()
child = Pattern()
layer = (10, 0)
child.label(layer=layer, string="A:type1 0", offset=(5, 0))
lib["child"] = child
parent = Pattern()
parent.ref("child", offset=(100, 100), rotation=numpy.pi / 2, scale=2)
data_to_ports([layer], lib, parent, max_depth=1)
assert "A" in parent.ports
assert_allclose(parent.ports["A"].offset, [100, 110], atol=1e-10)
assert parent.ports["A"].rotation is not None
assert_allclose(parent.ports["A"].rotation, numpy.pi / 2, atol=1e-10)