diff --git a/.github/write_components_autodoc.py b/.github/write_components_autodoc.py index b76efe8d..72c22d53 100644 --- a/.github/write_components_autodoc.py +++ b/.github/write_components_autodoc.py @@ -1,8 +1,8 @@ import inspect + import ubcpdk from ubcpdk.config import PATH - filepath = PATH.repo / "docs" / "components.rst" skip = { @@ -51,7 +51,7 @@ [ f"{p}={repr(sig.parameters[p].default)}" for p in sig.parameters - if isinstance(sig.parameters[p].default, (int, float, str, tuple)) + if isinstance(sig.parameters[p].default, int | float | str | tuple) and p not in skip_settings ] ) diff --git a/.github/write_components_plot.py b/.github/write_components_plot.py index 0c6b2ea0..8ad6bdcd 100644 --- a/.github/write_components_plot.py +++ b/.github/write_components_plot.py @@ -1,8 +1,7 @@ -from typing import Tuple import inspect -from ubcpdk.config import PATH -from ubcpdk import cells +from ubcpdk import cells +from ubcpdk.config import PATH filepath = PATH.repo / "docs" / "components_plot.rst" @@ -20,8 +19,8 @@ "waveguide_template", } -skip_plot: Tuple[str, ...] = ("add_fiber_array_siepic",) -skip_settings: Tuple[str, ...] = ("flatten", "safe_cell_names") +skip_plot: tuple[str, ...] = ("add_fiber_array_siepic",) +skip_settings: tuple[str, ...] = ("flatten", "safe_cell_names") with open(filepath, "w+") as f: @@ -45,7 +44,7 @@ [ f"{p}={repr(sig.parameters[p].default)}" for p in sig.parameters - if isinstance(sig.parameters[p].default, (int, float, str, tuple)) + if isinstance(sig.parameters[p].default, int | float | str | tuple) and p not in skip_settings ] ) diff --git a/.github/write_components_plot_klayout.py b/.github/write_components_plot_klayout.py index c3f9feb9..57d57a5c 100644 --- a/.github/write_components_plot_klayout.py +++ b/.github/write_components_plot_klayout.py @@ -1,8 +1,7 @@ -from typing import Tuple import inspect -from ubcpdk.config import PATH -from ubcpdk import cells +from ubcpdk import cells +from ubcpdk.config import PATH filepath = PATH.repo / "docs" / "components_plot.rst" @@ -20,8 +19,8 @@ "waveguide_template", } -skip_plot: Tuple[str, ...] = ("add_fiber_array_siepic",) -skip_settings: Tuple[str, ...] = ("flatten", "safe_cell_names") +skip_plot: tuple[str, ...] = ("add_fiber_array_siepic",) +skip_settings: tuple[str, ...] = ("flatten", "safe_cell_names") with open(filepath, "w+") as f: @@ -45,7 +44,7 @@ [ f"{p}={repr(sig.parameters[p].default)}" for p in sig.parameters - if isinstance(sig.parameters[p].default, (int, float, str, tuple)) + if isinstance(sig.parameters[p].default, int | float | str | tuple) and p not in skip_settings ] ) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 430965ae..7767172a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,12 +7,6 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - id: requirements-txt-fixer - - repo: https://github.com/pycqa/isort - rev: 7b69d092ae4885dcc45648538ae780a6326bcd1e - hooks: - - id: isort - files: ubcdpk/.* - args: [--profile, black, --filter-files] - repo: https://github.com/psf/black rev: 25d886f52c2bbbb58386ac8050f4e67952507bc7 @@ -23,3 +17,8 @@ repos: rev: "6a0ba1854991b693612486cc84a2254de82d071d" hooks: - id: ruff + - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.10.0 + hooks: + - id: pretty-format-toml + args: [--autofix] diff --git a/CHANGELOG.md b/CHANGELOG.md index e475360b..72ece472 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ # Changelog -## [2.0.0](https://github.com/gdsfactory/ubc/pull/204) - -- update to gdsfactory 7 +## [2.0.0](https://github.com/gdsfactory/ubc/pull/291) +- update to gdsfactory 7.0.2 ## [1.21.0](https://github.com/gdsfactory/ubc/pull/203) diff --git a/Makefile b/Makefile index 95402ad9..681b0def 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ install: dev: pip install -e .[dev,docs] -update: - pre-commit autoupdate --bleeding-edge +update-pre: + pre-commit autoupdate watch: gf watch ubcpdk diff --git a/install_tech.py b/install_tech.py index 42f63d32..658cb5dc 100644 --- a/install_tech.py +++ b/install_tech.py @@ -1,8 +1,8 @@ """Symlink tech to klayout.""" -import sys import os -import shutil import pathlib +import shutil +import sys def remove_path_or_dir(dest: pathlib.Path): diff --git a/pyproject.toml b/pyproject.toml index 60daef38..1f7f3bac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,52 +1,47 @@ # https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html + [build-system] -requires = ["flit_core >=3.2,<4"] build-backend = "flit_core.buildapi" +requires = ["flit_core >=3.2,<4"] [project] -name="ubcpdk" -description="ubcpdk pdk" +authors = [ + {name = "gdsfactory", email = "contact@gdsfactory.com"} +] classifiers = [ - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Operating System :: OS Independent", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent" ] -version="1.21.3" -authors = [ - {name = "gdsfactory", email = "contact@gdsfactory.com"}, +dependencies = [ + "gdsfactory==7.0.2", + "gplugins[tidy3d]>=0.0.3,<0.1.0" ] +description = "ubcpdk pdk" keywords = ["python"] license = {file = "LICENSE"} -dependencies = [ - "gdsfactory==7.0.2", - "gplugins[tidy3d]>=0.0.3,<0.1.0", -] +name = "ubcpdk" readme = "README.md" requires-python = ">=3.10" +version = "1.21.3" [project.optional-dependencies] -full = [ - "femwell" - ] dev = [ - "pytest", - "pytest-cov", - "pytest_regressions", - ] + "pytest", + "pytest-cov", + "pytest_regressions" +] docs = [ "autodoc_pydantic", "jupytext", - "jupyter-book==0.15.1", - ] - -[tool.setuptools.packages] -find = {} + "jupyter-book==0.15.1" +] +full = [ + "femwell" +] [tool.black] -line-length = 88 -target-version = ['py310'] -include = '\.pyi?$' exclude = ''' # Specify the files/dirs that should be ignored by the black formatter /( \.eggs @@ -62,83 +57,63 @@ exclude = ''' # Specify the files/dirs that should be ignored by the black form | dist )/ ''' - -[tool.pytest.ini_options] -testpaths = ["tests"] -# testpaths = ["ubcpdk/samples", "tests"] -# addopts = --tb=no -# addopts = '--tb=short' -# python_files = ["ubcpdk/samples*.py", "tests/*.py"] -python_files = ["tests/*.py"] -# norecursedirs = ["extra/*.py", 'ubcdpk/simulations/*.py'] - -[tool.flake8] -max-line-length = 88 -max-complexity = 57 -select = ["B","C","E","F","W","T4","B9"] -ignore = [ "E501", "E503", "E722", "W503", "W503", "E203", "B950", "B305", "B018", "B902", "B020", "B905"] -extend-ignore = "RST303" - -exclude = [ - ".git", - "__pycache__", - "lib", - "docs/source/conf.py", - "build", - "dist", - ".ipynb_checkpoints", - ".tox", - "extra", - "deprecated", - ".mypy_cache", - "venv", - "devsim", - ] - -[tool.commitizen] -name = "cz_conventional_commits" -version = "0.1.0" -version_files = [ - "pyproject.toml:version", -] +include = '\.pyi?$' +line-length = 88 +target-version = ['py310'] [tool.mypy] python_version = "3.10" strict = true +[tool.pydocstyle] +add-ignore = ["D100", "D101", "D102", "D103", "D104", "D203", "D405", "D417"] +convention = "google" +inherit = false +match = "(?!test).*\\.py" + [tool.pylsp-mypy] enabled = true live_mode = true strict = true -[tool.isort] -multi_line_output = 3 -line_length = 88 -include_trailing_comma = true - -[tool.setuptools.package-data] -mypkg = ["*.csv", "*.yaml"] - -[tool.pydocstyle] -inherit = false -match = "(?!test).*\\.py" -add-ignore = ["D100","D101","D102","D103","D104","D203","D405","D417"] -convention = "google" +[tool.pytest.ini_options] +# testpaths = ["ubcpdk/samples", "tests"] +# addopts = --tb=no +# addopts = '--tb=short' +# python_files = ["ubcpdk/samples*.py", "tests/*.py"] +python_files = ["tests/*.py"] +testpaths = ["tests"] [tool.ruff] -select = [ - "E", # pycodestyle errors - "W", # pycodestyle warnings - "F", # pyflakes - # "I", # isort - "C", # flake8-comprehensions - "B", # flake8-bugbear -] +extend-exclude = ["docs/notebooks"] ignore = [ - "E501", # line too long, handled by black - "B008", # do not perform function calls in argument defaults - "C901", # too complex - "B905", # `zip()` without an explicit `strict=` parameter - "C408", # C408 Unnecessary `dict` call (rewrite as a literal) + "E501", # line too long, handled by black + "B008", # do not perform function calls in argument defaults + "C901", # too complex + "B905", # `zip()` without an explicit `strict=` parameter + "C408" # C408 Unnecessary `dict` call (rewrite as a literal) ] -extend-exclude = ["docs/notebooks"] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "C", # flake8-comprehensions + "B", # flake8-bugbear + "UP" +] + +[tool.ruff.per-file-ignores] +"ubcpdk/samples/notebooks/11_sparameters.py" = ['E402'] +"ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py" = ['E402'] +"ubcpdk/samples/notebooks/13_sim_plugins.py" = ['E402'] +"ubcpdk/samples/notebooks/14_sax_tidy3d.py" = ['E402'] +"ubcpdk/samples/notebooks/21_schematic_driven_layout.py" = ['E402'] +"ubcpdk/samples/notebooks/31_data_analysis_mzi.py" = ['E402'] +"ubcpdk/samples/notebooks/33_data_analysis_dbr.py" = ['E402'] + +[tool.setuptools.package-data] +mypkg = ["*.csv", "*.yaml"] + +[tool.setuptools.packages] +find = {} diff --git a/tests/test_components.py b/tests/test_components.py index cf7a091f..88522e41 100644 --- a/tests/test_components.py +++ b/tests/test_components.py @@ -1,11 +1,11 @@ import pathlib -import pytest -from pytest_regressions.data_regression import DataRegressionFixture +import pytest from gdsfactory.component import Component from gdsfactory.difftest import difftest -from ubcpdk import cells +from pytest_regressions.data_regression import DataRegressionFixture +from ubcpdk import cells skip_test = { "add_siepic_labels", diff --git a/ubcpdk/__init__.py b/ubcpdk/__init__.py index 45b3ecbd..8cfebc34 100644 --- a/ubcpdk/__init__.py +++ b/ubcpdk/__init__.py @@ -6,14 +6,9 @@ from gdsfactory.get_factories import get_cells from gdsfactory.pdk import Pdk +from ubcpdk import components, data, tech from ubcpdk.config import CONFIG, PATH, module -from ubcpdk.tech import LAYER, strip, LAYER_STACK, LAYER_VIEWS -from ubcpdk import components -from ubcpdk import tech -from ubcpdk import data - -from ubcpdk.tech import cross_sections - +from ubcpdk.tech import LAYER, LAYER_STACK, LAYER_VIEWS, cross_sections, strip __version__ = "1.21.3" diff --git a/ubcpdk/components.py b/ubcpdk/components.py index 963d473c..6ae929a5 100644 --- a/ubcpdk/components.py +++ b/ubcpdk/components.py @@ -1,30 +1,31 @@ """Cells imported from the PDK.""" from functools import partial + import gdsfactory as gf +from gdsfactory import Component from gdsfactory.typings import ( Callable, ComponentReference, ComponentSpec, CrossSectionSpec, + Label, LayerSpec, List, Optional, Port, Tuple, - Label, ) -from gdsfactory import Component -from ubcpdk.config import CONFIG -from ubcpdk.import_gds import import_gds, import_gc from ubcpdk import tech +from ubcpdk.config import CONFIG +from ubcpdk.import_gds import import_gc, import_gds from ubcpdk.tech import ( - strip, - LAYER_STACK, LAYER, + LAYER_STACK, add_pins_bbox_siepic, add_pins_bbox_siepic_remove_layers, add_pins_siepic_metal, + strip, ) um = 1e-6 @@ -432,7 +433,7 @@ def get_input_label_text( "TM", ], f"Not valid polarization {polarization.upper()!r} in [TE, TM]" assert ( - isinstance(wavelength, (int, float)) and 1.0 < wavelength < 2.0 + isinstance(wavelength, int | float) and 1.0 < wavelength < 2.0 ), f"{wavelength} is Not valid 1000 < wavelength < 2000" name = component_name or port.parent.metadata_child.get("name") diff --git a/ubcpdk/config.py b/ubcpdk/config.py index ef71e406..5d712a35 100644 --- a/ubcpdk/config.py +++ b/ubcpdk/config.py @@ -10,7 +10,6 @@ from omegaconf import OmegaConf - default_config = io.StringIO( """ username: JoaquinMatres diff --git a/ubcpdk/data/find_bandwidth.py b/ubcpdk/data/find_bandwidth.py index 6f4f7dff..b023e216 100644 --- a/ubcpdk/data/find_bandwidth.py +++ b/ubcpdk/data/find_bandwidth.py @@ -41,8 +41,8 @@ def plot_bandwidth(x, y, threshold: float = 3) -> None: if __name__ == "__main__": - from ubcpdk.data.dbr import dbrs from ubcpdk.data.chop import chop + from ubcpdk.data.dbr import dbrs from ubcpdk.data.read_mat import read_mat w, p = read_mat(dbrs["1_5"], port=1) diff --git a/ubcpdk/data/read_mat.py b/ubcpdk/data/read_mat.py index 32bd4c1b..57db56ef 100644 --- a/ubcpdk/data/read_mat.py +++ b/ubcpdk/data/read_mat.py @@ -1,6 +1,6 @@ -from gdsfactory.typings import Tuple, PathType -from scipy.io import loadmat import numpy as np +from gdsfactory.typings import PathType, Tuple +from scipy.io import loadmat def read_mat(filename: PathType, port: int = 0) -> Tuple[np.ndarray, np.ndarray]: @@ -28,6 +28,7 @@ def read_mat(filename: PathType, port: int = 0) -> Tuple[np.ndarray, np.ndarray] if __name__ == "__main__": import matplotlib.pyplot as plt + import ubcpdk w, p = read_mat(ubcpdk.PATH.mzi1) diff --git a/ubcpdk/data/remove_baseline.py b/ubcpdk/data/remove_baseline.py index 5025640e..e208ab1a 100644 --- a/ubcpdk/data/remove_baseline.py +++ b/ubcpdk/data/remove_baseline.py @@ -1,4 +1,5 @@ import numpy as np + from ubcpdk.data.read_mat import read_mat @@ -17,6 +18,7 @@ def remove_baseline(wavelength: np.ndarray, power: np.ndarray, deg: int = 4): if __name__ == "__main__": import matplotlib.pyplot as plt + import ubcpdk w, p = read_mat(ubcpdk.PATH.mzi1) diff --git a/ubcpdk/data/windowed_mean.py b/ubcpdk/data/windowed_mean.py index 1d881a7a..d6607241 100644 --- a/ubcpdk/data/windowed_mean.py +++ b/ubcpdk/data/windowed_mean.py @@ -16,10 +16,11 @@ def windowed_mean(data: np.array, n: int = 60) -> np.array: if __name__ == "__main__": - from ubcpdk.data.read_mat import read_mat - from ubcpdk.config import PATH import matplotlib.pyplot as plt + from ubcpdk.config import PATH + from ubcpdk.data.read_mat import read_mat + wavelength, power = read_mat(PATH.ring_te_r3_g100) power_envelope = windowed_mean(power, 60) plt.plot(wavelength, power, label="power") diff --git a/ubcpdk/import_gds.py b/ubcpdk/import_gds.py index 91519fa8..05269b67 100644 --- a/ubcpdk/import_gds.py +++ b/ubcpdk/import_gds.py @@ -1,14 +1,10 @@ -from typing import Optional - -from numpy import ndarray -from numpy import arctan2, degrees, isclose - import gdsfactory as gf from gdsfactory.component import Component from gdsfactory.typings import LayerSpec -from ubcpdk.tech import LAYER -from ubcpdk.config import PATH +from numpy import arctan2, degrees, isclose, ndarray +from ubcpdk.config import PATH +from ubcpdk.tech import LAYER layer = LAYER.WG port_width = 0.5 @@ -80,9 +76,9 @@ def add_ports(component: Component) -> Component: def add_ports_from_siepic_pins( component: Component, pin_layer_optical: LayerSpec = "PORT", - port_layer_optical: Optional[LayerSpec] = None, + port_layer_optical: LayerSpec | None = None, pin_layer_electrical: LayerSpec = "PORTE", - port_layer_electrical: Optional[LayerSpec] = None, + port_layer_electrical: LayerSpec | None = None, ) -> Component: """Add ports from SiEPIC-type cells, where the pins are defined as paths. diff --git a/ubcpdk/import_pdk.py b/ubcpdk/import_pdk.py index df4ce341..fea688dc 100644 --- a/ubcpdk/import_pdk.py +++ b/ubcpdk/import_pdk.py @@ -1,6 +1,6 @@ import gdsfactory as gf -from ubcpdk.config import PATH +from ubcpdk.config import PATH if __name__ == "__main__": print( diff --git a/ubcpdk/samples/notebooks/11_sparameters.py b/ubcpdk/samples/notebooks/11_sparameters.py index 9f596423..5ff0a782 100644 --- a/ubcpdk/samples/notebooks/11_sparameters.py +++ b/ubcpdk/samples/notebooks/11_sparameters.py @@ -33,7 +33,6 @@ import ubcpdk.components as pdk from ubcpdk.config import PATH - # %% c = pdk.ebeam_y_1550() c.plot() @@ -63,6 +62,7 @@ # %% import gplugins as sim + import ubcpdk.components as pdk # %% @@ -95,7 +95,6 @@ # The resolution is in pixels/um so you need to run with at least `resolution=100` for 1/100 um/pixel (10 nm/ pixel). # %% -import gdsfactory as gf import gplugins.gmeep as gm # %% diff --git a/ubcpdk/samples/notebooks/11_sparameters_gratings.py b/ubcpdk/samples/notebooks/11_sparameters_gratings.py index 8cff546a..d0914a8b 100644 --- a/ubcpdk/samples/notebooks/11_sparameters_gratings.py +++ b/ubcpdk/samples/notebooks/11_sparameters_gratings.py @@ -23,10 +23,10 @@ # ## tidy3d # %% -import numpy as np +import gplugins.gtidy3d as gt import matplotlib.pyplot as plt +import numpy as np -import gplugins.gtidy3d as gt import ubcpdk.components as pdk from ubcpdk.config import PATH @@ -66,7 +66,11 @@ def log(x): # %% for offset in offsets: sp = gt.write_sparameters_grating_coupler( - c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=offset, dirpath=PATH.sparameters + c, + is_3d=False, + fiber_angle_deg=fiber_angle_deg, + fiber_xoffset=offset, + dirpath=PATH.sparameters, ) plt.plot( sp["wavelengths"], diff --git a/ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py b/ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py index 8de5814c..33732332 100644 --- a/ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py +++ b/ubcpdk/samples/notebooks/12_sim_plugins_tidy3d.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # --- # jupyter: # jupytext: @@ -40,12 +39,11 @@ # ![cloud_model](https://i.imgur.com/5VTCPLR.png) # %% -import gplugins as sim import gdsfactory as gf +import gplugins as sim import gplugins.gtidy3d as gt -import ubcpdk.components as pdk -from ubcpdk.config import PATH +import ubcpdk.components as pdk # %% c = pdk.ebeam_y_1550() @@ -69,14 +67,13 @@ mzi10.plot() # %% +import gdsfactory as gf +import gplugins.sax as gsax +import jax.numpy as jnp import matplotlib.pyplot as plt import numpy as np -import jax.numpy as jnp import sax -import gdsfactory as gf -import gplugins.sax as gsax - # %% def straight(wl=1.5, length=10.0, neff=2.4) -> sax.SDict: diff --git a/ubcpdk/samples/notebooks/13_sim_plugins.py b/ubcpdk/samples/notebooks/13_sim_plugins.py index 3c07d340..9def6ad6 100644 --- a/ubcpdk/samples/notebooks/13_sim_plugins.py +++ b/ubcpdk/samples/notebooks/13_sim_plugins.py @@ -25,9 +25,9 @@ # ## MEEP FDTD # + -import gplugins.gmeep as gm -import gplugins as sim import gdsfactory as gf +import gplugins as sim +import gplugins.gmeep as gm import ubcpdk as pdk @@ -131,6 +131,7 @@ # + from gplugins.add_simulation_markers import add_simulation_markers + import ubcpdk as pdk y = pdk.components.ebeam_y_1550() @@ -157,15 +158,14 @@ mzi10 # + +import gdsfactory as gf +import gplugins.gmeep as gm +import gplugins.sax as gsax +import jax.numpy as jnp import matplotlib.pyplot as plt import numpy as np -import jax.numpy as jnp import sax -import gdsfactory as gf -import gplugins.sax as gsax -import gplugins.gmeep as gm - import ubcpdk as pdk # - diff --git a/ubcpdk/samples/notebooks/14_sax_tidy3d.py b/ubcpdk/samples/notebooks/14_sax_tidy3d.py index 5072e53a..67a55cf8 100644 --- a/ubcpdk/samples/notebooks/14_sax_tidy3d.py +++ b/ubcpdk/samples/notebooks/14_sax_tidy3d.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # --- # jupyter: # jupytext: @@ -29,16 +28,15 @@ # %% from pprint import pprint -import numpy as np -import matplotlib.pyplot as plt -import jax.numpy as jnp import gdsfactory as gf +import gplugins.gtidy3d as gt import gplugins.sax as gs +import jax.numpy as jnp +import matplotlib.pyplot as plt +import numpy as np import sax -import gplugins.gtidy3d as gt - # %% [markdown] # ## Scatter *dictionaries* # @@ -188,7 +186,6 @@ def waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0) -> sa cp.plot_field(field_name="Ex", mode_index=1) # odd mode - # %% [markdown] # For a 200nm gap the effective index difference `dn` is `0.026`, which means that there is 100% power coupling over 29.4 diff --git a/ubcpdk/samples/notebooks/21_schematic_driven_layout.py b/ubcpdk/samples/notebooks/21_schematic_driven_layout.py index 5d926e87..3d689018 100644 --- a/ubcpdk/samples/notebooks/21_schematic_driven_layout.py +++ b/ubcpdk/samples/notebooks/21_schematic_driven_layout.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # --- # jupyter: # jupytext: @@ -22,11 +21,10 @@ # The Jupyter notebook interface allows you to get the best of both worlds of GUI and python driven based flows. # %% -from bokeh.io import output_notebook - import gdsfactory as gf -from gplugins.schematic_editor import SchematicEditor +from bokeh.io import output_notebook from gdsfactory.config import rich_output +from gplugins.schematic_editor import SchematicEditor # %env BOKEH_ALLOW_WS_ORIGIN=localhost:8888 @@ -159,10 +157,10 @@ # ## Circuit simulations # %% -import numpy as np -import matplotlib.pyplot as plt import gplugins.sax as gs import jax.numpy as jnp +import matplotlib.pyplot as plt +import numpy as np import sax netlist = c.get_netlist() diff --git a/ubcpdk/samples/notebooks/31_data_analysis_mzi.py b/ubcpdk/samples/notebooks/31_data_analysis_mzi.py index 59afcd6b..d6e1a753 100644 --- a/ubcpdk/samples/notebooks/31_data_analysis_mzi.py +++ b/ubcpdk/samples/notebooks/31_data_analysis_mzi.py @@ -68,6 +68,7 @@ # %% import matplotlib.pyplot as plt import numpy as np + import ubcpdk from ubcpdk.simulation.circuits.mzi_spectrum import mzi_spectrum diff --git a/ubcpdk/samples/notebooks/32_data_analysis_ring.py b/ubcpdk/samples/notebooks/32_data_analysis_ring.py index 1521e1c1..ae093241 100644 --- a/ubcpdk/samples/notebooks/32_data_analysis_ring.py +++ b/ubcpdk/samples/notebooks/32_data_analysis_ring.py @@ -32,6 +32,7 @@ # + attributes={"classes": [], "id": "", "n": "2"} import matplotlib.pyplot as plt + import ubcpdk # + attributes={"classes": [], "id": "", "n": "3"} diff --git a/ubcpdk/samples/notebooks/33_data_analysis_dbr.py b/ubcpdk/samples/notebooks/33_data_analysis_dbr.py index 9150cfb4..b2a9daf8 100644 --- a/ubcpdk/samples/notebooks/33_data_analysis_dbr.py +++ b/ubcpdk/samples/notebooks/33_data_analysis_dbr.py @@ -20,6 +20,7 @@ # + attributes={"classes": [], "id": "", "n": "2"} import matplotlib.pyplot as plt + import ubcpdk from ubcpdk.data.dbr import dbrs @@ -37,8 +38,9 @@ plt.xlim([1530, 1600]) # + -import numpy as np import matplotlib.pyplot as plt +import numpy as np + from ubcpdk import data from ubcpdk.data.dbr import dbrs diff --git a/ubcpdk/samples/test_masks.py b/ubcpdk/samples/test_masks.py index 9b74745a..28c77d78 100644 --- a/ubcpdk/samples/test_masks.py +++ b/ubcpdk/samples/test_masks.py @@ -1,10 +1,10 @@ """Write all mask for the course.""" import shutil -from ubcpdk.config import PATH -import ubcpdk.samples.ubc_joaquin_matres1 as m11 import ubcpdk.samples.ubc_helge as m12 +import ubcpdk.samples.ubc_joaquin_matres1 as m11 import ubcpdk.samples.ubc_simon as m13 +from ubcpdk.config import PATH def test_masks_2023_v1(): diff --git a/ubcpdk/samples/ubc_helge.py b/ubcpdk/samples/ubc_helge.py index 4147bfbd..7b714968 100644 --- a/ubcpdk/samples/ubc_helge.py +++ b/ubcpdk/samples/ubc_helge.py @@ -2,8 +2,8 @@ import ubcpdk import ubcpdk.components as pdk +from ubcpdk.samples.write_mask import pack, size, write_mask_gds_with_metadata from ubcpdk.tech import LAYER -from ubcpdk.samples.write_mask import write_mask_gds_with_metadata, pack, size add_gc = ubcpdk.components.add_fiber_array nm = 1e-3 diff --git a/ubcpdk/samples/ubc_joaquin_matres1.py b/ubcpdk/samples/ubc_joaquin_matres1.py index c495081b..0007b09b 100644 --- a/ubcpdk/samples/ubc_joaquin_matres1.py +++ b/ubcpdk/samples/ubc_joaquin_matres1.py @@ -4,11 +4,10 @@ import ubcpdk import ubcpdk.components as pdk - from ubcpdk import tech -from ubcpdk.tech import LAYER -from ubcpdk.samples.write_mask import write_mask_gds_with_metadata, add_gc, pack, size from ubcpdk.cutback_2x2 import cutback_2x2 +from ubcpdk.samples.write_mask import add_gc, pack, size, write_mask_gds_with_metadata +from ubcpdk.tech import LAYER def test_mask1(): diff --git a/ubcpdk/samples/ubc_simon.py b/ubcpdk/samples/ubc_simon.py index d885ef7b..91f34d64 100644 --- a/ubcpdk/samples/ubc_simon.py +++ b/ubcpdk/samples/ubc_simon.py @@ -1,20 +1,18 @@ """Sample mask for the edx course Q1 2023.""" -from typing import Optional, List - -import ubcpdk -import ubcpdk.components as pdk -from ubcpdk.tech import LAYER -from ubcpdk.samples.write_mask import write_mask_gds_with_metadata import gdsfactory as gf from gdsfactory.components.bend_euler import bend_euler from gdsfactory.components.coupler_ring import coupler_ring as _coupler_ring -from gdsfactory.components.via_stack import via_stack_heater_m3 from gdsfactory.components.straight import straight - +from gdsfactory.components.via_stack import via_stack_heater_m3 from gdsfactory.typings import ComponentSpec, CrossSectionSpec, Float2 +import ubcpdk +import ubcpdk.components as pdk +from ubcpdk.samples.write_mask import write_mask_gds_with_metadata +from ubcpdk.tech import LAYER + via_stack_heater_m3_mini = gf.partial(via_stack_heater_m3, size=(4, 4)) @@ -35,7 +33,7 @@ def ring_single_heater( cross_section_waveguide_heater: CrossSectionSpec = "strip_heater_metal", cross_section: CrossSectionSpec = "strip", via_stack: ComponentSpec = via_stack_heater_m3_mini, - port_orientation: Optional[List[float]] = (180, 0), + port_orientation: list[float] | None = (180, 0), via_stack_offset: Float2 = (0, 0), **kwargs, ) -> gf.Component: diff --git a/ubcpdk/samples/write_mask.py b/ubcpdk/samples/write_mask.py index e39050ad..8582479a 100644 --- a/ubcpdk/samples/write_mask.py +++ b/ubcpdk/samples/write_mask.py @@ -1,14 +1,13 @@ """Sample mask for the course.""" from functools import partial - -from typing import Tuple from pathlib import Path -from omegaconf import OmegaConf + import gdsfactory as gf +from omegaconf import OmegaConf import ubcpdk -from ubcpdk.tech import LAYER from ubcpdk.config import PATH +from ubcpdk.tech import LAYER size = (440, 470) add_gc = ubcpdk.components.add_fiber_array @@ -17,7 +16,7 @@ ) -def write_mask_gds_with_metadata(m) -> Tuple[Path, Path]: +def write_mask_gds_with_metadata(m) -> tuple[Path, Path]: """Returns""" gdspath = PATH.mask / f"{m.name}.gds" m.write_gds_with_metadata(gdspath=gdspath) diff --git a/ubcpdk/simulation/circuits/mzi_spectrum.py b/ubcpdk/simulation/circuits/mzi_spectrum.py index 6df7e88f..8a2d9b99 100644 --- a/ubcpdk/simulation/circuits/mzi_spectrum.py +++ b/ubcpdk/simulation/circuits/mzi_spectrum.py @@ -4,6 +4,7 @@ """ import numpy as np + from ubcpdk.simulation.circuits.waveguide import beta, neff, wavelength_um diff --git a/ubcpdk/simulation/modes_waveguide.py b/ubcpdk/simulation/modes_waveguide.py index 1526624b..6eff4bc4 100644 --- a/ubcpdk/simulation/modes_waveguide.py +++ b/ubcpdk/simulation/modes_waveguide.py @@ -2,8 +2,8 @@ import gdsfactory as gf import gplugins.modes as gm -from ubcpdk.config import PATH +from ubcpdk.config import PATH nm = 1e-3 diff --git a/ubcpdk/tech.py b/ubcpdk/tech.py index 56735a48..a4e2def0 100644 --- a/ubcpdk/tech.py +++ b/ubcpdk/tech.py @@ -7,14 +7,13 @@ import sys from functools import partial -from pydantic import BaseModel - import gdsfactory as gf -from gdsfactory.cross_section import get_cross_section_factories -from gdsfactory.technology import LayerStack, LayerLevel -from gdsfactory.typings import Layer, LayerSpec, Callable, LayerSpecs, Optional from gdsfactory.add_pins import add_pin_path from gdsfactory.component import Component +from gdsfactory.cross_section import get_cross_section_factories +from gdsfactory.technology import LayerLevel, LayerStack +from gdsfactory.typings import Callable, Layer, LayerSpec, LayerSpecs, Optional +from pydantic import BaseModel from ubcpdk.config import PATH