From 0e99bc2d7ebf457b2eda5525ea84d081417fa575 Mon Sep 17 00:00:00 2001 From: Vecko <36369090+VeckoTheGecko@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:52:26 +0200 Subject: [PATCH] API changes Make FieldSet.add_UVfield() private and Field.dimensions read only --- parcels/field.py | 6 +++++- parcels/fieldset.py | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/parcels/field.py b/parcels/field.py index 425989590..b3a63cc98 100644 --- a/parcels/field.py +++ b/parcels/field.py @@ -281,7 +281,7 @@ def __init__( self._scaling_factor = None # Variable names in JIT code - self.dimensions = kwargs.pop("dimensions", None) + self._dimensions = kwargs.pop("dimensions", None) self.indices = kwargs.pop("indices", None) self._dataFiles = kwargs.pop("dataFiles", None) if self.grid._add_last_periodic_data_timestep and self._dataFiles is not None: @@ -341,6 +341,10 @@ def creation_log(self): def loaded_time_indices(self): return self._loaded_time_indices + @property + def dimensions(self): + return self._dimensions + @property def grid(self): return self._grid diff --git a/parcels/fieldset.py b/parcels/fieldset.py index 7d2c6002c..1799f3d2a 100644 --- a/parcels/fieldset.py +++ b/parcels/fieldset.py @@ -54,7 +54,7 @@ def __init__(self, U: Field | NestedField | None, V: Field | NestedField | None, self.add_field(field, name) self.compute_on_defer = None - self.add_UVfield() + self._add_UVfield() @property def particlefile(self): @@ -245,7 +245,11 @@ def add_vector_field(self, vfield): for f in vfield: f.fieldset = self - def add_UVfield(self): + @deprecated_made_private # TODO: Remove 6 months after v3.1.0 + def add_UVfield(self, *args, **kwargs): + return self._add_UVfield(*args, **kwargs) + + def _add_UVfield(self): if not hasattr(self, "UV") and hasattr(self, "U") and hasattr(self, "V"): if isinstance(self.U, NestedField): self.add_vector_field(NestedField("UV", self.U, self.V)) @@ -313,7 +317,7 @@ def check_velocityfields(U, V, W): if g.defer_load: g.time_full = g.time_full + self.time_origin.reltime(g.time_origin) g.time_origin = self.time_origin - self.add_UVfield() + self._add_UVfield() ccode_fieldnames = [] counter = 1