Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Nov 10, 2024
1 parent 8deb52a commit 6847ac0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.8.0
hooks:
- id: nbstripout
files: ".ipynb"
Expand All @@ -20,14 +20,14 @@ repos:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.4.2"
rev: "v0.7.2"
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.13.0
rev: v2.14.0
hooks:
- id: pretty-format-toml
args: [--autofix]
Expand Down
21 changes: 8 additions & 13 deletions docs/notebooks/00_layout.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"source": [
"import gdsfactory as gf\n",
"\n",
"import ubcpdk\n",
"import ubcpdk.components as uc"
]
},
Expand Down Expand Up @@ -239,7 +238,7 @@
"outputs": [],
"source": [
"c = uc.mzi_heater()\n",
"c = uc.add_fiber_array_pads_rf(c, optical_routing_type=2)\n",
"c = uc.add_fiber_array_pads_rf(c)\n",
"c.plot()"
]
},
Expand Down Expand Up @@ -278,6 +277,7 @@
"outputs": [],
"source": [
"from functools import partial\n",
"\n",
"import gdsfactory as gf\n",
"\n",
"import ubcpdk.components as uc\n",
Expand Down Expand Up @@ -354,9 +354,9 @@
" \"\"\"Contains mirror cavities and structures inside a resonator.\"\"\"\n",
" e = []\n",
" e += [add_gc(uc.ebeam_crossing4())]\n",
" e += [add_gc(uc.ebeam_adiabatic_te1550(), optical_routing_type=1)]\n",
" e += [add_gc(uc.ebeam_adiabatic_te1550())]\n",
" e += [add_gc(uc.ebeam_bdc_te1550())]\n",
" e += [add_gc(uc.ebeam_y_1550(), optical_routing_type=1)]\n",
" e += [add_gc(uc.ebeam_y_1550())]\n",
" e += [add_gc(uc.straight(), component_name=f\"straight_{i}\") for i in range(2)]\n",
" c = gf.Component()\n",
" _ = c << gf.pack(e, max_size=size, spacing=2)[0]\n",
Expand All @@ -379,16 +379,11 @@
"def EBeam_JoaquinMatres_4() -> gf.Component:\n",
" \"\"\"MZI interferometers.\"\"\"\n",
" mzi = partial(gf.components.mzi, splitter=uc.ebeam_y_1550)\n",
" mzis = [mzi(delta_length=delta_length) for delta_length in [10, 40, 100]]\n",
" mzis_gc = [\n",
" uc.add_fiber_array(mzi, optical_routing_type=2, fanout_length=5) for mzi in mzis\n",
" ]\n",
" mzis = [mzi(delta_length=delta_length) for delta_length in [10, 40]]\n",
" mzis_gc = [uc.add_fiber_array(mzi, fanout_length=5) for mzi in mzis]\n",
"\n",
" mzis = [uc.mzi_heater(delta_length=delta_length) for delta_length in [40]]\n",
" mzis_heater_gc = [\n",
" uc.add_fiber_array_pads_rf(mzi, orientation=90, optical_routing_type=2)\n",
" for mzi in mzis\n",
" ]\n",
" mzis_heater_gc = [uc.add_fiber_array_pads_rf(mzi, orientation=90) for mzi in mzis]\n",
"\n",
" e = mzis_gc + mzis_heater_gc\n",
" c = gf.Component()\n",
Expand Down Expand Up @@ -457,7 +452,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/11_sparameters_gratings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 0 additions & 2 deletions docs/notebooks/12_sim_plugins_tidy3d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"metadata": {},
"outputs": [],
"source": [
"import gdsfactory as gf\n",
"import gplugins as sim\n",
"import gplugins.tidy3d as gt\n",
"\n",
Expand Down Expand Up @@ -116,7 +115,6 @@
"metadata": {},
"outputs": [],
"source": [
"import gdsfactory as gf\n",
"import gplugins.sax as gsax\n",
"import jax.numpy as jnp\n",
"import matplotlib.pyplot as plt\n",
Expand Down
29 changes: 19 additions & 10 deletions ubcpdk/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
ComponentSpec,
CrossSectionSpec,
Optional,
Port,
)

from ubcpdk import tech
Expand Down Expand Up @@ -433,8 +432,7 @@ def mzi_heater(delta_length=10.0, length_x=320) -> gf.Component:
Args:
delta_length: extra length for mzi arms.
"""
c = _mzi_heater(delta_length=delta_length, length_x=length_x)
return c
return _mzi_heater(delta_length=delta_length, length_x=length_x)


@gf.cell
Expand All @@ -447,15 +445,13 @@ def via_stack_heater_mtop(size=(10, 10)) -> gf.Component:


def get_input_label_text(
port: Port,
gc: ComponentReference,
component_name: Optional[str] = None,
username: str = CONFIG.username,
) -> str:
"""Return label for port and a grating coupler.
Args:
port: component port.
gc: grating coupler reference.
component_name: optional component name.
username: for the label.
Expand Down Expand Up @@ -525,6 +521,11 @@ def add_fiber_array(
ref.drotate(-90)
c.add_ports(ref.ports)
c.copy_child_info(component)

component_name = component_name or component.name
grating_coupler = gf.get_component(grating_coupler)
label = get_input_label_text(gc=grating_coupler, component_name=component_name)
c.add_label(position=c.ports["o1"].dcenter, text=label, layer=LAYER.TEXT)
return c


Expand Down Expand Up @@ -812,6 +813,8 @@ def add_fiber_array_pads_rf(
component: ComponentSpec = "ring_single_heater",
username: str = CONFIG.username,
orientation: float = 0,
pad_yspacing: float = 50,
component_name: Optional[str] = None,
**kwargs,
) -> Component:
"""Returns fiber array with label and electrical pads.
Expand All @@ -820,16 +823,21 @@ def add_fiber_array_pads_rf(
component: to add fiber array and pads.
username: for the label.
orientation: for adding pads.
pad_yspacing: for adding pads.
component_name: for the label.
kwargs: for add_fiber_array.
"""

c0 = gf.get_component(component)
# text = f"elec_{username}-{clean_name(c0.name)}_G"
# add_label = partial(add_label_electrical, text=text)
c1 = add_pads_rf(component=c0, orientation=orientation)
component_name = component_name or c0.name
component_name = clean_name(component_name)
text = f"elec_{username}-{component_name}_G"
c1 = add_pads_rf(component=c0, orientation=orientation, spacing=(0, pad_yspacing))

add_label_electrical(component=c1, text=text)
# ports_names = [port.name for port in c0.ports if port.orientation == orientation]
# c1 = add_pads_top(component=c0, port_names=ports_names)
return add_fiber_array(component=c1, **kwargs)
return add_fiber_array(component=c1, component_name=component_name, **kwargs)


@cache
Expand Down Expand Up @@ -874,7 +882,7 @@ def add_pads(
# c = add_fiber_array(straight_heater_metal)
# c.pprint_ports()
# c = coupler_ring()
c = dbr_cavity_te()
# c = dbr_cavity_te()
# c = dbr_cavity()
# c = ring_single(radius=12)
# c = bend_euler()
Expand All @@ -888,4 +896,5 @@ def add_pads(
# c = ring_double()
# c = ring_double(radius=12, length_x=2, length_y=2)
# c = straight()
c = add_fiber_array_pads_rf(component_name="ring_single_heater")
c.show()

0 comments on commit 6847ac0

Please sign in to comment.