Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Jan 2, 2023
1 parent 9638927 commit 205c958
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 42 deletions.
4 changes: 2 additions & 2 deletions gdsfactory/circuitviz.py
Expand Up @@ -401,10 +401,10 @@ def viz_instance(
}

for layer, polys in polys_by_layer.items():
xs = [[p.points[:, 0]] for p in polys]
ys = [[p.points[:, 1]] for p in polys]
color_info = colors_by_ldt.get(layer)
if color_info:
xs = [[p.points[:, 0]] for p in polys]
ys = [[p.points[:, 1]] for p in polys]
lp = LayerPolygons(
tag=instance_name,
xs=xs,
Expand Down
6 changes: 1 addition & 5 deletions gdsfactory/read/from_yaml.py
Expand Up @@ -599,11 +599,7 @@ def from_yaml(

settings = conf.get("settings", {})

if "mode" in kwargs:
mode = kwargs.pop("mode")
else:
mode = "layout"

mode = kwargs.pop("mode") if "mode" in kwargs else "layout"
for key, value in kwargs.items():
if key not in settings:
raise ValueError(f"{key!r} not in {settings.keys()}")
Expand Down
4 changes: 1 addition & 3 deletions gdsfactory/simulation/eme/meow_eme.py
Expand Up @@ -335,7 +335,7 @@ def compute_sparameters(self) -> Dict[str, np.ndarray]:
if not self.overwrite:
logger.info(f"Simulation loaded from {self.filepath!r}")
return dict(np.load(self.filepath))
elif self.overwrite:
else:
self.filepath.unlink()

start = time.time()
Expand Down Expand Up @@ -373,8 +373,6 @@ def compute_sparameters(self) -> Dict[str, np.ndarray]:

return sp

return sp


if __name__ == "__main__":
c = gf.components.taper(length=10, width2=2)
Expand Down
17 changes: 7 additions & 10 deletions gdsfactory/simulation/fem/mode_solver.py
Expand Up @@ -67,7 +67,7 @@ def compute_cross_section_modes(
epsilon[basis0.get_dofs(elements=layername)] = (
_ACTIVE_PDK.materials_index[layer.material](wl) ** 2
)
if "background_tag" in kwargs.keys():
if "background_tag" in kwargs:
epsilon[basis0.get_dofs(elements=kwargs["background_tag"])] = (
_ACTIVE_PDK.materials_index[kwargs["background_tag"]](wl) ** 2
)
Expand All @@ -85,9 +85,6 @@ def compute_cross_section_modes(

return lams, basis, xs

def plot_cross_section_modes():
return True


if __name__ == "__main__":
filtered_layerstack = LayerStack(
Expand All @@ -104,12 +101,12 @@ def plot_cross_section_modes():

filtered_layerstack.layers["core"].thickness = 0.2

resolutions = {}
resolutions["core"] = {"resolution": 0.02, "distance": 2}
resolutions["clad"] = {"resolution": 0.2, "distance": 1}
resolutions["box"] = {"resolution": 0.2, "distance": 1}
resolutions["slab90"] = {"resolution": 0.05, "distance": 1}

resolutions = {
"core": {"resolution": 0.02, "distance": 2},
"clad": {"resolution": 0.2, "distance": 1},
"box": {"resolution": 0.2, "distance": 1},
"slab90": {"resolution": 0.05, "distance": 1},
}
compute_cross_section_modes(
cross_section="rib",
layerstack=filtered_layerstack,
Expand Down
12 changes: 6 additions & 6 deletions gdsfactory/simulation/fem/test_mode_solver.py
Expand Up @@ -20,12 +20,12 @@ def test_compute_cross_section_mode():

filtered_layerstack.layers["core"].thickness = 0.2

resolutions = {}
resolutions["core"] = {"resolution": 0.02, "distance": 2}
resolutions["clad"] = {"resolution": 0.2, "distance": 1}
resolutions["box"] = {"resolution": 0.2, "distance": 1}
resolutions["slab90"] = {"resolution": 0.05, "distance": 1}

resolutions = {
"core": {"resolution": 0.02, "distance": 2},
"clad": {"resolution": 0.2, "distance": 1},
"box": {"resolution": 0.2, "distance": 1},
"slab90": {"resolution": 0.05, "distance": 1},
}
lams, basis, xs = compute_cross_section_modes(
cross_section="rib",
layerstack=filtered_layerstack,
Expand Down
20 changes: 9 additions & 11 deletions gdsfactory/simulation/gmsh/tests/test_meshing.py
Expand Up @@ -22,19 +22,18 @@ def test_gmsh_uz_xsection_mesh():
}
)

resolutions = {}
resolutions["core"] = {"resolution": 0.05, "distance": 2}
resolutions["slab90"] = {"resolution": 0.03, "distance": 1}
resolutions["via_contact"] = {"resolution": 0.1, "distance": 1}

resolutions = {
"core": {"resolution": 0.05, "distance": 2},
"slab90": {"resolution": 0.03, "distance": 1},
"via_contact": {"resolution": 0.1, "distance": 1},
}
uz_xsection_mesh(
waveguide,
[(4, -15), (4, 15)],
filtered_layerstack,
resolutions=resolutions,
background_tag="Oxide",
)
assert True


def test_gmsh_xy_xsection_mesh():
Expand All @@ -56,15 +55,14 @@ def test_gmsh_xy_xsection_mesh():
}
)

resolutions = {}
resolutions["core"] = {"resolution": 0.05, "distance": 0.1}
resolutions["via_contact"] = {"resolution": 0.1, "distance": 0}

resolutions = {
"core": {"resolution": 0.05, "distance": 0.1},
"via_contact": {"resolution": 0.1, "distance": 0},
}
xy_xsection_mesh(
component=waveguide,
z=0.09,
layerstack=filtered_layerstack,
resolutions=resolutions,
background_tag="Oxide",
)
assert True
6 changes: 3 additions & 3 deletions gdsfactory/technology/layer_views.py
Expand Up @@ -213,9 +213,9 @@ def _build_xml_element(self, tag: str, name: str) -> ET.Element:
"marked": str(self.marked).lower(),
"xfill": str(self.xfill).lower(),
"animation": self.animation,
"name": name
if not self.layer_in_name
else f"{name} {self.layer[0]}/{self.layer[1]}",
"name": f"{name} {self.layer[0]}/{self.layer[1]}"
if self.layer_in_name
else name,
"source": f"{self.layer[0]}/{self.layer[1]}@1"
if self.layer is not None
else "*/*@*",
Expand Down
4 changes: 2 additions & 2 deletions gdsfactory/tests/test_klayout/test_klayout_tech.py
Expand Up @@ -14,9 +14,9 @@ def test_klayout_tech_create(
data_regression: DataRegressionFixture, check: bool = True
) -> None:

lyp = LayerDisplayProperties.from_lyp(str(PATH.klayout_lyp))

if check:
lyp = LayerDisplayProperties.from_lyp(str(PATH.klayout_lyp))

data_regression.check(lyp.dict())


Expand Down

0 comments on commit 205c958

Please sign in to comment.