forked from gdsfactory/gdsfactory
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gdsfactory#1240 from gdsfactory/633c
make Component.remap_layers safe Former-commit-id: 63d25f6 [formerly 6c322ac] Former-commit-id: a027e38683c91577714be747b1fa73a39f93e1f3
- Loading branch information
Showing
5 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
import gdsfactory as gf | ||
from gdsfactory.add_pins import add_pins_siepic | ||
|
||
|
||
def test_extract(): | ||
c = gf.components.straight( | ||
length=10, | ||
width=0.5, | ||
bbox_layers=[gf.LAYER.WGCLAD], | ||
bbox_offsets=[3], | ||
with_bbox=True, | ||
cladding_layers=None, | ||
add_pins=add_pins_siepic, | ||
add_bbox=None, | ||
) | ||
c2 = c.extract(layers=[gf.LAYER.PORT]) | ||
|
||
assert len(c.polygons) == 2, len(c.polygons) | ||
assert len(c2.polygons) == 0, len(c2.polygons) | ||
|
||
assert len(c.paths) == 2, len(c.paths) | ||
assert len(c2.paths) == 2, len(c2.paths) | ||
assert gf.LAYER.WGCLAD in c.layers | ||
assert gf.LAYER.PORT in c2.layers | ||
return c2 | ||
|
||
|
||
if __name__ == "__main__": | ||
c = test_extract() | ||
c.show() | ||
|
||
c = gf.components.straight( | ||
length=10, | ||
width=0.5, | ||
bbox_layers=[gf.LAYER.WGCLAD], | ||
bbox_offsets=[3], | ||
with_bbox=True, | ||
cladding_layers=None, | ||
add_pins=add_pins_siepic, | ||
add_bbox=None, | ||
) | ||
c2 = c.extract(layers=[gf.LAYER.PORT]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import annotations | ||
|
||
import gdsfactory as gf | ||
from gdsfactory.add_pins import add_pins_siepic | ||
|
||
|
||
def test_remap_layers(): | ||
c = gf.components.straight(length=1, width=0.5, add_pins=add_pins_siepic) | ||
c2 = c.remap_layers({gf.LAYER.WG: gf.LAYER.WGN, gf.LAYER.PORT: gf.LAYER.PORTE}) | ||
|
||
assert len(c.polygons) == 1, len(c.polygons) | ||
assert len(c2.polygons) == 1, len(c2.polygons) | ||
assert len(c.paths) == 2, len(c.paths) | ||
assert len(c2.paths) == 2, len(c2.paths) | ||
assert gf.LAYER.WG in c.layers | ||
assert gf.LAYER.WGN in c2.layers | ||
assert gf.LAYER.PORTE in c2.layers | ||
return c2 | ||
|
||
|
||
if __name__ == "__main__": | ||
c = test_remap_layers() | ||
# c.show() | ||
|
||
c = gf.components.straight(length=1, width=0.5, add_pins=add_pins_siepic) | ||
c2 = c.remap_layers({gf.LAYER.WG: gf.LAYER.WGN, gf.LAYER.PORT: gf.LAYER.PORTE}) | ||
c2.show() |