Skip to content

Commit

Permalink
Merge pull request #56 from gdsfactory/add_samples
Browse files Browse the repository at this point in the history
add samples and docstrings
  • Loading branch information
joamatab authored Jul 28, 2024
2 parents 014201a + 6f64234 commit f3d31c1
Show file tree
Hide file tree
Showing 65 changed files with 5,821 additions and 5,625 deletions.
2 changes: 2 additions & 0 deletions .github/write_cells_si220.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Write docs."""

import inspect

from cspdk.si220 import _cells as cells
Expand Down
2 changes: 2 additions & 0 deletions .github/write_cells_si500.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Write docs."""

import inspect

from cspdk.si500 import _cells as cells
Expand Down
2 changes: 2 additions & 0 deletions .github/write_cells_sin300.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Write docs."""

import inspect

from cspdk.sin300 import _cells as cells
Expand Down
2 changes: 2 additions & 0 deletions cspdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Version of the package."""

__version__ = "0.10.1"
6 changes: 5 additions & 1 deletion cspdk/si220/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Si220 pdk."""

from functools import lru_cache

from gdsfactory.config import CONF
Expand All @@ -19,6 +21,7 @@

@lru_cache
def get_pdk() -> Pdk:
"""Return Cornerstone PDK."""
return Pdk(
name="cornerstone_si220",
cells=_cells,
Expand All @@ -31,7 +34,8 @@ def get_pdk() -> Pdk:
)


def activate_pdk():
def activate_pdk() -> None:
"""Activate Cornerstone Si220 PDK."""
pdk = get_pdk()
pdk.activate()

Expand Down
87 changes: 43 additions & 44 deletions cspdk/si220/cells.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""This module contains the building blocks for the CSPDK PDK."""

from functools import partial

import gdsfactory as gf
Expand All @@ -18,12 +20,13 @@ def straight(
cross_section: CrossSectionSpec = "xs_sc",
**kwargs,
) -> Component:
"""a straight waveguide
"""A straight waveguide.
Args:
length: the length of the waveguide
width: the width of the waveguide
length: the length of the waveguide.
width: the width of the waveguide.
cross_section: a cross section or its name or a function generating a cross section.
kwargs: additional arguments to pass to the straight function.
"""
if width is not None:
kwargs["width"] = width
Expand All @@ -44,7 +47,7 @@ def straight(

@gf.cell
def wire_corner() -> Component:
"""a wire corner
"""A wire corner.
A wire corner is a bend for electrical routes.
"""
Expand All @@ -56,7 +59,7 @@ def bend_s(
size: tuple[float, float] = (11.0, 1.8),
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""an S-bend
"""An S-bend.
Args:
size: the width and height of the s-bend
Expand All @@ -73,13 +76,13 @@ def bend_euler(
width: float | None = None,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""an euler bend
"""An euler bend.
Args:
radius: the effective radius of the bend
angle: the angle of the bend (usually 90 degrees)
p: the fraction of the bend that's represented by a polar bend
width: the width of the waveguide forming the bend
radius: the effective radius of the bend.
angle: the angle of the bend (usually 90 degrees).
p: the fraction of the bend that's represented by a polar bend.
width: the width of the waveguide forming the bend.
cross_section: a cross section or its name or a function generating a cross section.
"""
return gf.components.bend_euler(
Expand Down Expand Up @@ -114,15 +117,15 @@ def taper(
port: gf.Port | None = None,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""a taper
"""A taper.
A taper is a transition between two waveguide widths
Args:
length: the length of the taper
width1: the input width of the taper
width2: the output width of the taper (if not given, use port)
port: the port (with certain width) to taper towards (if not given, use width2)
length: the length of the taper.
width1: the input width of the taper.
width2: the output width of the taper (if not given, use port).
port: the port (with certain width) to taper towards (if not given, use width2).
cross_section: a cross section or its name or a function generating a cross section.
"""
c = gf.c.taper(
Expand Down Expand Up @@ -174,16 +177,16 @@ def taper_strip_to_ridge(
w_slab2: float = 10.45,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""a taper between strip and ridge
"""A taper between strip and ridge.
This is a transition between two distinct cross sections
Args:
length: the length of the taper
width1: the input width of the taper
width2: the output width of the taper
w_slab1: the input slab width of the taper
w_slab2: the output slab width of the taper
length: the length of the taper.
width1: the input width of the taper.
width2: the output width of the taper.
w_slab1: the input slab width of the taper.
w_slab2: the output slab width of the taper.
cross_section: a cross section or its name or a function generating a cross section.
"""
return gf.c.taper_strip_to_ridge(
Expand Down Expand Up @@ -218,17 +221,17 @@ def mmi1x2(
gap_mmi: float = 0.25,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""an mmi1x2
"""An mmi1x2.
An mmi1x2 is a splitter that splits a single input to two outputs
Args:
width: the width of the waveguides connecting at the mmi ports
width_taper: the width at the base of the mmi body
length_taper: the length of the tapers going towards the mmi body
length_mmi: the length of the mmi body
width_mmi: the width of the mmi body
gap_mmi: the gap between the tapers at the mmi body
width: the width of the waveguides connecting at the mmi ports.
width_taper: the width at the base of the mmi body.
length_taper: the length of the tapers going towards the mmi body.
length_mmi: the length of the mmi body.
width_mmi: the width of the mmi body.
gap_mmi: the gap between the tapers at the mmi body.
cross_section: a cross section or its name or a function generating a cross section.
"""
return gf.c.mmi1x2(
Expand Down Expand Up @@ -260,7 +263,7 @@ def mmi2x2(
gap_mmi: float = 0.25,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""an mmi2x2
"""An mmi2x2.
An mmi2x2 is a 2x2 splitter
Expand Down Expand Up @@ -303,7 +306,7 @@ def coupler_straight(
gap: float = 0.27,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""the straight part of a coupler
"""The straight part of a coupler.
Args:
length: the length of the straight part of the coupler
Expand All @@ -324,7 +327,7 @@ def coupler_symmetric(
dx: float = 10.0,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""the part of the coupler that diverges away from each other with s-bends
"""The part of the coupler that diverges away from each other with s-bends.
Args:
gap: the gap between the s-bends when closest together
Expand All @@ -349,7 +352,7 @@ def coupler(
dx: float = 10.0,
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""a coupler
"""A coupler.
a coupler is a 2x2 splitter
Expand All @@ -360,7 +363,6 @@ def coupler(
dx: the length of the s-bend
cross_section: a cross section or its name or a function generating a cross section.
"""

return gf.c.coupler(
gap=gap,
length=length,
Expand Down Expand Up @@ -405,7 +407,7 @@ def grating_coupler_rectangular(
wavelength: float = 1.55,
cross_section="xs_sc",
) -> Component:
"""A grating coupler with straight and parallel teeth
"""A grating coupler with straight and parallel teeth.
Args:
period: the period of the grating
Expand All @@ -414,7 +416,6 @@ def grating_coupler_rectangular(
wavelength: the center wavelength for which the grating is designed
cross_section: a cross section or its name or a function generating a cross section.
"""

return gf.c.grating_coupler_rectangular(
n_periods=n_periods,
period=period,
Expand Down Expand Up @@ -474,7 +475,7 @@ def grating_coupler_elliptical(
grating_line_width=0.315,
cross_section="xs_sc",
) -> Component:
"""A grating coupler with curved but parallel teeth
"""A grating coupler with curved but parallel teeth.
Args:
wavelength: the center wavelength for which the grating is designed
Expand Down Expand Up @@ -532,7 +533,7 @@ def mzi(
combiner="mmi2x2_sc",
cross_section: CrossSectionSpec = "xs_sc",
) -> Component:
"""A Mach-Zehnder Interferometer
"""A Mach-Zehnder Interferometer.
Args:
delta_length: the difference in length between the upper and lower arms of the mzi
Expand Down Expand Up @@ -613,13 +614,13 @@ def mzi(

@gf.cell
def pad() -> Component:
"""An electrical pad"""
"""An electrical pad."""
return gf.c.pad(layer=LAYER.PAD, size=(100.0, 100.0))


@gf.cell
def rectangle(**kwargs) -> Component:
"""A rectangle"""
"""A rectangle."""
kwargs["layer"] = LAYER.FLOORPLAN
return gf.c.rectangle(**kwargs)

Expand All @@ -636,7 +637,7 @@ def grating_coupler_array(
straight_to_grating_spacing=10.0,
cross_section="xs_sc",
) -> Component:
"""An array of grating couplers
"""An array of grating couplers.
Args:
pitch: the pitch of the grating couplers
Expand All @@ -649,7 +650,6 @@ def grating_coupler_array(
straight_to_grating_spacing: spacing between the last grating coupler and the loopback.
cross_section: a cross section or its name or a function generating a cross section.
"""

if grating_coupler is None:
if isinstance(cross_section, str):
xs = cross_section
Expand Down Expand Up @@ -684,12 +684,11 @@ def grating_coupler_array(

@gf.cell
def die(cross_section="xs_sc") -> Component:
"""A die template
"""A die template.
Args:
cross_section: a cross section or its name or a function generating a cross section.
"""

if isinstance(cross_section, str):
xs = cross_section
elif callable(cross_section):
Expand Down Expand Up @@ -809,7 +808,7 @@ def array(
size=None,
centered: bool = False,
) -> Component:
"""An array of components
"""An array of components.
Args:
component: the component of which to create an array
Expand Down
2 changes: 1 addition & 1 deletion cspdk/si220/import_pdk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""From a list of GDS files, generate a script to import the cells from a pdk"""
"""From a list of GDS files, generate a script to import the cells from a pdk."""

import gdsfactory as gf

Expand Down
Loading

0 comments on commit f3d31c1

Please sign in to comment.