Skip to content

Commit

Permalink
Merge pull request #606 from gdsfactory/kcl-dependency
Browse files Browse the repository at this point in the history
Try to fix dependency
  • Loading branch information
MatthewMckee4 authored Feb 9, 2025
2 parents 53445e1 + 3e4f60b commit 3a7fad2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 51 deletions.
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ def layers() -> Layers:

@pytest.fixture
def kcl() -> kf.KCLayout:
kcl = kf.KCLayout("TEST_LAYERS")
import random
import string

random_name = "".join(random.choices(string.ascii_letters, k=10))
kcl = kf.KCLayout(name=random_name)
kcl.infos = Layers()
return kcl

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def test_lock(straight: kf.KCell, bend90: kf.KCell) -> None:
def test_cell_in_threads(
kcl: kf.KCLayout, layers: Layers, wg_enc: kf.LayerEnclosure
) -> None:
taper_factory = kf.cells.taper.taper_factory(kcl)
taper_factory = kf.factories.taper.taper_factory(kcl)

def taper() -> kf.KCell:
return taper_factory(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cross_section.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import kfactory as kf


def test_icross_section_creation() -> None:
xs = kf.kcl.get_icross_section(
def test_icross_section_creation(kcl: kf.KCLayout) -> None:
xs = kcl.get_icross_section(
kf.cross_section.CrossSectionSpec[int](
name="WG_350",
sections=[(kf.kdb.LayerInfo(2, 0), 500)],
layer=kf.kdb.LayerInfo(1, 0),
width=1000,
)
)
assert xs._base in kf.kcl.cross_sections.cross_sections.values()
assert xs._base in kcl.cross_sections.cross_sections.values()
11 changes: 4 additions & 7 deletions tests/test_instance_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,22 @@ def test_vinstance_ports_contains(kcl: kf.KCLayout, layers: Layers) -> None:

def test_iter(kcl: kf.KCLayout, layers: Layers) -> None:
kcell = kcl.kcell()
_straight_factory = kf.factories.straight.straight_dbu_factory(kcl)
iref = kcell.create_inst(
kf.factories.straight.straight_dbu_factory(kcl)(
width=5000, length=10000, layer=layers.WG
),
_straight_factory(width=5000, length=10000, layer=layers.WG),
trans=kf.kdb.ICplxTrans(mag=2),
)
assert len(list(iref.ports)) == 2
assert all(isinstance(p, kf.Port) for p in iref.ports)

dkcell = kcl.dkcell()
dref = dkcell.create_inst(
kf.factories.straight.straight_dbu_factory(kcl)(
width=5000, length=10000, layer=layers.WG
),
_straight_factory(width=5000, length=10000, layer=layers.WG),
trans=kf.kdb.DCplxTrans(mag=2),
)
assert len(list(dref.ports)) == 2
assert all(isinstance(p, kf.DPort) for p in dref.ports)


if __name__ == "__main__":
pytest.main([__file__])
pytest.main([__file__, "-s"])
10 changes: 4 additions & 6 deletions tests/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ def test_create_port_error(kcl: kf.KCLayout, layers: Layers) -> None:
db_cell = db.create_cell("test")
subc = db.create_category("WidthMismatch")

cell = kf.factories.straight.straight_dbu_factory(kcl)(
length=10000, width=2000, layer=layers.WG
)
cell2 = kf.factories.straight.straight_dbu_factory(kcl)(
length=10000, width=2000, layer=layers.WG
)
straight_factory = kf.factories.straight.straight_dbu_factory(kcl)

cell = straight_factory(length=10000, width=2000, layer=layers.WG)
cell2 = straight_factory(length=10000, width=2000, layer=layers.WG)

kf.port.create_port_error(
cell.ports["o1"],
Expand Down
33 changes: 0 additions & 33 deletions tests/test_ports.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,6 @@ def wg(layers: Layers) -> kf.KCell:
return straight(1000, 20000, layers.WG)


@pytest.fixture()
@kf.cell
def wg_floating_off_grid(layers: Layers) -> kf.KCell:
with pytest.raises(AssertionError):
c = kf.KCell()
dbu = c.kcl.dbu

p1 = kf.Port(
width=c.kcl.to_dbu(10 + dbu / 2),
name="o1",
dcplx_trans=kf.kdb.DCplxTrans(1, 180, False, dbu / 2, 0),
layer=c.kcl.find_layer(layers.WG),
)
p2 = kf.Port(
width=c.kcl.to_dbu(10 + dbu / 2),
name="o2",
dcplx_trans=kf.kdb.DCplxTrans(1, 0, False, 20 + dbu, 0),
layer=c.kcl.find_layer(layers.WG),
)
c.shapes(layers.WG).insert(kf.kdb.DBox(p1.x, -p1.width / 2, p2.x, p1.width / 2))

c.add_port(port=p1)
c.add_port(port=p2)

kf.config.logfilter.regex = None

return c


def test_straight(layers: Layers) -> None:
straight(1000, 20000, layers.WG)


def test_settings(layers: Layers) -> None:
c = straight(1000, 20000, layers.WG)

Expand Down

0 comments on commit 3a7fad2

Please sign in to comment.