Skip to content

Commit

Permalink
Adding simple test for particle start times that are not multiple of dt
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvansebille committed Nov 9, 2021
1 parent c2f188e commit 1e9dec9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_particle_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ def test_pset_create_with_time(fieldset, pset_mode, mode, npart=100):
assert np.allclose([p.time for p in pset], time, rtol=1e-12)


@pytest.mark.parametrize('pset_mode', pset_modes)
@pytest.mark.parametrize('mode', ['scipy', 'jit'])
def test_pset_not_multipldt_time(fieldset, pset_mode, mode):
times = [0, 1.1]
pset = pset_type[pset_mode]['pset'](fieldset, lon=[0]*2, lat=[0]*2, pclass=ptype[mode], time=times)

def Addlon(particle, fieldset, time):
particle.lon += particle.dt

pset.execute(Addlon, dt=1, runtime=2)
assert np.allclose([p.lon for p in pset], [2 - t for t in times])


@pytest.mark.parametrize('pset_mode', pset_modes)
@pytest.mark.parametrize('mode', ['scipy', 'jit'])
def test_pset_repeated_release(fieldset, pset_mode, mode, npart=10):
Expand Down

0 comments on commit 1e9dec9

Please sign in to comment.