Skip to content

Commit

Permalink
Merge pull request #358 from gdsfactory/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
joamatab authored Mar 21, 2024
2 parents 6075f11 + 7784eb9 commit 3a3ee64
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.2"
rev: "v0.3.3"
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -26,7 +26,7 @@ repos:
# - id: shellcheck

- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
rev: 1.7.8
hooks:
- id: bandit
args: [--exit-zero]
Expand Down
1 change: 1 addition & 0 deletions gplugins/common/utils/add_simulation_markers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Returns component with simulation markers."""

from __future__ import annotations

import warnings
Expand Down
8 changes: 5 additions & 3 deletions gplugins/common/utils/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ async def handle_return(
append: bool = False,
) -> None:
"""Reads through a :class:`StreamReader` and tees content to ``out_stream`` and ``log_file``."""
with open(
log_file, "a" if append else "w", encoding="utf-8", buffering=1
) if log_file else nullcontext(None) as f:
with (
open(log_file, "a" if append else "w", encoding="utf-8", buffering=1)
if log_file
else nullcontext(None) as f
):
while True:
# Without this sleep, the program won't exit
await asyncio.sleep(0)
Expand Down
1 change: 1 addition & 0 deletions gplugins/common/utils/disable_print.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Disable print statements for overly verbose simulators."""

from __future__ import annotations

import os
Expand Down
6 changes: 3 additions & 3 deletions gplugins/common/utils/get_component_with_net_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def get_component_with_net_layers(
new_layers_init[0] + i,
new_layers_init[1] + j,
)
layer_stack.layers[
f"{old_layername}{delimiter}{portname}"
] = new_layer
layer_stack.layers[f"{old_layername}{delimiter}{portname}"] = (
new_layer
)
net_component.add_polygon(polygon, layer=new_layer_number)
# Otherwise put the polygon back on the same layer
else:
Expand Down
1 change: 1 addition & 0 deletions gplugins/common/utils/optical_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Useful optical constant manipulations."""

import numpy as np


Expand Down
1 change: 1 addition & 0 deletions gplugins/common/utils/parse_layer_stack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Preprocessing involving only the LayerStack."""

from __future__ import annotations

import numpy as np
Expand Down
5 changes: 2 additions & 3 deletions gplugins/devsim/get_simulation_xsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""


from __future__ import annotations

import warnings
Expand Down Expand Up @@ -57,8 +56,8 @@ def dn_carriers(wavelength: float, dN: float, dP: float) -> float:
else:
wavelength *= 1e-6
return (
-3.64 * 1e-10 * wavelength**2 * dN
- 3.51 * 1e-6 * wavelength**2 * np.power(dP, 0.8)
-3.64 * 1e-10 * wavelength** 2 * dN
- 3.51 * 1e-6 * wavelength** 2 * np.power(dP, 0.8)
)


Expand Down
12 changes: 6 additions & 6 deletions gplugins/femwell/solve_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ def get_thermal_conductivities(basis):
# adding the layer to the thermal_conductivities dict. Check for that
# case
if domain in thermal_conductivities:
thermal_conductivity[
basis.get_dofs(elements=domain)
] = thermal_conductivities[domain]
thermal_conductivity[basis.get_dofs(elements=domain)] = (
thermal_conductivities[domain]
)
else:
for material, labels in materials_dict.items():
if domain in labels:
# Assign the right values
thermal_conductivity[
basis.get_dofs(elements=domain)
] = thermal_conductivities[material]
thermal_conductivity[basis.get_dofs(elements=domain)] = (
thermal_conductivities[material]
)
break

thermal_conductivity *= 1e-12 # 1e-12 -> conversion from 1/m^2 -> 1/um^2
Expand Down
1 change: 1 addition & 0 deletions gplugins/gmeep/get_simulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Returns simulation from component."""

from __future__ import annotations

import inspect
Expand Down
1 change: 1 addition & 0 deletions gplugins/gmeep/get_simulation_grating_farfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- add tests
"""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions gplugins/gmeep/write_sparameters_grating.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 9.2 for Oband
"""

from __future__ import annotations

import hashlib
Expand Down
39 changes: 20 additions & 19 deletions gplugins/gmsh/parse_component.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Preprocessing involving both the GDS and the LayerStack, or the resulting simulation polygons."""

from __future__ import annotations

import numpy as np
Expand Down Expand Up @@ -75,32 +76,32 @@ def process_buffers(layer_polygons_dict: dict, layer_stack: LayerStack):
layer_stack.layers[layername].thickness * zs[z_ind + 1]
- layer_stack.layers[layername].thickness * z
)
extended_layer_stack_layers[
f"{layername}_{poly_ind}_{z}"
] = LayerLevel(
layer=layer_stack.layers[layername].layer,
thickness=new_thickness,
zmin=new_zmin,
material=layer_stack.layers[layername].material,
info=layer_stack.layers[layername].info,
mesh_order=layer_stack.layers[layername].mesh_order,
extended_layer_stack_layers[f"{layername}_{poly_ind}_{z}"] = (
LayerLevel(
layer=layer_stack.layers[layername].layer,
thickness=new_thickness,
zmin=new_zmin,
material=layer_stack.layers[layername].material,
info=layer_stack.layers[layername].info,
mesh_order=layer_stack.layers[layername].mesh_order,
)
)
extended_layer_polygons_dict[f"{layername}_{poly_ind}_{z}"] = (
f"{layername}",
f"{layername}_{poly_ind}_{zs[z_ind+1]}",
polygon.buffer(width_buffer),
polygon.buffer(width_buffers[z_ind + 1]),
)
extended_layer_stack_layers[
f"{layername}_{poly_ind}_{zs[-1]}"
] = LayerLevel(
layer=layer_stack.layers[layername].layer,
thickness=0,
zmin=layer_stack.layers[layername].zmin
+ layer_stack.layers[layername].thickness,
material=layer_stack.layers[layername].material,
info=layer_stack.layers[layername].info,
mesh_order=layer_stack.layers[layername].mesh_order,
extended_layer_stack_layers[f"{layername}_{poly_ind}_{zs[-1]}"] = (
LayerLevel(
layer=layer_stack.layers[layername].layer,
thickness=0,
zmin=layer_stack.layers[layername].zmin
+ layer_stack.layers[layername].thickness,
material=layer_stack.layers[layername].material,
info=layer_stack.layers[layername].info,
mesh_order=layer_stack.layers[layername].mesh_order,
)
)
return extended_layer_polygons_dict, LayerStack(layers=extended_layer_stack_layers)

Expand Down
1 change: 1 addition & 0 deletions gplugins/gmsh/parse_gds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Preprocessing involving mostly the GDS polygons."""

from __future__ import annotations

import gdsfactory as gf
Expand Down
1 change: 1 addition & 0 deletions gplugins/klayout/drc/samples/drc_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Write GDS with sample errors."""

from __future__ import annotations

import gdsfactory as gf
Expand Down
1 change: 1 addition & 0 deletions gplugins/lumerical/write_sparameters_lumerical.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Write Sparameters with Lumerical FDTD."""

from __future__ import annotations

import shutil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Write Sparameters with for different components."""

from __future__ import annotations

import gdsfactory as gf
Expand Down
1 change: 1 addition & 0 deletions gplugins/modes/find_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1/1.5 = 0.6667.
"""

import json
import pathlib
import pickle
Expand Down
1 change: 1 addition & 0 deletions gplugins/modes/find_modes_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1/1.5 = 0.6667.
"""

from __future__ import annotations

import pathlib
Expand Down
1 change: 1 addition & 0 deletions gplugins/modes/neff_convergence_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
hyperparameters that allowed convergence.
"""

from __future__ import annotations

import meep as mp
Expand Down
1 change: 1 addition & 0 deletions gplugins/process/implant_tables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Reference: Selberherr, S. (1984). Process Modeling. In: Analysis and Simulation of Semiconductor Devices. Springer, Vienna. https://doi.org/10.1007/978-3-7091-8752-4_3
"""

from pathlib import Path

import numpy as np
Expand Down
4 changes: 1 addition & 3 deletions gplugins/process/pysrim.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def run_fragmented_calculation(

for i, num_ions in enumerate(fragment(step, number_ions)):
print(
"total ions completed: {:06d}\tion: {}\tions in step: {:06d}".format(
i * step, ion.symbol, num_ions
)
f"total ions completed: {i * step:06d}\tion: {ion.symbol}\tions in step: {num_ions:06d}"
)
trim_settings = trim_settings or {"calculation": 2}
trim = TRIM(target, ion, number_ions=num_ions, **trim_settings)
Expand Down
1 change: 1 addition & 0 deletions gplugins/process/silicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Material class
Pint for units
"""

import numpy as np

kB = 1.380649e-23 # m2 kg s-2 K-1, boltzmann constant
Expand Down
1 change: 1 addition & 0 deletions gplugins/sax/read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""read Sparameters from CSV file and returns sax model."""

from __future__ import annotations

import pathlib
Expand Down
1 change: 1 addition & 0 deletions gplugins/sax/tests/test_mzi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Demo of non-hierarchical circuit simulations."""

from __future__ import annotations

import gdsfactory as gf
Expand Down
1 change: 1 addition & 0 deletions gplugins/sax/tests/test_mzi_lattice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test hierarchical circuit simulations."""

from __future__ import annotations

import gdsfactory as gf
Expand Down
16 changes: 8 additions & 8 deletions gplugins/tidy3d/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,14 @@ def write_sparameters(
for port_out in s.port_out.values:
for mode_index_in in s.mode_index_in.values:
for mode_index_out in s.mode_index_out.values:
sp[
f"{port_in}@{mode_index_in},{port_out}@{mode_index_out}"
] = s.sel(
port_in=port_in,
port_out=port_out,
mode_index_in=mode_index_in,
mode_index_out=mode_index_out,
).values
sp[f"{port_in}@{mode_index_in},{port_out}@{mode_index_out}"] = (
s.sel(
port_in=port_in,
port_out=port_out,
mode_index_in=mode_index_in,
mode_index_out=mode_index_out,
).values
)

frequency = s.f.values
sp["wavelengths"] = td.constants.C_0 / frequency
Expand Down
1 change: 1 addition & 0 deletions gplugins/tidy3d/get_simulation_grating_coupler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Returns tidy3d simulation from gdsfactory Component."""

from __future__ import annotations

import warnings
Expand Down

0 comments on commit 3a3ee64

Please sign in to comment.