Skip to content

Commit

Permalink
Ruff formatting + checks
Browse files Browse the repository at this point in the history
- add ruff ruff settings to pyproject.toml
- use ruff gh actions
- add python 3.12, remove python 3.8
- fix most ruff issues in code base (see pyproject.toml for ignore list).
  • Loading branch information
dbrakenhoff committed Sep 25, 2024
1 parent a7cb4c9 commit 21b3467
Show file tree
Hide file tree
Showing 56 changed files with 1,228 additions and 599 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.9, '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -30,13 +30,14 @@ jobs:
python -m pip install --upgrade pip
pip install -e .[ci]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=80 --statistics
- name: ruff-lint
uses: chartboost/ruff-action@v1

- name: ruff-format
uses: chartboost/ruff-action@v1
with:
args: "format --check"

- name: Run tests
run: |
py.test ./tests
Expand Down
1 change: 1 addition & 0 deletions docs/00tutorials/tutorial0_well_single_layer_aquifer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"outputs": [],
"source": [
"import numpy as np # import numpy package\n",
"\n",
"import timml as tml # import timml package"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/00tutorials/tutorial1_well_multi_layer_aquifer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import timml as tml"
]
},
Expand Down
73 changes: 37 additions & 36 deletions docs/03examples/BuildingPit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import timml as tml"
]
},
Expand Down Expand Up @@ -59,8 +60,8 @@
"metadata": {},
"outputs": [],
"source": [
"l = 40.0 # length building pit in m\n",
"b = 30.0 # width building pit in m\n",
"length = 40.0 # length building pit in m\n",
"width = 30.0 # width building pit in m\n",
"\n",
"h_bem = -6.21 # m\n",
"offset = 5.0 # distance groundwater extraction element from sheetpiles in m"
Expand All @@ -73,11 +74,11 @@
"outputs": [],
"source": [
"xy = [\n",
" (-l / 2, -b / 2),\n",
" (l / 2, -b / 2),\n",
" (l / 2, b / 2),\n",
" (-l / 2, b / 2),\n",
" (-l / 2, -b / 2),\n",
" (-length / 2, -width / 2),\n",
" (length / 2, -width / 2),\n",
" (length / 2, width / 2),\n",
" (-length / 2, width / 2),\n",
" (-length / 2, -width / 2),\n",
"]"
]
},
Expand Down Expand Up @@ -211,28 +212,28 @@
"\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" y1=b / 2 - offset,\n",
" x2=l / 2 - offset,\n",
" y2=b / 2 - offset,\n",
" x1=-length / 2 + offset,\n",
" y1=width / 2 - offset,\n",
" x2=length / 2 - offset,\n",
" y2=width / 2 - offset,\n",
" hls=h_bem,\n",
" layers=np.arange(last_lay_dw + 1),\n",
")\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" x1=-length / 2 + offset,\n",
" y1=0,\n",
" x2=l / 2 - offset,\n",
" x2=length / 2 - offset,\n",
" y2=0,\n",
" hls=h_bem,\n",
" layers=np.arange(last_lay_dw + 1),\n",
")\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" y1=-b / 2 + offset,\n",
" x2=l / 2 - offset,\n",
" y2=-b / 2 + offset,\n",
" x1=-length / 2 + offset,\n",
" y1=-width / 2 + offset,\n",
" x2=length / 2 - offset,\n",
" y2=-width / 2 + offset,\n",
" hls=h_bem,\n",
" layers=np.arange(last_lay_dw + 1),\n",
")\n",
Expand All @@ -248,7 +249,7 @@
"\n",
"print(\"\\nDischarge =\", np.round(Qtot.sum(), 2), \"m^3/dag\")\n",
"\n",
"y = np.linspace(-b / 2 - 25, b / 2 + 1100, 201)\n",
"y = np.linspace(-width / 2 - 25, width / 2 + 1100, 201)\n",
"hl = ml.headalongline(np.zeros(201), y, layers=[0])\n",
"y_5cm = np.interp(\n",
" -0.05, ml.headalongline(np.zeros(201), y, layers=0).squeeze(), y, right=np.nan\n",
Expand Down Expand Up @@ -298,7 +299,7 @@
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(0.0, l / 2 + 1100, 201)\n",
"x = np.linspace(0.0, length / 2 + 1100, 201)\n",
"hl = ml.headalongline(x, np.zeros(201), layers=[last_lay_dw, last_lay_dw + 1])"
]
},
Expand Down Expand Up @@ -337,7 +338,7 @@
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(-l / 2 - 25, 0.0, 201)\n",
"x = np.linspace(-length / 2 - 25, 0.0, 201)\n",
"hl = ml.headalongline(x, np.zeros(201), layers=[last_lay_dw, last_lay_dw + 1])"
]
},
Expand Down Expand Up @@ -378,7 +379,7 @@
"source": [
"xoffset = 50\n",
"zoffset = 15\n",
"x1, x2, y1, y2 = [-l / 2 - xoffset, 0.0, 0, 0]\n",
"x1, x2, y1, y2 = [-length / 2 - xoffset, 0.0, 0, 0]\n",
"nudge = 1e-6\n",
"n = 301"
]
Expand Down Expand Up @@ -581,29 +582,29 @@
"\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" y1=b / 2 - offset,\n",
" x2=l / 2 - offset,\n",
" y2=b / 2 - offset,\n",
" x1=-length / 2 + offset,\n",
" y1=width / 2 - offset,\n",
" x2=length / 2 - offset,\n",
" y2=width / 2 - offset,\n",
" hls=h_bem,\n",
" layers=wlayers,\n",
")\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" x1=-length / 2 + offset,\n",
" y1=0,\n",
" x2=l / 2 - offset,\n",
" x2=length / 2 - offset,\n",
" y2=0,\n",
" hls=h_bem,\n",
" layers=wlayers,\n",
" order=5,\n",
")\n",
"tml.HeadLineSink(\n",
" ml,\n",
" x1=-l / 2 + offset,\n",
" y1=-b / 2 + offset,\n",
" x2=l / 2 - offset,\n",
" y2=-b / 2 + offset,\n",
" x1=-length / 2 + offset,\n",
" y1=-width / 2 + offset,\n",
" x2=length / 2 - offset,\n",
" y2=-width / 2 + offset,\n",
" hls=h_bem,\n",
" layers=wlayers,\n",
")\n",
Expand All @@ -619,7 +620,7 @@
"\n",
"print(\"\\nDischarge =\", np.round(Qtot.sum(), 2), \"m^3/dag\")\n",
"\n",
"y = np.linspace(-b / 2 - 25, b / 2 + 1100, 201)\n",
"y = np.linspace(-width / 2 - 25, width / 2 + 1100, 201)\n",
"hl = ml.headalongline(np.zeros(201), y, layers=[0])\n",
"y_5cm = np.interp(\n",
" -0.05, ml.headalongline(np.zeros(201), y, layers=0).squeeze(), y, right=np.nan\n",
Expand All @@ -642,7 +643,7 @@
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(0.0, l / 2 + 1100, 201)\n",
"x = np.linspace(0.0, length / 2 + 1100, 201)\n",
"hl = ml.headalongline(x, np.zeros(201), layers=[0, last_lay_dw, last_lay_dw + 1])"
]
},
Expand Down Expand Up @@ -682,7 +683,7 @@
"metadata": {},
"outputs": [],
"source": [
"x = np.linspace(-l / 2 - 25, 0.0, 201)\n",
"x = np.linspace(-length / 2 - 25, 0.0, 201)\n",
"hl = ml.headalongline(x, np.zeros(201), layers=[0, last_lay_dw, last_lay_dw + 1])"
]
},
Expand Down Expand Up @@ -724,7 +725,7 @@
"source": [
"xoffset = 50\n",
"zoffset = 15\n",
"x1, x2, y1, y2 = [-l / 2 - xoffset, 0.0, 0, 0]\n",
"x1, x2, y1, y2 = [-length / 2 - xoffset, 0.0, 0, 0]\n",
"nudge = 1e-6\n",
"n = 301"
]
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/circareasink_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"\n",
"import timml as tml"
]
},
{
Expand Down
4 changes: 1 addition & 3 deletions docs/03examples/lake_horizontal_well.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"import timml as tml"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/normal_flux.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
"outputs": [],
"source": [
"# import packages\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import timml as tml\n",
"import matplotlib.pyplot as plt"
"\n",
"import timml as tml"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/test_linesink_discharge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"\n",
"import timml as tml"
]
},
{
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/test_polygon_areasink.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"\n",
"import timml as tml"
]
},
{
Expand Down
4 changes: 1 addition & 3 deletions docs/03examples/test_well_near_lake.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"import timml as tml"
]
},
{
Expand Down
10 changes: 3 additions & 7 deletions docs/03examples/timml_notebook0_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@
"metadata": {},
"outputs": [],
"source": [
"# install timml if it is not installed already\n",
"try:\n",
" import timml as tml\n",
"except:\n",
" !pip install timml\n",
" import timml as tml\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
"\n",
"import timml as tml"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/03examples/timml_notebook1_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import timml as tml\n",
"\n",
"figsize = (8, 8)"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/03examples/timml_notebook2_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import timml as tml\n",
"\n",
"figsize = (8, 8)"
]
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/timml_notebook3_3D_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import timml as tml\n",
"\n",
"plt.rcParams[\"figure.figsize\"] = (6, 6)"
]
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/timml_notebook3_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import timml as tml\n",
"\n",
"figsize = (8, 8)"
]
Expand Down
5 changes: 3 additions & 2 deletions docs/03examples/timml_notebook4_sol.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"import timml as tml\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"import timml as tml\n",
"\n",
"figsize = (8, 8)"
]
Expand Down
Loading

0 comments on commit 21b3467

Please sign in to comment.