Skip to content

Commit 097381f

Browse files
committed
Add xfailed test_pfile_set_towrite_False back to test_particlefile.py
1 parent 855ed76 commit 097381f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/v4/test_particlefile.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,35 @@ def test_particlefile_write_particle_data(tmp_store):
452452
# np.testing.assert_equal(ds["time"].isel(obs=0).values, left)
453453
assert ds.sizes["trajectory"] == nparticles
454454
np.testing.assert_allclose(ds["lon"].isel(obs=0).values, initial_lon)
455+
456+
457+
def test_pfile_write_custom_particle():
458+
# Test the writing of a custom particle with variables that are to_write, some to_write once, and some not to_write
459+
# ? This is more of an integration test... Should it be housed here?
460+
...
461+
462+
463+
@pytest.mark.xfail(
464+
reason="set_variable_write_status should be removed - with Particle writing defined on the particle level. GH2186"
465+
)
466+
def test_pfile_set_towrite_False(fieldset, tmp_zarrfile):
467+
npart = 10
468+
pset = ParticleSet(fieldset, pclass=Particle, lon=np.linspace(0, 1, npart), lat=0.5 * np.ones(npart))
469+
pset.set_variable_write_status("depth", False)
470+
pset.set_variable_write_status("lat", False)
471+
pfile = pset.ParticleFile(tmp_zarrfile, outputdt=1)
472+
473+
def Update_lon(particle, fieldset, time): # pragma: no cover
474+
particle.dlon += 0.1
475+
476+
pset.execute(Update_lon, runtime=10, output_file=pfile)
477+
478+
ds = xr.open_zarr(tmp_zarrfile)
479+
assert "time" in ds
480+
assert "z" not in ds
481+
assert "lat" not in ds
482+
ds.close()
483+
484+
# For pytest purposes, we need to reset to original status
485+
pset.set_variable_write_status("depth", True)
486+
pset.set_variable_write_status("lat", True)

0 commit comments

Comments
 (0)