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

Gdsfactory8 #413

Merged
merged 38 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4ddb072
fix notebooks
joamatab May 30, 2024
91c66ca
refactor logger
joamatab Jun 1, 2024
a1d09da
towards gdsfactory8
joamatab Jun 1, 2024
14abc4d
refactor
joamatab Jun 3, 2024
f1a18d4
port to gdsfactory8
joamatab Jun 3, 2024
7614eba
create a new component for mesh
joamatab Jun 4, 2024
f11ba95
add ipywidgets
joamatab Jun 8, 2024
7172347
bring schematic_editor files
joamatab Jun 8, 2024
457f3f4
fix klayout tests
joamatab Jun 8, 2024
17593f4
install gdsfactory from main
joamatab Jun 8, 2024
cac4b49
install latest gdsfactory
joamatab Jun 8, 2024
c2e607e
fix more klayout tests
joamatab Jun 8, 2024
c33cb4c
fix some sax tests
joamatab Jun 8, 2024
4716db3
updating elements
joamatab Jun 9, 2024
c018ae6
pin version of klayout
joamatab Jun 9, 2024
d7a9b50
Merge branch 'main' into gdsfactory8
simbilod Jun 9, 2024
347683e
convert KLayout region to shapely MultiPolygon
simbilod Jun 9, 2024
c925720
disactivate component with net layers
simbilod Jun 9, 2024
340efd5
use logicallayer
simbilod Jun 9, 2024
6c4d478
go from klayout units to microns
simbilod Jun 9, 2024
4854feb
last fixes
simbilod Jun 9, 2024
41f6574
fixing meep plugin paths
joamatab Jun 10, 2024
9b6c19c
fix sax tests
joamatab Jun 10, 2024
7e74a19
fixing meow
joamatab Jun 10, 2024
aa440f0
fixing tidy3d plugin
joamatab Jun 11, 2024
38d4d03
Merge branch 'main' into gdsfactory8
joamatab Jun 11, 2024
18b5844
fix test_global_density
joamatab Jun 11, 2024
0254c25
Merge branch 'gdsfactory8' of github.com:gdsfactory/gplugins into gds…
joamatab Jun 11, 2024
4bcb85a
fixing meow
joamatab Jun 11, 2024
5feefe3
Fixes for tidy3d plugin. ComponentModeler setup looks correct now, po…
yaugenst Jun 11, 2024
097819a
Merge pull request #421 from gdsfactory/tidy3d_fixes
joamatab Jun 11, 2024
0a86477
fix more tests
joamatab Jun 11, 2024
587859a
Merge branch 'gdsfactory8' of github.com:gdsfactory/gplugins into gds…
joamatab Jun 11, 2024
bae8c37
fix mode_solver femwell
joamatab Jun 11, 2024
7f6e813
fix test grating coupler
joamatab Jun 13, 2024
c044dd6
fix some errors from dbu
joamatab Jun 13, 2024
608e49f
update sax
joamatab Jun 18, 2024
864812d
Merge branch 'main' into gdsfactory8
joamatab Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gplugins/common/utils/add_simulation_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def add_simulation_markers(

if port_source_name not in port_names:
warnings.warn(f"port_source_name={port_source_name!r} not in {port_names}")
port_source = ref.get_ports_list()[0]
port_source = ref.ports[0]
port_source_name = port_source.name
warnings.warn(f"Selecting port_source_name={port_source_name!r} instead.")

Expand Down
2 changes: 1 addition & 1 deletion gplugins/devsim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import devsim as tcad
from gdsfactory.config import logger
from gdsfactory import logger

from gplugins.devsim.get_simulation_xsection import (
PINWaveguide,
Expand Down
2 changes: 1 addition & 1 deletion gplugins/fdtdz/get_epsilon_fdtdz.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def add_plot_labels(arg0, arg1, arg2, arg3):
padding = c << gf.components.bbox(
waveguide.bbox, top=2, bottom=2, layer=LAYER.WAFER
)
c.add_ports(gf.components.straight(length=length).get_ports_list())
c.add_ports(gf.components.straight(length=length).ports)

filtered_layer_stack = LayerStack(
layers={k: LAYER_STACK.layers[k] for k in ["clad", "box", "core"]}
Expand Down
2 changes: 1 addition & 1 deletion gplugins/fdtdz/get_ports_fdtdz.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def plot_mode(
padding = c << gf.components.bbox(
waveguide.bbox, top=2, bottom=2, layer=LAYER.WAFER
)
c.add_ports(gf.components.straight(length=length).get_ports_list())
c.add_ports(gf.components.straight(length=length).ports)

filtered_layer_stack = LayerStack(
layers={k: LAYER_STACK.layers[k] for k in ["clad", "box", "core"]}
Expand Down
2 changes: 1 addition & 1 deletion gplugins/fdtdz/get_sparameters_fdtdz.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get_sparameters_fdtdz(
padding = c << gf.components.bbox(
waveguide.bbox, top=2, bottom=2, layer=LAYER.WAFER
)
c.add_ports(gf.components.straight(length=length).get_ports_list())
c.add_ports(gf.components.straight(length=length).ports)

filtered_layer_stack = LayerStack(
layers={k: LAYER_STACK.layers[k] for k in ["clad", "box", "core"]}
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
print("You need to 'conda install -c conda-forge pymeep=*=mpi_mpich_* nlopt -y'")
raise e

from gdsfactory.config import logger
from gdsfactory import logger

from gplugins.common.utils import plot, port_symmetries
from gplugins.common.utils.get_sparameters_path import get_sparameters_data_meep
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/get_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_simulation(

if port_source_name not in port_names:
warnings.warn(f"port_source_name={port_source_name!r} not in {port_names}")
port_source = component_ref.get_ports_list()[0]
port_source = component_ref.ports[0]
port_source_name = port_source.name
warnings.warn(f"Selecting port_source_name={port_source_name!r} instead.")

Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/write_sparameters_grating.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import meep as mp
import numpy as np
import yaml
from gdsfactory.config import logger, sparameters_path
from gdsfactory import logger, sparameters_path
from gdsfactory.serialization import clean_value_json, clean_value_name
from gdsfactory.typings import PathType

Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/write_sparameters_meep.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import numpy as np
import pydantic
import yaml
from gdsfactory import logger
from gdsfactory.component import Component
from gdsfactory.config import logger
from gdsfactory.pdk import get_layer_stack
from gdsfactory.serialization import clean_value_json
from gdsfactory.technology import LayerStack
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/write_sparameters_meep_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import gdsfactory as gf
import numpy as np
import pydantic
from gdsfactory import logger, sparameters_path
from gdsfactory.component import Component
from gdsfactory.config import logger, sparameters_path
from gdsfactory.pdk import get_layer_stack
from gdsfactory.technology import LayerStack
from tqdm.auto import tqdm
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmeep/write_sparameters_meep_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

import gdsfactory as gf
import pydantic
from gdsfactory import logger, sparameters_path
from gdsfactory.component import Component
from gdsfactory.config import logger, sparameters_path
from gdsfactory.pdk import get_layer_stack
from gdsfactory.technology import LayerStack
from gdsfactory.typings import ComponentSpec, PathType
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmsh/get_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_mesh(
[xmin - wafer_padding, ymax + wafer_padding],
]
padded_component.add_polygon(points, layer=wafer_layer)
padded_component.add_ports(component.get_ports_list())
padded_component.add_ports(component.ports)

# Parse the resolutions dict to set default size_max
if "resolutions" in kwargs:
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmsh/tests/test_meshing_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_gmsh_xyz_mesh() -> None:
# Choose some component
c = gf.component.Component()
waveguide = c << gf.get_component(gf.components.straight_heater_metal(length=40))
c.add_ports(waveguide.get_ports_list())
c.add_ports(waveguide.ports)

# Add wafer / vacuum (could be automated)
_ = c << gf.components.bbox(bbox=waveguide.bbox, layer=LAYER.WAFER)
Expand Down
6 changes: 2 additions & 4 deletions gplugins/gmsh/xy_xsection_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
from gdsfactory.config import get_number_of_cores
from gdsfactory.geometry.union import union
from gdsfactory.technology import LayerLevel, LayerStack
from gdsfactory.typings import ComponentOrReference
from meshwell.model import Model
Expand Down Expand Up @@ -106,9 +105,8 @@ def xy_xsection_mesh(
layer_port_delimiter: Delimiter to use for new layers generated for ports: "layer{delimiter}port_name".
"""
if port_names:
mesh_component = gf.Component()
_ = mesh_component << union(component, by_layer=True)
mesh_component.add_ports(component.get_ports_list())
mesh_component = component
mesh_component.add_ports(component.ports)
component = get_component_with_net_layers(
component=mesh_component,
port_names=port_names,
Expand Down
18 changes: 7 additions & 11 deletions gplugins/gmsh/xyz_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import gdsfactory as gf
import numpy as np
from gdsfactory.config import get_number_of_cores
from gdsfactory.geometry.union import union
from gdsfactory.technology import LayerLevel, LayerStack
from gdsfactory.typings import ComponentOrReference, List
from meshwell.gmsh_entity import GMSH_entity
Expand Down Expand Up @@ -126,9 +125,7 @@ def define_prisms(
physical_name=layer_physical_map[layername]
if layername in layer_physical_map
else layername,
mesh_bool=layer_meshbool_map[layername]
if layername in layer_meshbool_map
else True,
mesh_bool=layer_meshbool_map.get(layername, True),
)
)

Expand Down Expand Up @@ -200,9 +197,8 @@ def xyz_mesh(
background_remeshing_file: .pos file to use as a remeshing field. Overrides resolutions if not None.
"""
if port_names:
mesh_component = gf.Component()
_ = mesh_component << union(component, by_layer=True)
mesh_component.add_ports(component.get_ports_list())
mesh_component = component
mesh_component.add_ports(component.ports)
component = get_component_with_net_layers(
component=mesh_component,
port_names=port_names,
Expand Down Expand Up @@ -280,9 +276,9 @@ def xyz_mesh(

# Add edgeports
if edge_ports is not None:
ports = component.get_ports_dict()
ports = component.ports
port_layernames = layer_stack.get_layer_to_layername()
for portname, edge_ports_dict in edge_ports.items():
for portname, edge_ports_dict in edge_ports:
port = ports[portname]
prisms_list.append(
define_edgeport(
Expand Down Expand Up @@ -324,11 +320,11 @@ def xyz_mesh(
# Choose some component
c = gf.component.Component()
waveguide = c << gf.get_component(gf.components.straight(length=40))
c.add_ports(waveguide.get_ports_list())
c.add_ports(waveguide.ports)

# Add wafer / vacuum (could be automated)
wafer = c << gf.components.bbox(
bbox=waveguide.bbox,
waveguide,
layer=LAYER.WAFER,
top=3,
bottom=3,
Expand Down
2 changes: 1 addition & 1 deletion gplugins/klayout/netlist_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import klayout.db as kdb
import networkx as nx
from gdsfactory.config import logger
from gdsfactory import logger
from gdsfactory.typings import PathType

import gplugins.vlsir
Expand Down
2 changes: 1 addition & 1 deletion gplugins/lumerical/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import gdsfactory as gf
import numpy as np
from gdsfactory import logger
from gdsfactory.component import Component
from gdsfactory.config import logger
from gdsfactory.generic_tech import LAYER_STACK
from gdsfactory.technology import LayerStack

Expand Down
3 changes: 2 additions & 1 deletion gplugins/meow/meow_eme.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import pandas as pd
import sax
import yaml
from gdsfactory.config import PATH, logger
from gdsfactory import logger
from gdsfactory.config import PATH
from gdsfactory.generic_tech import LAYER
from gdsfactory.pdk import get_active_pdk, get_layer_stack
from gdsfactory.technology import LayerStack
Expand Down
35 changes: 19 additions & 16 deletions gplugins/path_length_analysis/path_length_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ def idealized_mxn_connectivity(
Returns:
None (graph is modified in-place)
"""
warnings.warn(f"using idealized links for {inst_name} ({ref.parent.name})")
warnings.warn(f"using idealized links for {inst_name} ({ref.parent_cell.name})")
in_ports = [p for p in ref.ports if p.startswith("in")]
out_ports = [p for p in ref.ports if p.startswith("out")]
for in_port in in_ports:
for out_port in out_ports:
inst_in = f"{inst_name},{in_port}"
inst_out = f"{inst_name},{out_port}"
g.add_edge(inst_in, inst_out, weight=0.0001, component=ref.parent.name)
g.add_edge(inst_in, inst_out, weight=0.0001, component=ref.parent_cell.name)


def _get_edge_based_route_attr_graph(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Low code quality found in _get_edge_based_route_attr_graph - 10% (low-code-quality)


ExplanationThe quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

Expand All @@ -245,15 +245,16 @@ def _get_edge_based_route_attr_graph(
inst_refs = {}

for inst_name in netlist["instances"]:
ref = component.named_references[inst_name]
ref = component.insts[inst_name]
inst_refs[inst_name] = ref
info = ref.parent.info.model_dump()
info = ref.parent_cell.info.model_dump()
if "route_info_length" in info:
inst_route_attrs[inst_name] = dict()
inst_route_attrs[inst_name] = {}
for key, value in info.items():
if key.startswith("route_info"):
inst_route_attrs[inst_name].update({key: value})
for port_name, port in ref.ports.items():
for port in ref.ports:
port_name = port.name
ploc = port.center
pname = f"{inst_name},{port_name}"
n_attrs = {
Expand All @@ -269,7 +270,7 @@ def _get_edge_based_route_attr_graph(
# currently we only do this for routing components, but could do it more generally in the future
for inst_name, inst_dict in netlist["instances"].items():
route_info = inst_route_attrs.get(inst_name)
inst_component = component.named_references[inst_name]
inst_component = component.insts[inst_name]
route_attrs = get_internal_netlist_attributes(
inst_dict, route_info, inst_component
)
Expand All @@ -281,10 +282,10 @@ def _get_edge_based_route_attr_graph(
g.add_edge(inst_in, inst_out, **attrs)
elif recursive:
sub_inst = inst_refs[inst_name]
if sub_inst.parent.name in netlists:
sub_netlist = netlists[sub_inst.parent.name]
if sub_inst.parent_cell.name in netlists:
sub_netlist = netlists[sub_inst.parent_cell.name]
sub_graph = _get_edge_based_route_attr_graph(
sub_inst.parent,
sub_inst.parent_cell,
recursive=True,
component_connectivity=component_connectivity,
netlist=sub_netlist,
Expand Down Expand Up @@ -321,13 +322,14 @@ def _get_edge_based_route_attr_graph(
component_connectivity(inst_name, sub_inst, g)
else:
warnings.warn(
f"ignoring any links in {inst_name} ({sub_inst.parent.name})"
f"ignoring any links in {inst_name} ({sub_inst.parent_cell.name})"
)

# connect all top level ports
if top_level_ports:
edges = []
for port, sub_port in top_level_ports.items():
for sub_port in top_level_ports:
port = sub_port.name
p_attrs = dict(node_attrs[sub_port])
e_attrs = {"weight": 0.0001}
edge = [port, sub_port, e_attrs]
Expand Down Expand Up @@ -401,13 +403,14 @@ def get_pathlength_widgets(
cs_colors = DEFAULT_CS_COLORS
for node, data in G.nodes(data=True):
node_positions[node] = (data["x"], data["y"])
instances = pic.named_references
for inst_name, ref in instances.items():
ref: ComponentReference
instances = pic.insts.get_inst_names()
for inst_name in instances:
ref = pic.insts[inst_name]
inst_info = {"bbox": ref.bbox}
inst_infos[inst_name] = inst_info
pic_bbox = pic.bbox
for port_name, port in pic.ports.items():
for port in pic.ports:
port_name = port.name
p = port.center
node_positions[port_name] = (p[0], p[1])

Expand Down
3 changes: 2 additions & 1 deletion gplugins/tidy3d/get_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

import gdsfactory as gf
import tidy3d as td
from gdsfactory.config import PATH, logger
from gdsfactory import logger
from gdsfactory.config import PATH
from gdsfactory.typings import PathType
from tidy3d import web
from tidy3d.exceptions import WebError
Expand Down
4 changes: 2 additions & 2 deletions gplugins/tidy3d/get_simulation_grating_coupler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import matplotlib.pyplot as plt
import numpy as np
import tidy3d as td
from gdsfactory import logger
from gdsfactory.add_padding import add_padding_container
from gdsfactory.component import Component
from gdsfactory.components.extension import move_polar_rad_copy
from gdsfactory.config import logger
from gdsfactory.pdk import get_layer_stack
from gdsfactory.technology import LayerStack
from gdsfactory.typings import CrossSectionSpec
Expand Down Expand Up @@ -247,7 +247,7 @@ def get_simulation_grating_coupler(
warnings.warn(
f"port_waveguide_name={port_waveguide_name!r} not in {component.ports.keys()}"
)
port_waveguide = component.get_ports_list()[0]
port_waveguide = component.ports[0]
port_waveguide_name = port_waveguide.name
warnings.warn(f"Selecting port_waveguide_name={port_waveguide_name!r} instead.")

Expand Down
3 changes: 2 additions & 1 deletion gplugins/tidy3d/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import pydantic.v1 as pydantic
import tidy3d as td
import xarray
from gdsfactory.config import PATH, logger
from gdsfactory import logger
from gdsfactory.config import PATH
from gdsfactory.typings import PathType
from pydantic.v1 import BaseModel
from tidy3d.plugins import waveguide
Expand Down
2 changes: 1 addition & 1 deletion gplugins/tidy3d/write_sparameters_grating_coupler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import tidy3d as td
import yaml
from gdsfactory.config import logger
from gdsfactory import logger
from gdsfactory.serialization import clean_value_json
from gdsfactory.typings import (
Any,
Expand Down
10 changes: 9 additions & 1 deletion notebooks/11_get_netlist_spice.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"from gplugins.klayout.plot_nets import plot_nets\n",
"from gplugins.klayout.netlist_spice_reader import (\n",
" GdsfactorySpiceReader,\n",
")\n"
")"
]
},
{
Expand Down Expand Up @@ -153,6 +153,14 @@
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "13",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading
Loading