Skip to content

Commit

Permalink
Merge pull request #250 from gdsfactory/remove_black2
Browse files Browse the repository at this point in the history
remove black
  • Loading branch information
joamatab authored Nov 28, 2023
2 parents d19f8eb + 9a216a5 commit 2b1bf0a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 27 deletions.
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ repos:
rev: "v0.1.6"
hooks:
- id: ruff

- repo: https://github.com/psf/black
rev: "23.11.0"
hooks:
- id: black
- id: ruff-format

# - repo: https://github.com/shellcheck-py/shellcheck-py
# rev: v0.9.0.5
Expand Down
3 changes: 2 additions & 1 deletion docs/notebooks/pso.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def trainable_simulations(x, loss=lambda x: x):
)
if use_mpi: # change this to false if no MPI support
s_params = gm.write_sparameters_meep_mpi(
cores=2, **meep_params # set this to be the same as in `tune.Tuner`
cores=2,
**meep_params, # set this to be the same as in `tune.Tuner`
)
s_params = np.load(
s_params
Expand Down
3 changes: 2 additions & 1 deletion docs/notebooks/ray_optimiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def trainable_simulations(config):

if use_mpi: # change this to false if no MPI support
s_params = gm.write_sparameters_meep_mpi(
cores=2, **meep_params # set this to be same as in `tune.Tuner`
cores=2,
**meep_params, # set this to be same as in `tune.Tuner`
)
s_params = np.load(s_params) # parallel version returns filepath to npz instead
else:
Expand Down
16 changes: 9 additions & 7 deletions docs/notebooks/sax_01_sax.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def waveguide(wl=1.55, wl0=1.55, neff=2.34, ng=3.4, length=10.0, loss=0.0) -> sa


def fX(x, _order=8):
return x[:, None] ** (
jnp.arange(_order)[None, :]
return (
x[:, None] ** (jnp.arange(_order)[None, :])
) # artificially create more 'features' (wl**2, wl**3, wl**4, ...)


Expand Down Expand Up @@ -719,17 +719,19 @@ def bend_euler(wl=1.5, length=20.0, width=0.5):
# %%
def create_wafermaps(placements, correlation_length=1.0, num_maps=1, mean=0.0, std=1.0):
dx = dy = correlation_length / 200
xs, ys = [p["x"] for p in placements.values()], [
p["y"] for p in placements.values()
]
xs, ys = (
[p["x"] for p in placements.values()],
[p["y"] for p in placements.values()],
)
xmin, xmax, ymin, ymax = min(xs), max(xs), min(ys), max(ys)
wx, wy = xmax - xmin, ymax - ymin
xmin, xmax, ymin, ymax = xmin - wx, xmax + wx, ymin - wy, ymax + wy
x, y = np.arange(xmin, xmax + dx, dx), np.arange(ymin, ymax + dy, dy)
W0 = np.random.randn(num_maps, x.shape[0], y.shape[0])

fx, fy = fftshift(fftfreq(x.shape[0], d=x[1] - x[0])), fftshift(
fftfreq(y.shape[0], d=y[1] - y[0])
fx, fy = (
fftshift(fftfreq(x.shape[0], d=x[1] - x[0])),
fftshift(fftfreq(y.shape[0], d=y[1] - y[0])),
)
fY, fX = np.meshgrid(fy, fx)
fW = fftshift(fft2(W0))
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 @@ -243,4 +243,4 @@ def plot_mode(
nm_per_pixel=1000,
figsize=(11, 4),
)
plt.savefig("test_mode.png"),
plt.savefig("test_mode.png")
4 changes: 1 addition & 3 deletions gplugins/gmeep/get_simulation_grating_farfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ def get_simulation_grating_farfield(
fiber_clad = 120
hfiber_geom = 100 # Some large number to make fiber extend into PML

fiber_core_material = (
fiber_numerical_aperture**2 + fiber_clad_material**2
) ** 0.5
fiber_core_material = (fiber_numerical_aperture**2 + fiber_clad_material**2) ** 0.5
fiber_clad_material = mp.Medium(index=fiber_clad_material)
fiber_core_material = mp.Medium(index=fiber_core_material)

Expand Down
8 changes: 2 additions & 6 deletions gplugins/gmeep/get_simulation_grating_fiber.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,12 @@ def get_simulation_grating_fiber(
wg_material = mp.Medium(index=nwg)
top_clad_material = mp.Medium(index=clad_material)
bottom_clad_material = mp.Medium(index=nbox)
fiber_core_material = (
fiber_numerical_aperture**2 + fiber_clad_material**2
) ** 0.5
fiber_core_material = (fiber_numerical_aperture**2 + fiber_clad_material**2) ** 0.5
fiber_clad_material = mp.Medium(index=fiber_clad_material)
fiber_core_material = mp.Medium(index=fiber_core_material)

# Useful reference point
grating_start = (
-fiber_xposition
) # Since fiber dominates, keep it centered and offset the grating
grating_start = -fiber_xposition # Since fiber dominates, keep it centered and offset the grating

# Initialize domain x-z plane simulation
cell_size = mp.Vector3(sxy, sz)
Expand Down
4 changes: 1 addition & 3 deletions gplugins/palace/get_capacitance.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ def _read_palace_results(
"""Fetch results from successful Palace simulations."""
raw_capacitance_matrix = read_csv(
simulation_folder / "postpro" / "terminal-Cm.csv", dtype=float
).values[
:, 1:
] # remove index
).values[:, 1:] # remove index
return ElectrostaticResults(
capacitance_matrix={
(iname, jname): raw_capacitance_matrix[i][j]
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ select = [
]

[tool.ruff.per-file-ignores]
"docs/notebooks/*.py" = ["F821", 'E402', 'F405', 'F403']
"docs/notebooks/meep_01_sparameters.py" = ["F821", 'E402']
"docs/notebooks/tcad_02_analytical_process.py" = ["F821", 'E402', 'F405', 'F403']

Expand Down

0 comments on commit 2b1bf0a

Please sign in to comment.