Skip to content

Commit 4c92221

Browse files
Merge branch 'master' into CROCO_fix_sigma_calculation
2 parents 9b3fe7e + ef9eaa9 commit 4c92221

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+329
-268
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [macos, ubuntu, windows]
27-
python-version: ["3.12"]
27+
python-version: ["3.13"]
2828
include:
2929
- os: ubuntu
3030
python-version: "3.10"
3131
- os: ubuntu
3232
python-version: "3.11"
33+
- os: ubuntu
34+
python-version: "3.12"
3335
steps:
3436
- name: Checkout
3537
uses: actions/checkout@v4
@@ -43,10 +45,10 @@ jobs:
4345
coverage run -m pytest -v -s --html=${{ matrix.os }}_${{ matrix.python-version }}_unit_test_report.html --self-contained-html tests
4446
coverage xml
4547
- name: Codecov
46-
uses: codecov/codecov-action@v4.6.0
48+
uses: codecov/codecov-action@v5.0.7
4749
env:
4850
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49-
if: matrix.python-version == '3.12'
51+
if: matrix.python-version == '3.13'
5052
with:
5153
flags: unit-tests
5254
- name: Upload test results
@@ -62,7 +64,10 @@ jobs:
6264
fail-fast: false
6365
matrix:
6466
os: [macos, ubuntu, windows]
65-
python-version: ["3.12"]
67+
python-version: ["3.13"]
68+
include:
69+
- os: ubuntu
70+
python-version: "3.10"
6671
steps:
6772
- name: Checkout
6873
uses: actions/checkout@v4
@@ -72,10 +77,10 @@ jobs:
7277
environment-file: environment.yml
7378
- name: Integration test
7479
run: |
75-
coverage run -m pytest -v -s --nbval-lax -k "not documentation" --html="${{ matrix.os }}_integration_test_report.html" --self-contained-html docs/examples
80+
coverage run -m pytest -v -s --nbval-lax -k "not documentation" --html="${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html" --self-contained-html docs/examples
7681
coverage xml
7782
- name: Codecov
78-
uses: codecov/codecov-action@v4.6.0
83+
uses: codecov/codecov-action@v5.0.7
7984
env:
8085
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8186
with:
@@ -84,8 +89,8 @@ jobs:
8489
if: ${{ always() }} # Always run this step, even if tests fail
8590
uses: actions/upload-artifact@v4
8691
with:
87-
name: Integration test report ${{ matrix.os }}
88-
path: ${{ matrix.os }}_integration_test_report.html
92+
name: Integration test report ${{ matrix.os }}-${{ matrix.python-version }}
93+
path: ${{ matrix.os }}_${{ matrix.python-version }}_integration_test_report.html
8994
merge-test-artifacts:
9095
runs-on: ubuntu-latest
9196
needs:
@@ -112,7 +117,7 @@ jobs:
112117
run: |
113118
mypy --install-types --non-interactive parcels --cobertura-xml-report mypy_report
114119
- name: Upload mypy coverage to Codecov
115-
uses: codecov/codecov-action@v4.6.0
120+
uses: codecov/codecov-action@v5.0.7
116121
if: ${{ always() }} # Upload even on error of mypy
117122
env:
118123
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/pypi-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
7373
- name: Publish package to TestPyPI
7474
if: github.event_name == 'push'
75-
uses: pypa/gh-action-pypi-publish@v1.11.0
75+
uses: pypa/gh-action-pypi-publish@v1.12.2
7676
with:
7777
user: __token__
7878
password: ${{ secrets.PARCELS_PYPI_TEST_TOKEN }}
@@ -89,7 +89,7 @@ jobs:
8989
name: releases
9090
path: dist
9191
- name: Publish package to PyPI
92-
uses: pypa/gh-action-pypi-publish@v1.11.0
92+
uses: pypa/gh-action-pypi-publish@v1.12.2
9393
with:
9494
user: __token__
9595
password: ${{ secrets.PARCELS_PYPI_PROD_TOKEN }}

.pre-commit-config.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ repos:
1010
types: [text]
1111
files: \.(json|ipynb)$
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.7.4
13+
rev: v0.8.1
1414
hooks:
1515
- id: ruff
16+
name: ruff lint (.py)
1617
args: [--fix, --show-fixes]
18+
types_or: [python]
1719
- id: ruff
18-
name: ruff (isort jupyter)
20+
name: ruff isort (.ipynb)
1921
args: [--select, I, --fix]
2022
types_or: [jupyter]
2123
- id: ruff-format
2224
types_or: [python, jupyter]
2325
- repo: https://github.com/rbubley/mirrors-prettier # Update mirror as official mirror is deprecated
24-
rev: v3.3.3
26+
rev: v3.4.1
2527
hooks:
2628
- id: prettier
2729

docs/examples/documentation_indexing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
"metadata": {},
5555
"outputs": [],
5656
"source": [
57+
"import warnings\n",
5758
"from glob import glob\n",
5859
"from os import path\n",
59-
"import warnings\n",
6060
"\n",
6161
"import numpy as np\n",
6262
"\n",

docs/examples/example_brownian.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from datetime import timedelta
22

33
import numpy as np
4-
import parcels
54
import pytest
65

6+
import parcels
7+
78
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
89

910

docs/examples/example_dask_chunk_OCMs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
import dask
66
import numpy as np
7-
import parcels
87
import pytest
8+
9+
import parcels
910
from parcels.tools.statuscodes import DaskChunkingError
1011

1112
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
@@ -246,7 +247,7 @@ def test_pop(mode, chunk_mode):
246247
filenames = str(data_folder / "t.x1_SAMOC_flux.1690*.nc")
247248
variables = {"U": "UVEL", "V": "VVEL", "W": "WVEL"}
248249
timestamps = np.expand_dims(
249-
np.array([np.datetime64("2000-%.2d-01" % m) for m in range(1, 7)]), axis=1
250+
np.array([np.datetime64(f"2000-{m:02d}-01") for m in range(1, 7)]), axis=1
250251
)
251252
dimensions = {"lon": "ULON", "lat": "ULAT", "depth": "w_dep"}
252253
chs = False

docs/examples/example_decaying_moving_eddy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from datetime import timedelta
22

33
import numpy as np
4-
import parcels
54
import pytest
65

6+
import parcels
7+
78
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
89

910
# Define some constants.

docs/examples/example_globcurrent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
from glob import glob
33

44
import numpy as np
5-
import parcels
65
import pytest
76
import xarray as xr
87

8+
import parcels
9+
910
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
1011

1112

docs/examples/example_mitgcm.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from datetime import timedelta
2+
from pathlib import Path
3+
from typing import Literal
24

35
import numpy as np
4-
import parcels
56
import xarray as xr
67

8+
import parcels
9+
710
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
811

912

10-
def run_mitgcm_zonally_reentrant(mode):
13+
def run_mitgcm_zonally_reentrant(mode: Literal["scipy", "jit"], path: Path):
1114
"""Function that shows how to load MITgcm data in a zonally periodic domain."""
1215
data_folder = parcels.download_example_dataset("MITgcm_example_data")
1316
filenames = {
@@ -41,7 +44,7 @@ def periodicBC(particle, fieldset, time):
4144
size=10,
4245
)
4346
pfile = parcels.ParticleFile(
44-
"MIT_particles_" + str(mode) + ".zarr",
47+
str(path),
4548
pset,
4649
outputdt=timedelta(days=1),
4750
chunks=(len(pset), 1),
@@ -52,12 +55,15 @@ def periodicBC(particle, fieldset, time):
5255
)
5356

5457

55-
def test_mitgcm_output_compare():
56-
run_mitgcm_zonally_reentrant("scipy")
57-
run_mitgcm_zonally_reentrant("jit")
58+
def test_mitgcm_output_compare(tmpdir):
59+
def get_path(mode: Literal["scipy", "jit"]) -> Path:
60+
return tmpdir / f"MIT_particles_{mode}.zarr"
61+
62+
for mode in ["scipy", "jit"]:
63+
run_mitgcm_zonally_reentrant(mode, get_path(mode))
5864

59-
ds_jit = xr.open_zarr("MIT_particles_jit.zarr")
60-
ds_scipy = xr.open_zarr("MIT_particles_scipy.zarr")
65+
ds_jit = xr.open_zarr(get_path("jit"))
66+
ds_scipy = xr.open_zarr(get_path("scipy"))
6167

6268
np.testing.assert_allclose(ds_jit.lat.data, ds_scipy.lat.data)
6369
np.testing.assert_allclose(ds_jit.lon.data, ds_scipy.lon.data)

docs/examples/example_moving_eddies.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from datetime import timedelta
55

66
import numpy as np
7-
import parcels
87
import pytest
98

9+
import parcels
10+
1011
ptype = {"scipy": parcels.ScipyParticle, "jit": parcels.JITParticle}
1112
method = {
1213
"RK4": parcels.AdvectionRK4,
@@ -145,7 +146,7 @@ def moving_eddies_example(
145146

146147
# Execute for 1 week, with 1 hour timesteps and hourly output
147148
runtime = timedelta(days=7)
148-
print("MovingEddies: Advecting %d particles for %s" % (npart, str(runtime)))
149+
print(f"MovingEddies: Advecting {npart} particles for {runtime}")
149150
pset.execute(
150151
method,
151152
runtime=runtime,
@@ -176,7 +177,7 @@ def test_moving_eddies_fwdbwd(mode, mesh, tmpdir, npart=2):
176177
runtime = timedelta(days=1)
177178
dt = timedelta(minutes=5)
178179
outputdt = timedelta(hours=1)
179-
print("MovingEddies: Advecting %d particles for %s" % (npart, str(runtime)))
180+
print(f"MovingEddies: Advecting {npart} particles for {runtime}")
180181
outfile = tmpdir.join("EddyParticlefwd")
181182
pset.execute(
182183
method,

0 commit comments

Comments
 (0)