88from parcels import FieldSet , ParticleSet
99from parcels ._core ._windowed_array import WindowedArray , maybe_windowed
1010from parcels ._datasets .structured .generated import simple_UV_dataset
11+ from parcels ._datasets .unstructured .generic import _ux_constant_flow_face_centered_2D
1112from parcels .kernels import AdvectionRK2
1213
1314
@@ -70,8 +71,7 @@ def test_windowed_isel_backward_clock_loads_once_and_evicts():
7071 assert win .loads == ntime # each time level read exactly once, going backward
7172 assert max_cache <= 2 # only the bracketing levels resident
7273
73-
74- def test_to_windowed_arrays_wraps_dask_but_not_numpy ():
74+ def test_structured_windowed_arrays_wraps_dask_but_not_numpy ():
7575 ds = simple_UV_dataset (mesh = "flat" )
7676 fset_np = FieldSet .from_sgrid_conventions (ds , mesh = "flat" )
7777 fset_dk = FieldSet .from_sgrid_conventions (ds .chunk ({"time" : 1 }), mesh = "flat" )
@@ -91,6 +91,25 @@ def test_to_windowed_arrays_wraps_dask_but_not_numpy():
9191 assert fset_dk .U .data .dims == fset_np .U .data .dims
9292 assert fset_dk .U .data .shape == fset_np .U .data .shape
9393
94+ def test_unstructured_windowed_arrays_wraps_dask_but_not_numpy ():
95+ ds = _ux_constant_flow_face_centered_2D ()
96+ fset_np = FieldSet .from_ugrid_conventions (ds , mesh = "flat" )
97+ fset_dk = FieldSet .from_ugrid_conventions (ds .chunk ({"time" : 1 }), mesh = "flat" )
98+
99+ # construction is never windowing -- it is opt-in via the fieldset method
100+ assert not isinstance (fset_np .U .data , WindowedArray )
101+ assert not isinstance (fset_dk .U .data , WindowedArray )
102+ assert isinstance (fset_dk .U .data .data , da .Array ) # chunked input stays lazy (dask-backed)
103+
104+ assert fset_np .to_windowed_arrays () is fset_np # chainable
105+ fset_dk .to_windowed_arrays ()
106+
107+ # numpy-backed field is left eager; dask-backed field gets wrapped
108+ assert not isinstance (fset_np .U .data , WindowedArray )
109+ assert isinstance (fset_dk .U .data , WindowedArray )
110+ # transparency: forwarded attributes still behave like the DataArray
111+ assert fset_dk .U .data .dims == fset_np .U .data .dims
112+ assert fset_dk .U .data .shape == fset_np .U .data .shape
94113
95114def test_to_windowed_arrays_is_idempotent_and_forwards_max_levels ():
96115 ds = simple_UV_dataset (mesh = "flat" )
0 commit comments