[tests] fix some tests

This commit is contained in:
jan 2026-03-08 10:15:09 -07:00
commit d0b48e6bfc
2 changed files with 9 additions and 3 deletions

View file

@ -6,8 +6,7 @@ from masque.builder.tools import AutoTool
from masque.pattern import Pattern from masque.pattern import Pattern
from masque.ports import Port from masque.ports import Port
from masque.library import Library from masque.library import Library
from masque.builder.pather import Pather from masque.builder.pather import Pather, RenderPather
from masque.builder.renderpather import RenderPather
def make_straight(length, width=2, ptype="wire"): def make_straight(length, width=2, ptype="wire"):
pat = Pattern() pat = Pattern()
@ -18,13 +17,17 @@ def make_straight(length, width=2, ptype="wire"):
def make_bend(R, width=2, ptype="wire", clockwise=True): def make_bend(R, width=2, ptype="wire", clockwise=True):
pat = Pattern() pat = Pattern()
# 90 degree arc # 90 degree arc approximation (just two rects for start and end)
if clockwise: if clockwise:
# (0,0) rot 0 to (R, -R) rot pi/2 # (0,0) rot 0 to (R, -R) rot pi/2
pat.rect((1, 0), xmin=0, xmax=R, yctr=0, ly=width)
pat.rect((1, 0), xctr=R, lx=width, ymin=-R, ymax=0)
pat.ports["A"] = Port((0, 0), 0, ptype=ptype) pat.ports["A"] = Port((0, 0), 0, ptype=ptype)
pat.ports["B"] = Port((R, -R), pi/2, ptype=ptype) pat.ports["B"] = Port((R, -R), pi/2, ptype=ptype)
else: else:
# (0,0) rot 0 to (R, R) rot -pi/2 # (0,0) rot 0 to (R, R) rot -pi/2
pat.rect((1, 0), xmin=0, xmax=R, yctr=0, ly=width)
pat.rect((1, 0), xctr=R, lx=width, ymin=0, ymax=R)
pat.ports["A"] = Port((0, 0), 0, ptype=ptype) pat.ports["A"] = Port((0, 0), 0, ptype=ptype)
pat.ports["B"] = Port((R, R), -pi/2, ptype=ptype) pat.ports["B"] = Port((R, R), -pi/2, ptype=ptype)
return pat return pat

View file

@ -10,6 +10,7 @@ from ..error import PatternError
# 1. Text shape tests # 1. Text shape tests
def test_text_to_polygons() -> None: def test_text_to_polygons() -> None:
pytest.importorskip("freetype")
font_path = "/usr/share/fonts/truetype/dejavu/DejaVuMathTeXGyre.ttf" font_path = "/usr/share/fonts/truetype/dejavu/DejaVuMathTeXGyre.ttf"
if not Path(font_path).exists(): if not Path(font_path).exists():
pytest.skip("Font file not found") pytest.skip("Font file not found")
@ -28,6 +29,8 @@ def test_text_to_polygons() -> None:
# 2. Manhattanization tests # 2. Manhattanization tests
def test_manhattanize() -> None: def test_manhattanize() -> None:
pytest.importorskip("float_raster")
pytest.importorskip("skimage.measure")
# Diamond shape # Diamond shape
poly = Polygon([[0, 5], [5, 10], [10, 5], [5, 0]]) poly = Polygon([[0, 5], [5, 10], [10, 5], [5, 0]])
grid = numpy.arange(0, 11, 1) grid = numpy.arange(0, 11, 1)