From 76198cbf08cee8fe526ce4be904e7f4af0fe0baf Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Tue, 20 Oct 2026 17:34:06 +0200 Subject: [PATCH 1/2] Removing set_variable_write_status Which was not tested and used. And in parquet does not make sense. During investigation, I also realised that the migration guide was wrong --- docs/user_guide/v4-migration.md | 4 ++-- src/parcels/_core/particleset.py | 12 ------------ tests/test_particlefile.py | 26 -------------------------- 3 files changed, 2 insertions(+), 40 deletions(-) diff --git a/docs/user_guide/v4-migration.md b/docs/user_guide/v4-migration.md index d05591f0d..eebebb629 100644 --- a/docs/user_guide/v4-migration.md +++ b/docs/user_guide/v4-migration.md @@ -344,10 +344,10 @@ Remove the chunks argument from your code
-ParticleFile does not have a to_write argument +ParticleFile does not have a to_write="once" argument
-Remove the to_write argument from your code +Either write all timesteps of a variable, or none

diff --git a/src/parcels/_core/particleset.py b/src/parcels/_core/particleset.py index 207d7b620..77c6d7f76 100644 --- a/src/parcels/_core/particleset.py +++ b/src/parcels/_core/particleset.py @@ -351,18 +351,6 @@ def _num_error_particles(self): """ return int(np.sum(self._data["state"] != StatusCode.Success)) - def set_variable_write_status(self, var, write_status): - """Method to set the write status of a Variable. - - Parameters - ---------- - var : - Name of the variable (string) - write_status : - Write status of the variable (True, False or 'once') - """ - self._data[var].set_variable_write_status(write_status) - def execute( self, kernels, diff --git a/tests/test_particlefile.py b/tests/test_particlefile.py index a334fd605..7b7f5df9d 100755 --- a/tests/test_particlefile.py +++ b/tests/test_particlefile.py @@ -486,32 +486,6 @@ def ErrorKernel(particles, fieldset): # pragma: no cover assert len(df) >= 1 # at least the initial condition was written -@pytest.mark.xfail( - reason="set_variable_write_status should be removed - with Particle writing defined on the particle level. GH2186" -) -def test_pfile_set_towrite_False(fieldset, tmp_parquet): - npart = 10 - pset = ParticleSet(fieldset, pclass=Particle, x=np.linspace(0, 1, npart), y=0.5 * np.ones(npart)) - pset.set_variable_write_status("z", False) - pset.set_variable_write_status("lat", False) - pfile = pset.ParticleFile(tmp_parquet, outputdt=1) - - def Update_lon(particles, fieldset): # pragma: no cover - particles.dx += 0.1 - - pset.execute(Update_lon, runtime=10, output_file=pfile) - - ds = xr.open_zarr(tmp_parquet) - assert "t" in ds - assert "z" not in ds - assert "lat" not in ds - ds.close() - - # For pytest purposes, we need to reset to original status - pset.set_variable_write_status("z", True) - pset.set_variable_write_status("lat", True) - - @pytest.mark.parametrize( "particle", [ From 7a462a5a2c4baf51b6f9f9ee100cfbc81e616bcb Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 22 Oct 2026 10:39:03 +0200 Subject: [PATCH 2/2] Removing another irrelevant test --- tests/test_particlefile.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test_particlefile.py b/tests/test_particlefile.py index 7b7f5df9d..fd46c4688 100755 --- a/tests/test_particlefile.py +++ b/tests/test_particlefile.py @@ -463,12 +463,6 @@ def test_particlefile_init_invalid(tmp_path): ParticleFile(path, outputdt=np.timedelta64(1, "s")) -def test_pfile_write_custom_particle(): - # Test the writing of a custom particle with variables that are to_write, some to_write once, and some not to_write - # ? This is more of an integration test... Should it be housed here? - ... - - def test_particlefile_readable_after_kernel_error(fieldset, tmp_parquet): """Parquet output file must be readable even if the kernel raises an error mid-execution (GH-2713)."""