Skip to content

Commit c0e625f

Browse files
authored
Merge pull request #136 from nikosavola/enable-more-ruff
Enable more ruff checks
2 parents 21a028c + 9e01e69 commit c0e625f

39 files changed

+841
-459
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
34
rev: "9260cbc9c84c06022993bfbcc42fdbf0305c5b8e"
45
hooks:
56
- id: check-added-large-files

docs/gdsfactory_interface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
# gmsh.initialize()
6666
# gmsh.open("heater_uz.msh")
6767
# gmsh.fltk.run()
68-
# except: # noqa: E722
68+
# except:
6969
# print("Skipping CAD GUI visualization - only available when running locally")
7070
# ```
7171

@@ -93,7 +93,7 @@
9393
# gmsh.initialize()
9494
# gmsh.open("heater_3D.msh")
9595
# gmsh.fltk.run()
96-
# except: # noqa: E722
96+
# except:
9797
# print("Skipping CAD GUI visualization - only available when running locally")
9898
# ```
9999
# %%

docs/importing_gds.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
# First, assume we have a GDS file (here we write a small one with gdstk):
88

99
# %%
10-
from typing import List
10+
1111
import gdstk
12-
from meshwell.import_gds import read_gds_layers
12+
import matplotlib.pyplot as plt
1313
import shapely
1414
import shapely.geometry as sg
15-
from meshwell.visualization import colors
16-
from meshwell.polysurface import PolySurface
17-
import matplotlib.pyplot as plt
18-
from meshwell.visualization import plot2D
15+
1916
from meshwell.cad import cad
17+
from meshwell.import_gds import read_gds_layers
2018
from meshwell.mesh import mesh
19+
from meshwell.polysurface import PolySurface
20+
from meshwell.visualization import colors, plot2D
2121

2222
lib = gdstk.Library()
2323
cell = lib.new_cell("TOP")
@@ -50,7 +50,7 @@
5050
# Add all shapes to cell
5151
shapes = [rect1a, poly1b, poly1c, rect2a, poly2b, poly2c, circle1, circle2, circle3]
5252
for shape in shapes:
53-
if isinstance(shape, List):
53+
if isinstance(shape, list):
5454
for subshape in shape:
5555
cell.add(subshape)
5656
else:
@@ -64,10 +64,7 @@
6464
ymax = float("-inf")
6565

6666
for shape in shapes:
67-
if isinstance(shape, List):
68-
shape_list = shape
69-
else:
70-
shape_list = [shape]
67+
shape_list = shape if isinstance(shape, list) else [shape]
7168

7269
for s in shape_list:
7370
bbox = s.bounding_box()
@@ -236,7 +233,7 @@
236233
# %%
237234
# Helper function to plot shapely geometries
238235
def plot_geometry(geometry, title=None, color="blue", alpha=0.5, show_layer4=True):
239-
fig, ax = plt.subplots(figsize=(8, 8))
236+
_fig, ax = plt.subplots(figsize=(8, 8))
240237

241238
# Plot the main geometry
242239
if isinstance(geometry, sg.MultiPolygon):

docs/intro_gmsh.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# %%
66
import gmsh
77
import meshio
8+
89
from meshwell.visualization import plot2D
910

1011
# %% [markdown]

docs/models.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
# Multiple GMSH entities (and polysurfaces or prisms) can be provided to a model to create a single mesh.
44

55
# %%
6-
import shapely
7-
import gmsh
86
from functools import partial
9-
from meshwell.polysurface import PolySurface
10-
from meshwell.gmsh_entity import GMSH_entity
11-
from meshwell.visualization import plot2D
7+
8+
import gmsh
9+
import shapely
10+
1211
from meshwell.cad import cad
12+
from meshwell.gmsh_entity import GMSH_entity
1313
from meshwell.mesh import mesh
14+
from meshwell.polysurface import PolySurface
15+
from meshwell.visualization import plot2D
1416

1517
# %%
1618
polygon_hull = shapely.Polygon(

docs/polysurfaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import matplotlib.pyplot as plt
77
import shapely
88

9-
from meshwell.polysurface import PolySurface
109
from meshwell.cad import cad
1110
from meshwell.mesh import mesh
11+
from meshwell.polysurface import PolySurface
1212
from meshwell.visualization import plot2D
1313

1414
# %%

docs/prisms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# Polygons can be associated with arbitrarily complex extrusion rules to form 3D Prisms.
44

55
# %%
6-
import shapely
76
import matplotlib.pyplot as plt
8-
from meshwell.polyprism import PolyPrism
97
import plotly.graph_objects as go
8+
import shapely
9+
1010
from meshwell.cad import cad
1111
from meshwell.mesh import mesh
12+
from meshwell.polyprism import PolyPrism
1213

1314
# %%
1415
# We use shapely as an API to enter polygons

docs/resolution_advanced.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
# %%
66
import shapely
7-
from meshwell.polysurface import PolySurface
8-
from meshwell.visualization import plot2D
9-
from meshwell.resolution import ConstantInField, ThresholdField
7+
108
from meshwell.cad import cad
119
from meshwell.mesh import mesh
10+
from meshwell.polysurface import PolySurface
11+
from meshwell.resolution import ConstantInField, ThresholdField
12+
from meshwell.visualization import plot2D
1213

1314
# %% [markdown]
1415
# ## Filtering by mass

docs/resolution_basic.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
# When defining entities, ResolutionSpecs can be attached to control the mesh size within or near the entity and its boundaries.
44

55
# %%
6-
import shapely
76
from collections import OrderedDict
8-
from meshwell.polysurface import PolySurface
9-
from meshwell.visualization import plot2D
10-
from meshwell.resolution import ConstantInField, ThresholdField, ExponentialField
7+
8+
import shapely
9+
1110
from meshwell.cad import cad
1211
from meshwell.mesh import mesh
12+
from meshwell.polysurface import PolySurface
13+
from meshwell.resolution import ConstantInField, ExponentialField, ThresholdField
14+
from meshwell.visualization import plot2D
1315

1416
# %% [markdown]
1517
# ## Default characteristic length

meshwell/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""meshwell - GMSH wrapper, with integrated photonics focus"""
1+
"""meshwell - GMSH wrapper, with integrated photonics focus."""
22

33
__version__ = "0.0.1"
44
__author__ = "Simon Bilodeau <sb30@princeton.edu>"

0 commit comments

Comments
 (0)