Skip to content

Commit a6ac036

Browse files
Merge branch 'v4-dev' into circulation_models_part2
2 parents ee4817d + 7d2157c commit a6ac036

12 files changed

Lines changed: 496 additions & 628 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,16 @@ defaults:
1818

1919
jobs:
2020
unit-test:
21-
name: "py${{ matrix.python-version }} | ${{ matrix.os }} | unit tests (${{ matrix.test-subfolder }})"
21+
name: "py${{ matrix.python-version }} | ${{ matrix.os }} | unit tests"
2222
runs-on: ${{ matrix.os }}-latest
2323
strategy:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu] #, mac, windows] # TODO v4: Re-enable windows and mac
27-
test-subfolder: ["/"]
2827
python-version: ["3.12"]
2928
include:
3029
- os: ubuntu
3130
python-version: "3.11"
32-
test-subfolder: "/"
33-
- os: ubuntu
34-
python-version: "3.12"
35-
test-subfolder: "/v4"
3631
steps:
3732
- name: Checkout
3833
uses: actions/checkout@v4
@@ -43,7 +38,7 @@ jobs:
4338
python-version: ${{ matrix.python-version }}
4439
- name: Unit test
4540
run: |
46-
coverage run -m pytest -v -s --html=${{ matrix.os }}_${{ matrix.python-version }}_unit_test_report.html --self-contained-html tests${{ matrix.test-subfolder }}
41+
coverage run -m pytest -v -s --html=${{ matrix.os }}_${{ matrix.python-version }}_unit_test_report.html --self-contained-html
4742
coverage xml
4843
- name: Codecov
4944
uses: codecov/codecov-action@v5.3.1
@@ -58,6 +53,8 @@ jobs:
5853
name: Unittest report ${{ matrix.os }}-${{ matrix.python-version }}
5954
path: ${{ matrix.os }}_${{ matrix.python-version }}_unit_test_report.html
6055
integration-test:
56+
# TODO v4: Re-enable the workflow once development has stabilized and we want to run integration tests again
57+
if: false
6158
name: "py${{ matrix.python-version }} | ${{ matrix.os }} | integration tests"
6259
runs-on: ${{ matrix.os }}-latest
6360
strategy:
@@ -111,6 +108,8 @@ jobs:
111108
pattern: "* report *"
112109
typechecking:
113110
name: mypy
111+
# TODO v4: Enable typechecking again
112+
if: false
114113
runs-on: ubuntu-latest
115114
steps:
116115
- name: Checkout

docs/examples/tutorial_stommel_uxarray.ipynb

Lines changed: 287 additions & 261 deletions
Large diffs are not rendered by default.

parcels/_core/utils/time.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import cftime
77
import numpy as np
88

9-
T = TypeVar("T", datetime, cftime.datetime)
10-
119
if TYPE_CHECKING:
12-
from parcels._typing import DatetimeLike
10+
from parcels._typing import TimeLike
11+
12+
T = TypeVar("T", bound="TimeLike")
1313

1414

1515
class TimeInterval:
@@ -92,7 +92,7 @@ def is_compatible(
9292

9393

9494
def get_datetime_type_calendar(
95-
example_datetime: DatetimeLike,
95+
example_datetime: TimeLike,
9696
) -> tuple[type, str | None]:
9797
"""Get the type and calendar of a datetime object.
9898

parcels/_core/utils/unstructured.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from collections.abc import Hashable
2-
31
DIM_TO_VERTICAL_LOCATION_MAP = {
42
"nz1": "center",
53
"nz": "face",
64
}
75

86

9-
def get_vertical_location_from_dims(dims: tuple[Hashable, ...]):
7+
def get_vertical_location_from_dims(dims: tuple[str, ...]):
108
"""
119
Determine the vertical location of the field based on the uxarray.UxDataArray object variables.
1210

parcels/_index_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def _search_indices_curvilinear_2d(
356356

357357

358358
## TODO : Still need to implement the search_indices_curvilinear
359-
def _search_indices_curvilinear(field: Field, time, z, y, x, ti, particle=None, search2D=False):
359+
def _search_indices_curvilinear(field, time, z, y, x, ti, particle=None, search2D=False):
360360
if particle:
361361
zi, yi, xi = field.unravel_index(particle.ei)
362362
else:

parcels/_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
VectorType = Literal["3D", "3DSigma", "2D"] | None # corresponds with `vector_type`
3535
GridIndexingType = Literal["pop", "mom5", "mitgcm", "nemo", "croco"] # corresponds with `gridindexingtype`
3636
NetcdfEngine = Literal["netcdf4", "xarray", "scipy"]
37-
DatetimeLike = datetime | cftime_datetime | np.datetime64
37+
TimeLike = datetime | cftime_datetime | np.datetime64
3838

3939
KernelFunction = Callable[..., None]
4040

parcels/fieldset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from parcels.xgrid import XGrid
1616

1717
if TYPE_CHECKING:
18-
from parcels._typing import DatetimeLike
18+
from parcels._typing import TimeLike
1919
from parcels.basegrid import BaseGrid
2020
__all__ = ["FieldSet"]
2121

@@ -57,7 +57,7 @@ def __init__(self, fields: list[Field | VectorField]):
5757
assert_compatible_calendars(fields)
5858

5959
self.fields = {f.name: f for f in fields}
60-
self.constants = {}
60+
self.constants: dict[str, float] = {}
6161

6262
def __getattr__(self, name):
6363
"""Get the field by name. If the field is not found, check if it's a constant."""
@@ -236,7 +236,7 @@ class CalendarError(Exception): # TODO: Move to a parcels errors module
236236
"""Exception raised when the calendar of a field is not compatible with the rest of the Fields. The user should ensure that they only add fields to a FieldSet that have compatible CFtime calendars."""
237237

238238

239-
def assert_compatible_calendars(fields: Iterable[Field]):
239+
def assert_compatible_calendars(fields: Iterable[Field | VectorField]):
240240
time_intervals = [f.time_interval for f in fields if f.time_interval is not None]
241241

242242
if len(time_intervals) == 0: # All time intervals are none
@@ -253,13 +253,13 @@ def assert_compatible_calendars(fields: Iterable[Field]):
253253
raise CalendarError(msg)
254254

255255

256-
def _datetime_to_msg(example_datetime: DatetimeLike) -> str:
256+
def _datetime_to_msg(example_datetime: TimeLike) -> str:
257257
datetime_type, calendar = get_datetime_type_calendar(example_datetime)
258258
msg = str(datetime_type)
259259
if calendar is not None:
260260
msg += f" with cftime calendar {calendar}'"
261261
return msg
262262

263263

264-
def _format_calendar_error_message(field: Field, reference_datetime: DatetimeLike) -> str:
264+
def _format_calendar_error_message(field: Field, reference_datetime: TimeLike) -> str:
265265
return f"Expected field {field.name!r} to have calendar compatible with datetime object {_datetime_to_msg(reference_datetime)}. Got field with calendar {_datetime_to_msg(field.time_interval.left)}. Have you considered using xarray to update the time dimension of the dataset to have a compatible calendar?"

parcels/kernel.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
AdvectionRK4_3D_CROCO,
1717
AdvectionRK45,
1818
)
19-
from parcels.field import VectorField
2019
from parcels.grid import GridType
2120
from parcels.tools.statuscodes import (
2221
StatusCode,
@@ -313,12 +312,6 @@ def execute(self, pset, endtime, dt):
313312
stacklevel=2,
314313
)
315314

316-
if pset.fieldset is not None:
317-
for f in self.fieldset.fields.values():
318-
if isinstance(f, VectorField):
319-
continue
320-
f.data = np.array(f.data)
321-
322315
if not self._positionupdate_kernels_added:
323316
self.add_positionupdate_kernels()
324317
self._positionupdate_kernels_added = True

0 commit comments

Comments
 (0)