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

[pre-commit.ci] pre-commit autoupdate #537

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.6"
rev: "v0.9.1"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -28,7 +28,7 @@ repos:
# - id: shellcheck

- repo: https://github.com/PyCQA/bandit
rev: 1.8.0
rev: 1.8.2
hooks:
- id: bandit
args: [--exit-zero]
Expand Down Expand Up @@ -61,6 +61,6 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.14
rev: 0.5.18
hooks:
- id: uv-lock
6 changes: 3 additions & 3 deletions gplugins/common/utils/add_simulation_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def add_simulation_markers(
port_source_name = port_source.name
warnings.warn(f"Selecting port_source_name={port_source_name!r} instead.")

assert isinstance(
component, Component
), f"component needs to be a gf.Component, got Type {type(component)}"
assert isinstance(component, Component), (
f"component needs to be a gf.Component, got Type {type(component)}"
)

# Add port monitors
for port_name in port_names:
Expand Down
6 changes: 3 additions & 3 deletions gplugins/common/utils/convert_sparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def pandas_to_numpy(df: pd.DataFrame, port_map=None) -> np.ndarray:
if port_map is None:
port_map = {f"o{i}@0": i for i in idxs}
rev_port_map = {i: p for p, i in port_map.items()}
assert len(rev_port_map) == len(
port_map
), "Duplicate port indices found in port_map"
assert len(rev_port_map) == len(port_map), (
"Duplicate port indices found in port_map"
)

s_map = {
s: tuple(rev_port_map[i] for i in _s_header_to_port_idxs(s)) for s in s_headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def test_component_with_new_port_layers() -> None:
layernames_after = set(layer_stack.layers.keys())

# Check we have two new layers in the LayerStack
assert (
len(layernames_after - layernames_before) == 2
), "Two new layers should be added to the LayerStack"
assert len(layernames_after - layernames_before) == 2, (
"Two new layers should be added to the LayerStack"
)

# Check we have one new layer in Component (all metal3 is removed by these operations)
# assert len(new_component.get_layers()) == len(original_component.get_layers()) + 1
Expand Down
4 changes: 2 additions & 2 deletions gplugins/devsim/get_simulation_xsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def set_net_doping(self, device) -> None:
device,
"slab",
"Acceptors",
f"{self.p_conc:1.3e}*step({-1*self.p_offset / cm:1.3e}-x) + {self.ppp_conc:1.3e}*step({self.xppp / cm:1.3e}-x)",
f"{self.p_conc:1.3e}*step({-1 * self.p_offset / cm:1.3e}-x) + {self.ppp_conc:1.3e}*step({self.xppp / cm:1.3e}-x)",
)
model_create.CreateNodeModel(
device,
Expand All @@ -319,7 +319,7 @@ def set_net_doping(self, device) -> None:
device,
"core",
"Acceptors",
f"{self.p_conc:1.1e}*step({-1*self.p_offset / cm:1.6e}-x)",
f"{self.p_conc:1.1e}*step({-1 * self.p_offset / cm:1.6e}-x)",
)
model_create.CreateNodeModel(
device,
Expand Down
2 changes: 1 addition & 1 deletion gplugins/elmer/get_capacitance.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def _read_elmer_results(
field_file_location=simulation_folder
/ raw_name
/ "results"
/ f'{raw_name}_t0001.{"pvtu" if n_processes > 1 else "vtu"}',
/ f"{raw_name}_t0001.{'pvtu' if n_processes > 1 else 'vtu'}",
)
),
)
Expand Down
6 changes: 3 additions & 3 deletions gplugins/fdtdz/get_sparameters_fdtdz.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def get_sparameters_fdtdz(

optical_port_names = list(component_ref.get_ports_dict(port_type="optical").keys())

assert isinstance(
component, Component
), f"component needs to be a gf.Component, got Type {type(component)}"
assert isinstance(component, Component), (
f"component needs to be a gf.Component, got Type {type(component)}"
)

component_extended = (
gf.components.extension.extend_ports(
Expand Down
6 changes: 3 additions & 3 deletions gplugins/gmeep/get_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def get_simulation(
port_source_name = port_source.name
warnings.warn(f"Selecting port_source_name={port_source_name!r} instead.")

assert isinstance(
component, Component
), f"component needs to be a gf.Component, got Type {type(component)}"
assert isinstance(component, Component), (
f"component needs to be a gf.Component, got Type {type(component)}"
)

component_extended = (
gf.c.extend_ports(
Expand Down
2 changes: 1 addition & 1 deletion gplugins/gmsh/parse_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def process_buffers(layer_polygons_dict: dict, layer_stack: LayerStack):
)
extended_layer_polygons_dict[f"{layername}_{poly_ind}_{z}"] = (
f"{layername}",
f"{layername}_{poly_ind}_{zs[z_ind+1]}",
f"{layername}_{poly_ind}_{zs[z_ind + 1]}",
polygon.buffer(width_buffer),
polygon.buffer(width_buffers[z_ind + 1]),
)
Expand Down
2 changes: 1 addition & 1 deletion gplugins/klayout/drc/write_drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def check_not_inside(
"""
if size is None:
error = f"{layer} not inside {not_inside}"
return f"{layer}.not_inside({not_inside})" f".output({error!r}, {error!r})"
return f"{layer}.not_inside({not_inside}).output({error!r}, {error!r})"
else:
error = f"{layer} sized by {size} not inside {not_inside}"
script = f"{layer}_sized = {layer}.size({size})\n "
Expand Down
6 changes: 3 additions & 3 deletions gplugins/klayout/tests/test_global_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ def test_estimate_weighted_global_density(
estimated_density = estimate_weighted_global_density(
Xi=Xi, Yi=Yi, Zi=Zi, bbox=get_gds_bbox(gdspath)
)
assert np.isclose(
estimated_density, expected_global_density
), f"{estimated_density=}, {expected_global_density=}"
assert np.isclose(estimated_density, expected_global_density), (
f"{estimated_density=}, {expected_global_density=}"
)
4 changes: 2 additions & 2 deletions gplugins/lumerical/interconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def run_wavelength_sweep(
session.connect(ona.name, "output", component.name, name)
for i, port in enumerate(ports_out.keys()):
name = port if is_top_level else f"{port}.{ports_out[port]}"
session.connect(ona.name, f"input {i+1}", component.name, name)
session.connect(ona.name, f"input {i + 1}", component.name, name)

session.run()

# inc.close()
return {
result: {
port: session.getresult(ona.name, f"input {i+1}/mode {mode}/{result}")
port: session.getresult(ona.name, f"input {i + 1}/mode {mode}/{result}")
for i, port in enumerate(ports_out)
}
for result in results
Expand Down
6 changes: 3 additions & 3 deletions gplugins/lumerical/tests/test_netlist_get_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def mock_get_connections(instances, mapping):

routes = get_routes(instances, mapping, layers, True)
assert "electrical_bundle_00" not in routes
assert all(
"electrical" not in key for key in routes.keys()
), "Electrical routes should be ignored"
assert all("electrical" not in key for key in routes.keys()), (
"Electrical routes should be ignored"
)


# def test_electrical_routing_with_parameters(setup_routing_data):
Expand Down
7 changes: 3 additions & 4 deletions gplugins/lumerical/write_sparameters_lumerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ def write_sparameters_lumerical(
]
if not layers_thickness:
raise ValueError(
f"no layers for component {component.layers}"
f"in layer stack {layer_stack}"
f"no layers for component {component.layers}in layer stack {layer_stack}"
)
layers_zmin = [
layer_to_zmin[layer]
Expand All @@ -300,7 +299,7 @@ def write_sparameters_lumerical(
)

logger.info(
f"Simulation size = {x_span*1e6:.3f}, {y_span*1e6:.3f}, {z_span*1e6:.3f} um"
f"Simulation size = {x_span * 1e6:.3f}, {y_span * 1e6:.3f}, {z_span * 1e6:.3f} um"
)

# from pprint import pprint
Expand Down Expand Up @@ -393,7 +392,7 @@ def write_sparameters_lumerical(
zspan = 2 * ss.port_margin + thickness

s.addport()
p = f"FDTD::ports::port {i+1}"
p = f"FDTD::ports::port {i + 1}"
s.setnamed(p, "x", port.dx * 1e-6)
s.setnamed(p, "y", port.dy * 1e-6)
s.setnamed(p, "z", z * 1e-6)
Expand Down
2 changes: 1 addition & 1 deletion gplugins/photonic_circuit_models/ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def ring(
coupling=coupling,
loss=loss,
)
plt.plot(wl, p, label=f"{int(width*1e3)}nm")
plt.plot(wl, p, label=f"{int(width * 1e3)}nm")

# for thickness, ng in zip(thicknesses, ngs):
# p = ring(
Expand Down
2 changes: 1 addition & 1 deletion gplugins/sax/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _mmi_nxn(
splitting_matrix[i][j]
) # Convert power ratio to amplitude
loss_factor = 10 ** (-loss_dB[j] / 20)
S[(f"o{i+1}", f"o{j+1}")] = amplitude * loss_factor
S[(f"o{i + 1}", f"o{j + 1}")] = amplitude * loss_factor

return sax.reciprocal(S)

Expand Down
6 changes: 3 additions & 3 deletions gplugins/sentaurus/sprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def write_sprocess(
)
if split_steps:
f.write(
f"struct tdr={relative_save_directory!s}/{struct_prefix}{i+1}_{step.name}_litho.tdr\n"
f"struct tdr={relative_save_directory!s}/{struct_prefix}{i + 1}_{step.name}_litho.tdr\n"
)

if isinstance(step, Etch):
Expand Down Expand Up @@ -350,7 +350,7 @@ def write_sprocess(

if split_steps:
f.write(
f"struct tdr={relative_save_directory!s}/{struct_prefix}{i+1}_{step.name}.tdr"
f"struct tdr={relative_save_directory!s}/{struct_prefix}{i + 1}_{step.name}.tdr"
)

f.write("\n")
Expand Down Expand Up @@ -632,7 +632,7 @@ def cut_tdr(
)

contact_str = f"""contact name=cathode aluminum silicon xlo=0.0 xhi=0.2 ylo=0.0 yhi=1 zlo=0 zhi=0
contact name=anode aluminum silicon xlo=0.0 xhi=0.2 ylo={c.dysize-1:1.3f} yhi={c.dysize:1.3f} zlo=0 zhi=0
contact name=anode aluminum silicon xlo=0.0 xhi=0.2 ylo={c.dysize - 1:1.3f} yhi={c.dysize:1.3f} zlo=0 zhi=0
contact name=substrate box silicon xlo=4.2 xhi=4.3 ylo=0.0 yhi={c.dysize:1.3f} zlo=0 zhi=0
"""

Expand Down
6 changes: 3 additions & 3 deletions gplugins/spice/spice_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,13 +834,13 @@ def get_ports(netlist: str, instances: list, model: dict, mapping: dict) -> dict
# Ex. [a,o1: b,o1] is same as [b,o1: a,o1]; remove this permutation
if (
"$" not in inst1["nets"][i]
and f'{inst1["name"]},{inst1["ports"][i]}' not in connections
and f"{inst1['name']},{inst1['ports'][i]}" not in connections
):
side1 = f'{inst1["name"]},{inst1["ports"][i]}'
side1 = f"{inst1['name']},{inst1['ports'][i]}"
connections.append(side1)

# Map instance port name to layout port name
side1 = f'{inst1["name"]},{mapping[inst1["model"]]["ports"][inst1["ports"][i]]}'
side1 = f"{inst1['name']},{mapping[inst1['model']]['ports'][inst1['ports'][i]]}"

j = ctk_ports.index(inst1["nets"][i])
ports[model["ports"][j]] = side1
Expand Down
6 changes: 3 additions & 3 deletions gplugins/tidy3d/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# Function to validate the medium
def validate_medium(v):
# Check if the input is an instance of td.Medium
assert isinstance(
v, td.AbstractMedium
), f"Input should be a tidy3d medium, but got {type(v)} instead"
assert isinstance(v, td.AbstractMedium), (
f"Input should be a tidy3d medium, but got {type(v)} instead"
)
return v


Expand Down
6 changes: 3 additions & 3 deletions gplugins/vlsir/tests/test_vlsir.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def test_kdb_vlsir(pkg) -> None:
assert pkg is not None, "Package should not be None"
assert len(pkg.modules) == 3, "Expected 3 modules in the package"
for i in range(3):
assert (
pkg.modules[i].name == packages[i]
), f"Module[{i}] name should be {packages[i]}"
assert pkg.modules[i].name == packages[i], (
f"Module[{i}] name should be {packages[i]}"
)


@pytest.mark.parametrize("spice_format", ["spice", "spectre", "xyce", "verilog"])
Expand Down
2 changes: 1 addition & 1 deletion notebooks/workflow_2_ring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
" coupling=coupling,\n",
" loss=loss,\n",
" )\n",
" plt.plot(wl, p, label=f\"{int(width*1e3)}nm\")\n",
" plt.plot(wl, p, label=f\"{int(width * 1e3)}nm\")\n",
"\n",
" plt.title(\"ring resonator vs waveguide width\")\n",
" plt.xlabel(\"wavelength (um)\")\n",
Expand Down
Loading