Skip to content

Commit

Permalink
API changes
Browse files Browse the repository at this point in the history
Make FieldSet.add_UVfield() private and Field.dimensions read only
  • Loading branch information
VeckoTheGecko committed Sep 23, 2024
1 parent 35bb37c commit 0e99bc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion parcels/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -341,6 +341,10 @@ def creation_log(self):
def loaded_time_indices(self):
return self._loaded_time_indices

Check warning on line 342 in parcels/field.py

View check run for this annotation

Codecov / codecov/patch

parcels/field.py#L342

Added line #L342 was not covered by tests

@property
def dimensions(self):
return self._dimensions

@property
def grid(self):
return self._grid
Expand Down
10 changes: 7 additions & 3 deletions parcels/fieldset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

Check warning on line 250 in parcels/fieldset.py

View check run for this annotation

Codecov / codecov/patch

parcels/fieldset.py#L250

Added line #L250 was not covered by tests

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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0e99bc2

Please sign in to comment.