Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/user_guide/v4-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ Remove the <code>chunks</code> argument from your code
<hr class="migration-divider" />

<div class="migration-bubble migration-change">
<code>ParticleFile</code> does not have a <code>to_write</code> argument
<code>ParticleFile</code> does not have a <code>to_write="once"</code> argument
</div>
<div class="migration-bubble migration-how">
Remove the <code>to_write</code> argument from your code
Either write all timesteps of a variable, or none
</div>
<hr class="migration-divider" />

Expand Down
12 changes: 0 additions & 12 deletions src/parcels/_core/particleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 0 additions & 32 deletions tests/test_particlefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,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)."""

Expand All @@ -489,32 +483,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",
[
Expand Down
Loading