Skip to content

Commit

Permalink
Test minimum-length paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jatoben committed Nov 23, 2024
1 parent 18167ef commit d48ac24
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/flexpath_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

33 changes: 31 additions & 2 deletions tests/library_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
# Boost Software License - Version 1.0. See the accompanying
# LICENSE file or <http://www.boost.org/LICENSE_1_0.txt>

from datetime import datetime
import hashlib
import pathlib
import pytest
from datetime import datetime
from typing import Callable

import numpy
import pytest

import gdstk


Expand Down Expand Up @@ -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(),
)
Binary file added tests/min_length_path.oas
Binary file not shown.

0 comments on commit d48ac24

Please sign in to comment.