Skip to content

Commit 3314d61

Browse files
merge commit
2 parents bcf8878 + ca89010 commit 3314d61

File tree

12 files changed

+30
-379
lines changed

12 files changed

+30
-379
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
needs:
9898
- unit-test
9999
- integration-test
100+
- typechecking
100101
steps:
101102
- name: Merge Artifacts
102103
uses: actions/upload-artifact/merge@v4
@@ -116,13 +117,10 @@ jobs:
116117
- run: conda install lxml # dep for report generation
117118
- name: Typechecking
118119
run: |
119-
mypy --install-types --non-interactive parcels --cobertura-xml-report mypy_report
120-
- name: Upload mypy coverage to Codecov
121-
uses: codecov/[email protected]
122-
if: ${{ always() }} # Upload even on error of mypy
123-
env:
124-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
120+
mypy --install-types --non-interactive parcels --html-report mypy-report
121+
- name: Upload test results
122+
if: ${{ always() }} # Upload even on mypy error
123+
uses: actions/upload-artifact@v4
125124
with:
126-
file: mypy_report/cobertura.xml
127-
flags: mypy
128-
fail_ci_if_error: false
125+
name: Mypy report
126+
path: mypy-report

docs/documentation/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Parcels has several documentation and tutorial Jupyter notebooks and scripts whi
2020
../examples/tutorial_nemo_curvilinear.ipynb
2121
../examples/tutorial_nemo_3D.ipynb
2222
../examples/tutorial_croco_3D.ipynb
23-
../examples/tutorial_NestedFields.ipynb
2423
../examples/tutorial_timevaryingdepthdimensions.ipynb
2524
../examples/tutorial_periodic_boundaries.ipynb
2625
../examples/tutorial_interpolation.ipynb

docs/examples/tutorial_NestedFields.ipynb

Lines changed: 0 additions & 242 deletions
This file was deleted.

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies: #! Keep in sync with [tool.pixi.dependencies] in pyproject.toml
3030

3131
# Typing
3232
- mypy
33+
- lxml # in CI
3334
- types-tqdm
3435
- types-psutil
3536

parcels/field.py

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
from parcels.fieldset import FieldSet
5555

56-
__all__ = ["Field", "NestedField", "VectorField"]
56+
__all__ = ["Field", "VectorField"]
5757

5858

5959
def _isParticle(key):
@@ -140,11 +140,6 @@ class Field:
140140
Write the Field in NetCDF format at the same frequency as the ParticleFile outputdt,
141141
using a filenaming scheme based on the ParticleFile name
142142
143-
Examples
144-
--------
145-
For usage examples see the following tutorials:
146-
147-
* `Nested Fields <../examples/tutorial_NestedFields.ipynb>`__
148143
"""
149144

150145
allow_time_extrapolation: bool
@@ -1329,75 +1324,3 @@ def __getitem__(self, key):
13291324
return self.eval(*key)
13301325
except tuple(AllParcelsErrorCodes.keys()) as error:
13311326
return _deal_with_errors(error, key, vector_type=self.vector_type)
1332-
1333-
1334-
class NestedField(list):
1335-
"""NestedField is a class that allows for interpolation of fields on different grids of potentially varying resolution.
1336-
1337-
The NestedField class is a list of Fields where the first Field that contains the particle within the domain is then used for interpolation.
1338-
This induces that the order of the fields in the list matters.
1339-
Each one it its turn, a field is interpolated: if the interpolation succeeds or if an error other
1340-
than `ErrorOutOfBounds` is thrown, the function is stopped. Otherwise, next field is interpolated.
1341-
NestedField returns an `ErrorOutOfBounds` only if last field is as well out of boundaries.
1342-
NestedField is composed of either Fields or VectorFields.
1343-
1344-
Parameters
1345-
----------
1346-
name : str
1347-
Name of the NestedField
1348-
F : list of Field
1349-
List of fields (order matters). F can be a scalar Field, a VectorField, or the zonal component (U) of the VectorField
1350-
V : list of Field
1351-
List of fields defining the meridional component of a VectorField, if F is the zonal component. (default: None)
1352-
W : list of Field
1353-
List of fields defining the vertical component of a VectorField, if F and V are the zonal and meridional components (default: None)
1354-
1355-
1356-
Examples
1357-
--------
1358-
See `here <../examples/tutorial_NestedFields.ipynb>`__
1359-
for a detailed tutorial
1360-
1361-
"""
1362-
1363-
def __init__(self, name: str, F, V=None, W=None):
1364-
if V is None:
1365-
if isinstance(F[0], VectorField):
1366-
vector_type = F[0].vector_type
1367-
for Fi in F:
1368-
assert isinstance(Fi, Field) or (
1369-
isinstance(Fi, VectorField) and Fi.vector_type == vector_type
1370-
), "Components of a NestedField must be Field or VectorField"
1371-
self.append(Fi)
1372-
elif W is None:
1373-
for i, Fi, Vi in zip(range(len(F)), F, V, strict=True):
1374-
assert isinstance(Fi, Field) and isinstance(
1375-
Vi, Field
1376-
), "F, and V components of a NestedField must be Field"
1377-
self.append(VectorField(f"{name}_{i}", Fi, Vi))
1378-
else:
1379-
for i, Fi, Vi, Wi in zip(range(len(F)), F, V, W, strict=True):
1380-
assert (
1381-
isinstance(Fi, Field) and isinstance(Vi, Field) and isinstance(Wi, Field)
1382-
), "F, V and W components of a NestedField must be Field"
1383-
self.append(VectorField(f"{name}_{i}", Fi, Vi, Wi))
1384-
self.name = name
1385-
1386-
def __getitem__(self, key):
1387-
if isinstance(key, int):
1388-
return list.__getitem__(self, key)
1389-
else:
1390-
for iField in range(len(self)):
1391-
try:
1392-
if _isParticle(key):
1393-
val = list.__getitem__(self, iField).eval(key.time, key.depth, key.lat, key.lon, particle=None)
1394-
else:
1395-
val = list.__getitem__(self, iField).eval(*key)
1396-
break
1397-
except tuple(AllParcelsErrorCodes.keys()) as error:
1398-
if iField == len(self) - 1:
1399-
vector_type = self[iField].vector_type if isinstance(self[iField], VectorField) else None
1400-
return _deal_with_errors(error, key, vector_type=vector_type)
1401-
else:
1402-
pass
1403-
return val

0 commit comments

Comments
 (0)