Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add post process to more pcells #2524

Merged
merged 3 commits into from Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion gdsfactory/components/coupler.py
Expand Up @@ -8,7 +8,7 @@
from gdsfactory.components.coupler_symmetric import (
coupler_symmetric as coupler_symmetric_function,
)
from gdsfactory.typings import ComponentFactory, CrossSectionSpec
from gdsfactory.typings import Callable, ComponentFactory, CrossSectionSpec


@gf.cell
Expand All @@ -20,6 +20,7 @@
dy: float = 4.0,
dx: float = 10.0,
cross_section: CrossSectionSpec = "xs_sc",
post_process: Callable | None = None,
) -> Component:
r"""Symmetric coupler.

Expand All @@ -31,6 +32,7 @@
dy: port to port vertical spacing in um.
dx: length of bend in x direction in um.
cross_section: spec (CrossSection, string or dict).
post_process: function to call after the component is created.

.. code::

Expand Down Expand Up @@ -78,6 +80,8 @@
x = gf.get_cross_section(cross_section)
x.add_bbox(c)
x.add_pins(c)
if post_process:
post_process(c)

Check warning on line 84 in gdsfactory/components/coupler.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/components/coupler.py#L84

Added line #L84 was not covered by tests
return c


Expand Down
10 changes: 3 additions & 7 deletions gdsfactory/components/coupler_straight.py
Expand Up @@ -2,15 +2,15 @@

import gdsfactory as gf
from gdsfactory.component import Component
from gdsfactory.components.straight import straight
from gdsfactory.components.straight import straight as straight_function
from gdsfactory.cross_section import CrossSectionSpec


@gf.cell
def coupler_straight(
length: float = 10.0,
gap: float = 0.27,
straight: Component = straight,
straight: Component = straight_function,
cross_section: CrossSectionSpec = "xs_sc_no_pins",
**kwargs,
) -> Component:
Expand All @@ -31,12 +31,8 @@ def coupler_straight(
"""
component = Component()

x = gf.get_cross_section(cross_section, **kwargs)

straight_component = straight(
length=length,
cross_section=x,
add_pins=False,
length=length, cross_section=cross_section, add_pins=False, **kwargs
)

top = component << straight_component
Expand Down
6 changes: 5 additions & 1 deletion gdsfactory/components/resistance_sheet.py
Expand Up @@ -6,7 +6,7 @@
from gdsfactory.component import Component
from gdsfactory.components.compass import compass
from gdsfactory.components.via_stack import via_stack_slab_npp_m3
from gdsfactory.typings import ComponentSpec, Floats, LayerSpecs
from gdsfactory.typings import Callable, ComponentSpec, Floats, LayerSpecs

pad_via_stack_slab_npp = partial(via_stack_slab_npp_m3, size=(80, 80))

Expand All @@ -21,6 +21,7 @@
ohms_per_square: float | None = None,
port_orientation1: int = 180,
port_orientation2: int = 0,
post_process: Callable | None = None,
) -> Component:
"""Returns Sheet resistance.

Expand All @@ -35,6 +36,7 @@
ohms_per_square: optional sheet resistance to compute info.resistance.
port_orientation1: in degrees.
port_orientation2: in degrees.
post_process: function to post process the component.
"""
c = Component()

Expand Down Expand Up @@ -75,6 +77,8 @@
)
c.absorb(pad1)
c.absorb(pad2)
if post_process:
post_process(c)

Check warning on line 81 in gdsfactory/components/resistance_sheet.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/components/resistance_sheet.py#L81

Added line #L81 was not covered by tests
return c


Expand Down
6 changes: 5 additions & 1 deletion gdsfactory/components/triangles.py
Expand Up @@ -4,7 +4,7 @@

from gdsfactory.cell import cell
from gdsfactory.component import Component
from gdsfactory.typings import LayerSpec, LayerSpecs
from gdsfactory.typings import Callable, LayerSpec, LayerSpecs


@cell
Expand All @@ -15,6 +15,7 @@
ybot: float = 0,
layer: LayerSpec = "WG",
layers: LayerSpecs | None = None,
post_process: Callable | None = None,
) -> Component:
r"""Return triangle.

Expand All @@ -25,6 +26,7 @@
ybot: bottom ysize.
layer: layer.
layers: optional list of layers to duplicate the geometry.
post_process: function to call after the component is created.

.. code::

Expand All @@ -44,6 +46,8 @@
layers = layers or [layer]
for layer in layers:
c.add_polygon(points, layer=layer)
if post_process:
post_process(c)

Check warning on line 50 in gdsfactory/components/triangles.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/components/triangles.py#L50

Added line #L50 was not covered by tests
return c


Expand Down
5 changes: 5 additions & 0 deletions gdsfactory/components/via_stack.py
Expand Up @@ -11,6 +11,7 @@
from gdsfactory.components.via import via1, via2, viac
from gdsfactory.components.wire import wire_corner45
from gdsfactory.typings import (
Callable,
ComponentFactory,
ComponentSpec,
Float2,
Expand All @@ -30,6 +31,7 @@
correct_size: bool = True,
slot_horizontal: bool = False,
slot_vertical: bool = False,
post_process: Callable | None = None,
) -> Component:
"""Rectangular via array stack.

Expand Down Expand Up @@ -154,6 +156,9 @@
y0 = -b + ch + h / 2
ref.move((x0, y0))

if post_process:
post_process(c)

Check warning on line 160 in gdsfactory/components/via_stack.py

View check run for this annotation

Codecov / codecov/patch

gdsfactory/components/via_stack.py#L160

Added line #L160 was not covered by tests

return c


Expand Down
2 changes: 2 additions & 0 deletions test-data-regression/test_netlists_mzit_.yml
Expand Up @@ -264,6 +264,7 @@ instances:
dy: 2.0
gap: 0.3
length: 10.0
post_process: null
coupler_2:
component: coupler
info:
Expand All @@ -279,6 +280,7 @@ instances:
dy: 2.0
gap: 0.2
length: 5.0
post_process: null
straight_1:
component: straight
info:
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_coupler_.yml
Expand Up @@ -14,3 +14,4 @@ settings:
dy: 4.0
gap: 0.236
length: 20.0
post_process: null
1 change: 1 addition & 0 deletions test-data-regression/test_settings_resistance_sheet_.yml
Expand Up @@ -32,4 +32,5 @@ settings:
pad_pitch: 100.0
port_orientation1: 180
port_orientation2: 0
post_process: null
width: 10
1 change: 1 addition & 0 deletions test-data-regression/test_settings_triangle_.yml
Expand Up @@ -5,6 +5,7 @@ name: triangle
settings:
layer: WG
layers: null
post_process: null
x: 10
xtop: 0
y: 20
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_via_stack_.yml
Expand Up @@ -16,6 +16,7 @@ settings:
- M1
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -15,6 +15,7 @@ settings:
layers:
- HEATER
- M2
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -16,6 +16,7 @@ settings:
- HEATER
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
Expand Up @@ -16,6 +16,7 @@ settings:
- HEATER
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down
1 change: 1 addition & 0 deletions test-data-regression/test_settings_via_stack_slab_m3_.yml
Expand Up @@ -17,6 +17,7 @@ settings:
- M1
- M2
- MTOP
post_process: null
size:
- 11.0
- 11.0
Expand Down