Skip to content

Commit

Permalink
fix some ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joamatab committed Jan 11, 2025
1 parent 64685d0 commit 4303d9e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 76 deletions.
3 changes: 1 addition & 2 deletions gplugins/sax/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,9 @@ def mmi2x2(
loss_dB: loss in dB.
shift: shift in wavelength for both cross and thru ports.
loss_dB_cross: loss in dB for the cross port.
loss_dB_bar: loss in dB for the bar port.
loss_dB_thru: loss in dB for the bar port.
splitting_ratio_cross: splitting ratio for the cross port.
splitting_ratio_thru: splitting ratio for the bar port.
"""
loss_dB_cross = loss_dB_cross or loss_dB
loss_dB_thru = loss_dB_thru or loss_dB
Expand Down
12 changes: 6 additions & 6 deletions gplugins/sentaurus/sdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def write_sdevice_quasistationary_ramp_voltage_dd(
ramp_max_step: maximum ramping step.
ramp_min_step: minimum ramping step.
ramp_sample_voltages: list of voltages between 0V and ramp_final_voltage to report.
filepath: str = Path to the TLC file to be written.
file_settings: "File" field settings to add to the TCL file
output_settings: "Output" field settings to add to the TCL file
physics_settings: "Physics" field settings to add to the TCL file
math_settings: str = "Math" field settings to add to the TCL file
initialization_commands: in the solver, what to execute before the ramp
filename: name of the TCL file to save.
save_directory: directory to save the TCL file.
execution_directory: directory to execute the TCL file.
output_settings: "Plot" field settings to add to the TCL file.
physics_settings: "Physics" field settings to add to the TCL file.
math_settings: str = "Math" field settings to add to the TCL file.
"""
save_directory = (
Path("./sdevice/") if save_directory is None else Path(save_directory)
Expand Down
11 changes: 5 additions & 6 deletions gplugins/vlsir/export_netlist.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Uses VLSIRTools for converting between Klayout's DB Netlist format and other electrical schematic file formats:
"""Uses VLSIRTools for converting between Klayout's DB Netlist format and other electrical schematic file formats.
- SPICE
- Spectre
- Xyce
- Verilog (Not supported yet).
Todo:
- Add support for Verilog
- Thoroughly test the parser with more complex netlists
- Add support for Verilog.
- Thoroughly test the parser with more complex netlists.
"""

from io import StringIO
Expand Down Expand Up @@ -45,9 +46,7 @@ def _connections(**kwargs) -> list[Connection]:


def _params(**kwargs) -> list[Param]:
"""Create a list of `Param`s from keyword args of the form
`r=ParamValue(double_value=1e3)`.
"""
"""Create a list of `Param`s from keyword args of the form r=ParamValue(double_value=1e3)."""
return [Param(name=key, value=value) for key, value in kwargs.items()]


Expand Down
99 changes: 43 additions & 56 deletions notebooks/elmer_01_electrostatic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"from math import inf\n",
"\n",
"import gdsfactory as gf\n",
"import pyvista as pv\n",
"from gdsfactory.components.interdigital_capacitor_enclosed import (\n",
" interdigital_capacitor_enclosed,\n",
")\n",
Expand Down Expand Up @@ -146,61 +145,48 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"id": "8",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"# results = run_capacitive_simulation_elmer(\n",
"# c,\n",
"# layer_stack=layer_stack,\n",
"# material_spec=material_spec,\n",
"# n_processes=1,\n",
"# element_order=1,\n",
"# simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
"# mesh_parameters=dict(\n",
"# background_tag=\"vacuum\",\n",
"# background_padding=(0,) * 5 + (700,),\n",
"# port_names=c.ports.keys(),\n",
"# default_characteristic_length=200,\n",
"# resolutions={\n",
"# \"bw\": {\n",
"# \"resolution\": 15,\n",
"# },\n",
"# \"substrate\": {\n",
"# \"resolution\": 40,\n",
"# },\n",
"# \"vacuum\": {\n",
"# \"resolution\": 40,\n",
"# },\n",
"# **{\n",
"# f\"bw__{port}\": { # `__` is used as the layer–port delimiter for Elmer\n",
"# \"resolution\": 20,\n",
"# \"DistMax\": 30,\n",
"# \"DistMin\": 10,\n",
"# \"SizeMax\": 14,\n",
"# \"SizeMin\": 3,\n",
"# }\n",
"# for port in c.ports\n",
"# },\n",
"# },\n",
"# ),\n",
"# )\n",
"# display(results)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {
"lines_to_next_cell": 2
},
"outputs": [],
"metadata": {},
"source": [
"```python\n",
"results = run_capacitive_simulation_elmer(\n",
" c,\n",
" layer_stack=layer_stack,\n",
" material_spec=material_spec,\n",
" n_processes=1,\n",
" element_order=1,\n",
" simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
" mesh_parameters=dict(\n",
" background_tag=\"vacuum\",\n",
" background_padding=(0,) * 5 + (700,),\n",
" port_names=c.ports.keys(),\n",
" default_characteristic_length=200,\n",
" resolutions={\n",
" \"bw\": {\n",
" \"resolution\": 15,\n",
" },\n",
" \"substrate\": {\n",
" \"resolution\": 40,\n",
" },\n",
" \"vacuum\": {\n",
" \"resolution\": 40,\n",
" },\n",
" **{\n",
" f\"bw__{port}\": { # `__` is used as the layer to port delimiter for Elmer\n",
" \"resolution\": 20,\n",
" \"DistMax\": 30,\n",
" \"DistMin\": 10,\n",
" \"SizeMax\": 14,\n",
" \"SizeMin\": 3,\n",
" }\n",
" for port in c.ports\n",
" },\n",
" },\n",
" ),\n",
")\n",
"display(results)\n",
"\n",
"if results.field_file_location:\n",
" pv.start_xvfb()\n",
" pv.set_jupyter_backend(\"trame\")\n",
Expand All @@ -212,12 +198,13 @@
" p.show_grid()\n",
" p.camera_position = \"xy\"\n",
" p.enable_parallel_projection()\n",
" p.show()"
" p.show()\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "10",
"id": "9",
"metadata": {},
"source": [
"## Bibliography\n",
Expand Down
3 changes: 1 addition & 2 deletions notebooks/mpb_001_mpb_waveguide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,7 @@
" power_ratio: float = 1.0,\n",
" wavelength: float = 1.55,\n",
") -> float:\n",
" \"\"\"Returns the coupling length (um) of the directional coupler\n",
" to achieve power_ratio.\n",
" \"\"\"Returns the coupling length (um) of the directional coupler to achieve power_ratio.\n",
"\n",
" Args:\n",
" neff1: even supermode of the directional coupler.\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/palace_01_electrostatic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
" \"resolution\": 40,\n",
" },\n",
" **{\n",
" f\"bw__{port}\": { # `__` is used as the layerport delimiter for Palace\n",
" f\"bw__{port}\": { # `__` is used as the layer to port delimiter for Palace\n",
" \"resolution\": 20,\n",
" \"DistMax\": 30,\n",
" \"DistMin\": 10,\n",
Expand Down
6 changes: 4 additions & 2 deletions notebooks/ray_optimiser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"from gdsfactory.config import PATH\n",
"from gdsfactory.generic_tech import get_generic_pdk\n",
"from ray import tune\n",
"from ray.tune.search.hyperopt import HyperOptSearch\n",
"\n",
"import gplugins.gmeep as gm\n",
"\n",
Expand Down Expand Up @@ -126,8 +127,6 @@
" \"width_mmi\": tune.uniform(0.05, 2),\n",
"}\n",
"\n",
"# pylint: disable=wrong-import-position,ungrouped-imports\n",
"from ray.tune.search.hyperopt import HyperOptSearch\n",
"\n",
"tune_config = tune.TuneConfig(\n",
" metric=\"loss\",\n",
Expand Down Expand Up @@ -294,6 +293,9 @@
"cell_metadata_filter": "-all",
"main_language": "python",
"notebook_metadata_filter": "-all"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/sax_01_sax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@
"\n",
"\n",
"def bend_euler(wl=1.5, length=20.0):\n",
" \"\"\" \"Let's assume a reduced transmission for the euler bend compared to a straight.\"\"\"\n",
" \"\"\"Let's assume a reduced transmission for the euler bend compared to a straight.\"\"\"\n",
" return {k: 0.99 * v for k, v in straight(wl=wl, length=length).items()}\n",
"\n",
"\n",
Expand Down

0 comments on commit 4303d9e

Please sign in to comment.