Skip to content

Commit

Permalink
fix ruff errors and remove isort and black
Browse files Browse the repository at this point in the history
  • Loading branch information
m-reuter committed Aug 30, 2024
1 parent 470a7b6 commit 8454986
Show file tree
Hide file tree
Showing 25 changed files with 117 additions and 155 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ jobs:
python -m pip install --progress-bar off .[style]
- name: Run Ruff
run: ruff check .
- name: Run isort
uses: isort/isort-action@master
- name: Run black
uses: psf/black@stable
with:
options: "--check --verbose"
version: "23.10.1"
- name: Run codespell
uses: codespell-project/actions-codespell@master
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# some tests fail (numerical issues) in older python on mac, so we ...
exclude:
- os: macos
python-version: 3.9
python-version: '3.9'
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
Expand All @@ -36,7 +36,6 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#architecture: 'x64'
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
Expand Down
6 changes: 4 additions & 2 deletions examples/Test_Plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualization"
"# Visualization"
]
},
{
Expand All @@ -20,8 +20,10 @@
"metadata": {},
"outputs": [],
"source": [
"from lapy import TriaMesh, TetMesh, Solver, plot, io\n",
"import plotly.io as pio\n",
"\n",
"from lapy import Solver, TetMesh, TriaMesh, io, plot\n",
"\n",
"pio.renderers.default = \"sphinx_gallery\""
]
},
Expand Down
5 changes: 2 additions & 3 deletions examples/Test_ShapeDNA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# ShapeDNA"
"# ShapeDNA"
]
},
{
Expand All @@ -21,8 +21,7 @@
"outputs": [],
"source": [
"# imports\n",
"from lapy import TriaMesh, TetMesh\n",
"from lapy import shapedna"
"from lapy import TetMesh, TriaMesh, shapedna"
]
},
{
Expand Down
19 changes: 12 additions & 7 deletions examples/Test_TetMesh_Geodesics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# TetMesh Geodesics"
"# TetMesh Geodesics"
]
},
{
Expand Down Expand Up @@ -39,11 +39,14 @@
],
"source": [
"import numpy as np\n",
"from lapy import TetMesh\n",
"from lapy.plot import plot_tet_mesh\n",
"\n",
"# import plotly\n",
"# plotly.offline.init_notebook_mode(connected=True)\n",
"import plotly.io as pio\n",
"\n",
"from lapy import TetMesh\n",
"from lapy.plot import plot_tet_mesh\n",
"\n",
"pio.renderers.default = \"sphinx_gallery\""
]
},
Expand Down Expand Up @@ -116,6 +119,7 @@
],
"source": [
"from lapy import Solver\n",
"\n",
"fem = Solver(T,lump=True)\n",
"\n",
"evals, evec = fem.eigs(10)\n"
Expand Down Expand Up @@ -168,8 +172,8 @@
"metadata": {},
"outputs": [],
"source": [
"from lapy.diffgeo import compute_gradient\n",
"from lapy.diffgeo import compute_divergence\n",
"from lapy.diffgeo import compute_divergence, compute_gradient\n",
"\n",
"grad = compute_gradient(T,evec[:,evnum])\n",
"divx = -compute_divergence(T,grad)\n",
"vfunc = Bi*divx\n"
Expand Down Expand Up @@ -299,6 +303,7 @@
"source": [
"# compute distance\n",
"from scipy.sparse.linalg import splu\n",
"\n",
"useCholmod = True\n",
"try:\n",
" from sksparse.cholmod import cholesky\n",
Expand Down Expand Up @@ -373,8 +378,8 @@
}
],
"source": [
"from lapy.diffgeo import compute_geodesic_f\n",
"from lapy import heat\n",
"from lapy.diffgeo import compute_geodesic_f\n",
"\n",
"tria = T.boundary_tria()\n",
"bvert=np.unique(tria.t)\n",
Expand Down Expand Up @@ -473,7 +478,7 @@
"version": "3"
},
"nbsphinx": {
"execute": "always"
"execute": "always"
}
},
"nbformat": 4,
Expand Down
3 changes: 2 additions & 1 deletion examples/Test_TriaMesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Triangle Mesh"
"# Triangle Mesh"
]
},
{
Expand All @@ -14,6 +14,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from lapy import TriaMesh"
]
},
Expand Down
13 changes: 10 additions & 3 deletions examples/Test_TriaMesh_Geodesics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@
"# import plotting functions\n",
"# import plotly\n",
"# plotly.offline.init_notebook_mode(connected=True)\n",
"from lapy.plot import plot_tria_mesh\n",
"import plotly.io as pio\n",
"\n",
"from lapy.plot import plot_tria_mesh\n",
"\n",
"pio.renderers.default = \"sphinx_gallery\""
]
},
Expand Down Expand Up @@ -139,6 +141,7 @@
"source": [
"# compute first eigenfunction\n",
"from lapy import Solver\n",
"\n",
"fem = Solver(T,lump=True)\n",
"eval, evec = fem.eigs()\n",
"vfunc = evec[:,1]\n",
Expand Down Expand Up @@ -221,8 +224,8 @@
"metadata": {},
"outputs": [],
"source": [
"from lapy.diffgeo import compute_gradient\n",
"from lapy.diffgeo import compute_divergence\n",
"from lapy.diffgeo import compute_divergence, compute_gradient\n",
"\n",
"grad = compute_gradient(T,vfunc)\n",
"divx = -compute_divergence(T,grad)\n",
"plot_tria_mesh(T,Bi*divx,plot_edges=True)"
Expand Down Expand Up @@ -254,6 +257,7 @@
],
"source": [
"from lapy import heat\n",
"\n",
"bvert = T.boundary_loops()\n",
"u = heat.diffusion(T,bvert,m=1)"
]
Expand Down Expand Up @@ -338,6 +342,7 @@
"source": [
"# compute distance\n",
"from scipy.sparse.linalg import splu\n",
"\n",
"useCholmod = True\n",
"try:\n",
" from sksparse.cholmod import cholesky\n",
Expand Down Expand Up @@ -488,6 +493,7 @@
],
"source": [
"from lapy.diffgeo import compute_geodesic_f\n",
"\n",
"gf = compute_geodesic_f(T,u)\n",
"plot_tria_mesh(T,gf,plot_edges=True,plot_levels=True)"
]
Expand Down Expand Up @@ -545,6 +551,7 @@
"source": [
"# testing if we can rotate the function\n",
"from lapy.diffgeo import compute_rotated_f\n",
"\n",
"gf = compute_rotated_f(T,vf)\n",
"plot_tria_mesh(T,gf,plot_edges=True,plot_levels=True)"
]
Expand Down
6 changes: 3 additions & 3 deletions lapy/_read_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _read_volume_info(fobj):
if not np.array_equal(head, [2, 0, 20]) and not np.array_equal(
head, [2, 1, 20]
):
warnings.warn("Unknown extension code.")
warnings.warn("Unknown extension code.", stacklevel=2)
return volume_info
head = [2, 0, 20]

Expand All @@ -98,7 +98,7 @@ def _read_volume_info(fobj):
]:
pair = fobj.readline().decode("utf-8").split("=")
if pair[0].strip() != key or len(pair) != 2:
raise IOError("Error parsing volume info.")
raise OSError("Error parsing volume info.")
if key in ("valid", "filename"):
volume_info[key] = pair[1].strip()
elif key == "volume":
Expand Down Expand Up @@ -176,7 +176,7 @@ def read_geometry(filepath, read_metadata=False, read_stamp=False):
ret = (coords, faces)
if read_metadata:
if len(volume_info) == 0:
warnings.warn("No volume information contained in the file")
warnings.warn("No volume information contained in the file", stacklevel=2)
ret += (volume_info,)
if read_stamp:
ret += (create_stamp,)
Expand Down
10 changes: 5 additions & 5 deletions lapy/_tet_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def read_gmsh(filename):
print("[no .msh file] --> FAILED\n")
return
try:
f = open(filename, "r")
except IOError:
f = open(filename)
except OSError:
print("[file not found or not readable]\n")
return
line = f.readline()
Expand Down Expand Up @@ -126,8 +126,8 @@ def read_vtk(filename):
if verbose > 0:
print("--> VTK format ... ")
try:
f = open(filename, "r")
except IOError:
f = open(filename)
except OSError:
print("[file not found or not readable]\n")
return
# skip comments
Expand Down Expand Up @@ -209,7 +209,7 @@ def write_vtk(tet, filename):
# open file
try:
f = open(filename, "w")
except IOError:
except OSError:
print("[File " + filename + " not writable]")
return
# check data structure
Expand Down
Loading

0 comments on commit 8454986

Please sign in to comment.