[gdsii] make sure iterable is supported
This commit is contained in:
parent
afc49f945d
commit
28be89f047
2 changed files with 10 additions and 0 deletions
|
|
@ -637,6 +637,7 @@ def check_valid_names(
|
||||||
max_length: Max allowed length
|
max_length: Max allowed length
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
names = tuple(names)
|
||||||
allowed_chars = set(string.ascii_letters + string.digits + '_?$')
|
allowed_chars = set(string.ascii_letters + string.digits + '_?$')
|
||||||
|
|
||||||
bad_chars = [
|
bad_chars = [
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import cast
|
from typing import cast
|
||||||
import numpy
|
import numpy
|
||||||
|
import pytest
|
||||||
from numpy.testing import assert_equal, assert_allclose
|
from numpy.testing import assert_equal, assert_allclose
|
||||||
|
|
||||||
|
from ..error import LibraryError
|
||||||
from ..pattern import Pattern
|
from ..pattern import Pattern
|
||||||
from ..library import Library
|
from ..library import Library
|
||||||
from ..file import gdsii
|
from ..file import gdsii
|
||||||
|
|
@ -69,3 +71,10 @@ def test_gdsii_annotations(tmp_path: Path) -> None:
|
||||||
read_ann = read_lib["cell"].shapes[(1, 0)][0].annotations
|
read_ann = read_lib["cell"].shapes[(1, 0)][0].annotations
|
||||||
assert read_ann is not None
|
assert read_ann is not None
|
||||||
assert read_ann["1"] == ["hello"]
|
assert read_ann["1"] == ["hello"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_gdsii_check_valid_names_validates_generator_lengths() -> None:
|
||||||
|
names = (name for name in ("a" * 40,))
|
||||||
|
|
||||||
|
with pytest.raises(LibraryError, match="invalid names"):
|
||||||
|
gdsii.check_valid_names(names)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue