From 9a216a5ccf8b28e2a79ab304a5a26c6bb611741e Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:32:26 -0800 Subject: [PATCH] remove black --- .pre-commit-config.yaml | 6 +----- docs/notebooks/pso.py | 3 ++- docs/notebooks/ray_optimiser.py | 3 ++- docs/notebooks/sax_01_sax.py | 16 +++++++++------- gplugins/fdtdz/get_ports_fdtdz.py | 2 +- .../gmeep/get_simulation_grating_farfield.py | 4 +--- gplugins/gmeep/get_simulation_grating_fiber.py | 8 ++------ gplugins/palace/get_capacitance.py | 4 +--- pyproject.toml | 1 + 9 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9f6a73ce..00256ce3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,11 +18,7 @@ repos: rev: "v0.1.5" 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 diff --git a/docs/notebooks/pso.py b/docs/notebooks/pso.py index 84695a58..6d674b5e 100644 --- a/docs/notebooks/pso.py +++ b/docs/notebooks/pso.py @@ -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 diff --git a/docs/notebooks/ray_optimiser.py b/docs/notebooks/ray_optimiser.py index b32288a5..d9325a15 100644 --- a/docs/notebooks/ray_optimiser.py +++ b/docs/notebooks/ray_optimiser.py @@ -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: diff --git a/docs/notebooks/sax_01_sax.py b/docs/notebooks/sax_01_sax.py index 6080344a..b83460d7 100644 --- a/docs/notebooks/sax_01_sax.py +++ b/docs/notebooks/sax_01_sax.py @@ -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, ...) @@ -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)) diff --git a/gplugins/fdtdz/get_ports_fdtdz.py b/gplugins/fdtdz/get_ports_fdtdz.py index 6dbf8ef7..58f851f1 100644 --- a/gplugins/fdtdz/get_ports_fdtdz.py +++ b/gplugins/fdtdz/get_ports_fdtdz.py @@ -243,4 +243,4 @@ def plot_mode( nm_per_pixel=1000, figsize=(11, 4), ) - plt.savefig("test_mode.png"), + plt.savefig("test_mode.png") diff --git a/gplugins/gmeep/get_simulation_grating_farfield.py b/gplugins/gmeep/get_simulation_grating_farfield.py index 033db038..de262b73 100644 --- a/gplugins/gmeep/get_simulation_grating_farfield.py +++ b/gplugins/gmeep/get_simulation_grating_farfield.py @@ -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) diff --git a/gplugins/gmeep/get_simulation_grating_fiber.py b/gplugins/gmeep/get_simulation_grating_fiber.py index d4034f5a..53cc7e69 100644 --- a/gplugins/gmeep/get_simulation_grating_fiber.py +++ b/gplugins/gmeep/get_simulation_grating_fiber.py @@ -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) diff --git a/gplugins/palace/get_capacitance.py b/gplugins/palace/get_capacitance.py index b3038092..a437c928 100644 --- a/gplugins/palace/get_capacitance.py +++ b/gplugins/palace/get_capacitance.py @@ -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] diff --git a/pyproject.toml b/pyproject.toml index 4caf41f4..f7c4fb4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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']