Skip to content

Commit 3893730

Browse files
committed
Remove __contains__ and __getattr__ from Field
Overloaded behaviour that wasn't justified/used in the rest of the codebase.
1 parent d00880f commit 3893730

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

parcels/field.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,6 @@ def eval(self, time: datetime, z, y, x, particle=None, applyConversion=True):
316316
else:
317317
return value
318318

319-
def __getattr__(self, key: str):
320-
return getattr(self.data, key)
321-
322319
def __getitem__(self, key):
323320
self._check_velocitysampling()
324321
try:
@@ -329,9 +326,6 @@ def __getitem__(self, key):
329326
except tuple(AllParcelsErrorCodes.keys()) as error:
330327
return _deal_with_errors(error, key, vector_type=None)
331328

332-
def __contains__(self, key: str):
333-
return key in self.data
334-
335329

336330
class VectorField:
337331
"""VectorField class that holds vector field data needed to execute particles."""

tests/v4/test_uxarray_fieldset.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ def uvw_fesom_channel(ds_fesom_channel) -> VectorField:
7777
def test_fesom_fieldset(ds_fesom_channel, uv_fesom_channel):
7878
fieldset = FieldSet([uv_fesom_channel, uv_fesom_channel.U, uv_fesom_channel.V])
7979
# Check that the fieldset has the expected properties
80-
assert (fieldset.U == ds_fesom_channel.U).all()
81-
assert (fieldset.V == ds_fesom_channel.V).all()
80+
assert (fieldset.U.data == ds_fesom_channel.U).all()
81+
assert (fieldset.V.data == ds_fesom_channel.V).all()
8282

8383

8484
def test_fesom_in_particleset(ds_fesom_channel, uv_fesom_channel):
8585
fieldset = FieldSet([uv_fesom_channel, uv_fesom_channel.U, uv_fesom_channel.V])
8686

8787
# Check that the fieldset has the expected properties
88-
assert (fieldset.U == ds_fesom_channel.U).all()
89-
assert (fieldset.V == ds_fesom_channel.V).all()
88+
assert (fieldset.U.data == ds_fesom_channel.U).all()
89+
assert (fieldset.V.data == ds_fesom_channel.V).all()
9090
pset = ParticleSet(fieldset, pclass=Particle)
9191
assert pset.fieldset == fieldset
9292

9393

9494
def test_set_interp_methods(ds_fesom_channel, uv_fesom_channel):
9595
fieldset = FieldSet([uv_fesom_channel, uv_fesom_channel.U, uv_fesom_channel.V])
9696
# Check that the fieldset has the expected properties
97-
assert (fieldset.U == ds_fesom_channel.U).all()
98-
assert (fieldset.V == ds_fesom_channel.V).all()
97+
assert (fieldset.U.data == ds_fesom_channel.U).all()
98+
assert (fieldset.V.data == ds_fesom_channel.V).all()
9999

100100
# Set the interpolation method for each field
101101
fieldset.U.interp_method = UXPiecewiseConstantFace

0 commit comments

Comments
 (0)