Skip to content

Commit 5335cd8

Browse files
Merge branch 'v4-dev' into croco-support
2 parents d636f0e + 92a3b75 commit 5335cd8

76 files changed

Lines changed: 4889 additions & 3204 deletions

Some content is hidden

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

.github/ci/min_deps_check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def parse_requirements(fname) -> Iterator[tuple[str, int, int, int | None]]:
6060

6161
try:
6262
version_tup = tuple(int(x) for x in version.split("."))
63-
except ValueError:
64-
raise ValueError("non-numerical version: " + row)
63+
except ValueError as e:
64+
raise ValueError("non-numerical version: " + row) from e
6565

6666
if len(version_tup) == 2:
6767
yield (pkg, *version_tup, None) # type: ignore[misc]
@@ -193,7 +193,7 @@ def main() -> None:
193193
print("\nErrors:")
194194
print("-------")
195195
for i, e in enumerate(errors):
196-
print(f"{i+1}. {e}")
196+
print(f"{i + 1}. {e}")
197197
sys.exit(1)
198198

199199

.github/workflows/pypi-release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ jobs:
9090
path: dist
9191
- name: Publish package to PyPI
9292
uses: pypa/gh-action-pypi-publish@v1.12.4
93-
with:
94-
user: __token__
95-
password: ${{ secrets.PARCELS_PYPI_PROD_TOKEN }}
96-
verbose: true
9793

9894
test-pypi-release:
9995
needs: upload-to-pypi

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
types: [text]
1111
files: \.(json|ipynb)$
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.8.6
13+
rev: v0.12.5
1414
hooks:
1515
- id: ruff
1616
name: ruff lint (.py)
@@ -23,13 +23,13 @@ repos:
2323
- id: ruff-format
2424
types_or: [python, jupyter]
2525
- repo: https://github.com/rbubley/mirrors-prettier # Update mirror as official mirror is deprecated
26-
rev: v3.4.2
26+
rev: v3.6.2
2727
hooks:
2828
- id: prettier
2929

3030
# Ruff doesn't have full coverage of pydoclint https://github.com/astral-sh/ruff/issues/12434
3131
- repo: https://github.com/PyCQA/flake8
32-
rev: 7.1.1
32+
rev: 7.3.0
3333
hooks:
3434
- id: flake8
3535
name: pydoclint

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[![Anaconda-release](https://anaconda.org/conda-forge/parcels/badges/version.svg)](https://anaconda.org/conda-forge/parcels/)
44
[![Anaconda-date](https://anaconda.org/conda-forge/parcels/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/parcels/)
55
[![Zenodo](https://zenodo.org/badge/DOI/10.5281/zenodo.823561.svg)](https://doi.org/10.5281/zenodo.823561)
6-
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
6+
[![Xarray](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydata/xarray/refs/heads/main/doc/badge.json)](https://xarray.dev)
7+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
78
[![unit-tests](https://github.com/OceanParcels/parcels/actions/workflows/ci.yml/badge.svg)](https://github.com/OceanParcels/parcels/actions/workflows/ci.yml)
89
[![codecov](https://codecov.io/gh/OceanParcels/parcels/branch/main/graph/badge.svg)](https://codecov.io/gh/OceanParcels/parcels)
910
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5353/badge)](https://bestpractices.coreinfrastructure.org/projects/5353)

docs/community/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ See the sections in the primary sidebar and below to explore.
1010

1111
contributing
1212
Versioning and Deprecation Policies <policies>
13+
Release Notes <https://github.com/OceanParcels/Parcels/releases>
14+
Parcels v4.0 Migration Guide <v4-migration>
1315

1416

1517

docs/community/v4-migration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Parcels v4 migration guide
2+
3+
```{warning}
4+
Version 4 of Parcels is unreleased at the moment. The information in this migration guide is a work in progress, and is subject to change. If you would like to provide feedback on this migration guide (or generally on the development of v4) please [submit an issue](https://github.com/OceanParcels/Parcels/issues/new/choose).
5+
```
6+
7+
## Kernels
8+
9+
- The Kernel loop has been 'vectorized', so that the input of a Kernel is not one particle anymore, but a collection of particles. This means that `if`-statements in Kernels don't work anymore. Replace `if`-statements with `numpy.where` statements.
10+
- `particle.delete()` is no longer valid. Instead, use `particle.state = StatusCode.Delete`.
11+
- Sharing state between kernels must be done via the particle data (as the kernels are not combined under the hood anymore).
12+
- `particl_dlon`, `particle_dlat` etc have been renamed to `particle.dlon` and `particle.dlat`.
13+
- `particle.dt` is a np.timedelta64 object; be careful when multiplying `particle.dt` with a velocity, as its value may be cast to nanoseconds.
14+
- The `time` argument in the Kernel signature is now standard `None` (and may be removed in the Kernel API before release of v4), so can't be used. Use `particle.time` instead.
15+
- `math` functions should be replaced with array compatible equivalents (e.g., `math.sin` -> `np.sin`). Instead of `ParcelsRandom` you should use numpy's random functions.
16+
17+
## FieldSet
18+
19+
- `interp_method` has to be an Interpolation function, instead of a string.
20+
21+
## ParticleSet
22+
23+
- `repeatdt` and `lonlatdepth_dtype` have been removed from the ParticleSet.
24+
- ParticleSet.execute() expects `numpy.datetime64`/`numpy.timedelta.64` for `runtime`, `endtime` and `dt`.
25+
- `ParticleSet.from_field()`, `ParticleSet.from_line()`, `ParticleSet.from_list()` have been removed.
26+
27+
## ParticleFile
28+
29+
- Particlefiles should be created by `ParticleFile(...)` instead of `pset.ParticleFile(...)`

docs/examples/example_globcurrent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def test_globcurrent_particle_independence(rundays=5):
196196
time0 = fieldset.U.grid.time[0]
197197

198198
def DeleteP0(particle, fieldset, time): # pragma: no cover
199-
if particle.id == 0:
199+
if particle.trajectory == 0:
200200
particle.delete()
201201

202202
pset0 = parcels.ParticleSet(
@@ -244,7 +244,7 @@ def test_globcurrent_pset_fromfile(dt, pid_offset, tmpdir):
244244
pset.execute(parcels.AdvectionRK4, runtime=timedelta(days=1), dt=dt)
245245
pset_new.execute(parcels.AdvectionRK4, runtime=timedelta(days=1), dt=dt)
246246

247-
for var in ["lon", "lat", "depth", "time", "id"]:
247+
for var in ["lon", "lat", "depth", "time", "trajectory"]:
248248
assert np.allclose(
249249
[getattr(p, var) for p in pset], [getattr(p, var) for p in pset_new]
250250
)

docs/examples/example_mitgcm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def run_mitgcm_zonally_reentrant(path: Path):
2727

2828
def periodicBC(particle, fieldset, time): # pragma: no cover
2929
if particle.lon < 0:
30-
particle_dlon += fieldset.domain_width # noqa
30+
particle.dlon += fieldset.domain_width
3131
elif particle.lon > fieldset.domain_width:
32-
particle_dlon -= fieldset.domain_width
32+
particle.dlon -= fieldset.domain_width
3333

3434
# Release particles 5 cells away from the Eastern boundary
3535
pset = parcels.ParticleSet.from_line(

docs/examples/example_moving_eddies.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,17 @@ def test_periodic_and_computeTimeChunk_eddies():
272272

273273
def periodicBC(particle, fieldset, time): # pragma: no cover
274274
if particle.lon < fieldset.halo_west:
275-
particle_dlon += fieldset.halo_east - fieldset.halo_west # noqa
275+
particle.dlon += fieldset.halo_east - fieldset.halo_west
276276
elif particle.lon > fieldset.halo_east:
277-
particle_dlon -= fieldset.halo_east - fieldset.halo_west
277+
particle.dlon -= fieldset.halo_east - fieldset.halo_west
278278
if particle.lat < fieldset.halo_south:
279-
particle_dlat += fieldset.halo_north - fieldset.halo_south # noqa
279+
particle.dlat += fieldset.halo_north - fieldset.halo_south
280280
elif particle.lat > fieldset.halo_north:
281-
particle_dlat -= fieldset.halo_north - fieldset.halo_south
281+
particle.dlat -= fieldset.halo_north - fieldset.halo_south
282282

283283
def slowlySouthWestward(particle, fieldset, time): # pragma: no cover
284-
particle_dlon -= 5 * particle.dt / 1e5 # noqa
285-
particle_dlat -= 3 * particle.dt / 1e5 # noqa
284+
particle.dlon -= 5 * particle.dt / 1e5
285+
particle.dlat -= 3 * particle.dt / 1e5
286286

287287
kernels = pset.Kernel(parcels.AdvectionRK4) + slowlySouthWestward + periodicBC
288288
pset.execute(kernels, runtime=timedelta(days=6), dt=timedelta(hours=1))

docs/examples/example_nemo_curvilinear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def run_nemo_curvilinear(outfile, advtype="RK4"):
4343

4444
def periodicBC(particle, fieldSet, time): # pragma: no cover
4545
if particle.lon > 180:
46-
particle_dlon -= 360 # noqa
46+
particle.dlon -= 360
4747

4848
pset = parcels.ParticleSet.from_list(fieldset, parcels.Particle, lon=lonp, lat=latp)
4949
pfile = parcels.ParticleFile(outfile, pset, outputdt=timedelta(days=1))

0 commit comments

Comments
 (0)