diff --git a/tests/flexpath_test.py b/tests/flexpath_test.py index f598d5ab..08686f35 100644 --- a/tests/flexpath_test.py +++ b/tests/flexpath_test.py @@ -166,3 +166,12 @@ def test_raith_data(): assert path.raith_data.periods == 5 assert path.raith_data.grating_type == 6 assert path.raith_data.dots_per_cycle == 7 + + +def test_min_length(): + lib = gdstk.Library("test") + tol = lib.precision / lib.unit + + path = gdstk.FlexPath(((0, 0), (tol, 0)), width=0.01, tolerance=tol) + assert path.to_polygons() + diff --git a/tests/library_test.py b/tests/library_test.py index 2a2ced86..ba580dca 100644 --- a/tests/library_test.py +++ b/tests/library_test.py @@ -5,11 +5,14 @@ # Boost Software License - Version 1.0. See the accompanying # LICENSE file or -from datetime import datetime import hashlib import pathlib -import pytest +from datetime import datetime +from typing import Callable + import numpy +import pytest + import gdstk @@ -532,3 +535,29 @@ def test_roundtrip_path_ends(tmpdir: pathlib.Path): assert ( path.ends == gds_path.ends and path.ends == oas_path.ends ), f"expected: {path.ends}, gds: {gds_path.ends}, oas: {oas_path.ends}" + + +@pytest.mark.parametrize( + "write_f, read_f", + ( + (gdstk.Library.write_oas, gdstk.read_oas), + (gdstk.Library.write_gds, gdstk.read_gds), + ), +) +def test_write_min_length_path( + write_f: Callable[[gdstk.Library, str | pathlib.Path], None], + read_f: Callable[[str | pathlib.Path], gdstk.Library], + tmp_path: pathlib.Path +): + source = gdstk.read_oas(pathlib.Path(__file__).parent / "min_length_path.oas") + assert source.cells[0].paths + + rw_path = tmp_path / "out" + write_f(source, rw_path) + rw = read_f(rw_path) + assert rw.cells[0].paths + + assert numpy.array_equal( + source.cells[0].paths[0].spine(), + rw.cells[0].paths[0].spine(), + ) diff --git a/tests/min_length_path.oas b/tests/min_length_path.oas new file mode 100644 index 00000000..4be94d3b Binary files /dev/null and b/tests/min_length_path.oas differ