Skip to content

Commit 6aaf85b

Browse files
Adding test for creating particles outside time
1 parent be14654 commit 6aaf85b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/v4/test_particleset.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
import numpy as np
55
import pytest
6+
import xarray as xr
67

78
from parcels import (
89
AdvectionEE,
910
Field,
1011
FieldSet,
1112
Particle,
1213
ParticleSet,
14+
ParticleSetWarning,
1315
StatusCode,
1416
UXPiecewiseConstantFace,
1517
VectorField,
@@ -79,6 +81,12 @@ def test_particleset_init_time_type(fieldset, time, expectation):
7981
ParticleSet(fieldset, lon=[0.2], lat=[5.0], time=[time], pclass=Particle)
8082

8183

84+
def test_pset_create_outside_time(fieldset):
85+
time = xr.date_range("1999", "2001", 20)
86+
with pytest.warns(ParticleSetWarning, match="Some particles are set to be released*"):
87+
ParticleSet(fieldset, pclass=Particle, lon=[0] * len(time), lat=[0] * len(time), time=time)
88+
89+
8290
@pytest.mark.parametrize(
8391
"dt, expectation",
8492
[

0 commit comments

Comments
 (0)