Skip to content

Commit 846520b

Browse files
Merge branch 'master' into fieldset_from_directory
2 parents 133426f + c2bf42c commit 846520b

6 files changed

Lines changed: 53 additions & 11 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,17 @@ jobs:
9494
user: __token__
9595
password: ${{ secrets.PARCELS_PYPI_PROD_TOKEN }}
9696
verbose: true
97+
98+
test-pypi-release:
99+
needs: upload-to-pypi
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: conda-incubator/setup-miniconda@v3
103+
with:
104+
activate-environment: parcels
105+
python-version: 3.8
106+
channels: conda-forge
107+
- run: conda install -c conda-forge c-compiler pip
108+
- run: pip install parcels --no-cache
109+
- run: curl https://raw.githubusercontent.com/OceanParcels/parcels/master/docs/examples/example_peninsula.py > example_peninsula.py
110+
- run: python example_peninsula.py

docs/examples/example_globcurrent.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,6 @@ def test_globcurrent_time_extrapolation_error(mode, use_xarray):
173173
pset.execute(AdvectionRK4, runtime=delta(days=1), dt=delta(minutes=5))
174174

175175

176-
@pytest.mark.parametrize('mode', ['scipy', 'jit'])
177-
@pytest.mark.parametrize('use_xarray', [True, False])
178-
def test_globcurrent_dt0(mode, use_xarray):
179-
fieldset = set_globcurrent_fieldset(use_xarray=use_xarray)
180-
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=[25], lat=[-35])
181-
pset.execute(AdvectionRK4, dt=0.)
182-
183-
184176
@pytest.mark.parametrize('mode', ['scipy', 'jit'])
185177
@pytest.mark.parametrize('dt', [-300, 300])
186178
@pytest.mark.parametrize('with_starttime', [True, False])
@@ -260,3 +252,22 @@ def test_globcurrent_pset_fromfile(mode, dt, pid_offset, tmpdir):
260252

261253
for var in ['lon', 'lat', 'depth', 'time', 'id']:
262254
assert np.allclose([getattr(p, var) for p in pset], [getattr(p, var) for p in pset_new])
255+
256+
257+
@pytest.mark.parametrize('mode', ['scipy', 'jit'])
258+
def test_error_outputdt_not_multiple_dt(mode, tmpdir):
259+
# Test that outputdt is a multiple of dt
260+
fieldset = set_globcurrent_fieldset()
261+
262+
filepath = tmpdir.join("pfile_error_outputdt_not_multiple_dt.zarr")
263+
264+
dt = 81.2584344538292 # number for which output writing fails
265+
266+
pset = ParticleSet(fieldset, pclass=ptype[mode], lon=[0], lat=[0])
267+
ofile = pset.ParticleFile(name=filepath, outputdt=delta(days=1))
268+
269+
def DoNothing(particle, fieldset, time):
270+
pass
271+
272+
with pytest.raises(ValueError):
273+
pset.execute(DoNothing, runtime=delta(days=10), dt=dt, output_file=ofile)

docs/examples/tutorial_parcels_structure.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@
450450
"source": [
451451
"### For more tutorials on MPI and parallelisation:\n",
452452
"\n",
453-
"- [Optimising the partitioning of the particles with a user-defined `partition_function`](https://docs.oceanparcels.org/en/latest/examples/documentation_MPI.html#Optimising-the-partitioning-of-the-particles-with-a-user-defined-partition_function)\n",
453+
"- [Optimising the partitioning of the particles with a user-defined partition function](https://docs.oceanparcels.org/en/latest/examples/documentation_MPI.html#Optimising-the-partitioning-of-the-particles-with-a-user-defined-partition_function)\n",
454454
"- [Future developments: load balancing](https://docs.oceanparcels.org/en/latest/examples/documentation_MPI.html#Future-developments:-load-balancing)"
455455
]
456456
},

parcels/particleset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,10 @@ def execute(self, pyfunc=AdvectionRK4, pyfunc_inter=None, endtime=None, runtime=
878878
runtime = runtime.total_seconds()
879879
if isinstance(dt, delta):
880880
dt = dt.total_seconds()
881-
if dt > 0 and dt <= 1e-6:
881+
if abs(dt) <= 1e-6:
882882
raise ValueError('Time step dt is too small')
883+
if (dt * 1e6) % 1 != 0:
884+
raise ValueError('Output interval should not have finer precision than 1e-6 s')
883885
outputdt = output_file.outputdt if output_file else np.infty
884886
if isinstance(outputdt, delta):
885887
outputdt = outputdt.total_seconds()

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ classifiers = [
1919
"Topic :: Scientific/Engineering",
2020
"Intended Audience :: Science/Research",
2121
]
22+
dependencies = [
23+
"cgen",
24+
"cftime",
25+
"numpy",
26+
"dask",
27+
"cftime",
28+
"psutil",
29+
"netCDF4",
30+
"zarr",
31+
"tqdm",
32+
"pymbolic",
33+
"pytest",
34+
"scipy",
35+
"xarray",
36+
]
2237

2338
[project.urls]
2439
homepage = "https://oceanparcels.org/"

tests/test_interaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def f(p):
169169

170170
@pytest.mark.parametrize('runtime, dt',
171171
[(1, 1e-2),
172-
(1, -2.1234e-3),
172+
(1, -2.123e-3),
173173
(1, -3.12452-3)])
174174
def test_pseudo_interaction(runtime, dt):
175175
# A linear field where advected particles are moving at

0 commit comments

Comments
 (0)