Skip to content

Commit 2c9946c

Browse files
authored
BREAKING CHANGE: last 2025.10.00 deprecations (CopyCorners, Quantity.values(), extra_dim_lengths on SubtileGridSizer (NOAA-GFDL#300)
* Remove deprecated extra_dim_lengths of SubtileGridSizer This is a follow-up from NOAA-GFDL#295. * Remove deprecated CopyCorners * Remove deprecated `Quantity.values()` --------- Co-authored-by: Roman Cattaneo <1116746+romanc@users.noreply.github.com>
1 parent dd931b2 commit 2c9946c

File tree

4 files changed

+3
-208
lines changed

4 files changed

+3
-208
lines changed

ndsl/initialization/subtile_grid_sizer.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
from collections.abc import Iterable
32
from typing import Self
43

@@ -21,7 +20,6 @@ def from_tile_params(
2120
data_dimensions: dict[str, int] | None = None,
2221
tile_partitioner: TilePartitioner | None = None,
2322
tile_rank: int = 0,
24-
extra_dim_lengths: dict[str, int] | None = None,
2523
) -> Self:
2624
"""Create a SubtileGridSizer from parameters about the full tile.
2725
@@ -36,18 +34,10 @@ def from_tile_params(
3634
tile_partitioner (optional): partitioner object for the tile. By default, a
3735
TilePartitioner is created with the given layout
3836
tile_rank (optional): rank of this subtile.
39-
extra_dim_lengths: DEPRECATED API - use `data_dimensions`
4037
"""
4138
if data_dimensions is None:
4239
data_dimensions = {}
4340

44-
if extra_dim_lengths is not None:
45-
warnings.warn(
46-
"`extra_dim_lengths` is a deprecated name, please use `data_dimensions` instead.",
47-
DeprecationWarning,
48-
2,
49-
)
50-
data_dimensions = extra_dim_lengths
5141
if tile_partitioner is None:
5242
tile_partitioner = TilePartitioner(layout)
5343
y_slice, x_slice = tile_partitioner.subtile_slice(

ndsl/quantity/quantity.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,6 @@ def dims(self) -> tuple[str, ...]:
254254
"""Names of each dimension"""
255255
return self.metadata.dims
256256

257-
@property
258-
def values(self) -> np.ndarray:
259-
warnings.warn(
260-
"values exists only for backwards-compatibility with "
261-
"DataArray and will be removed, use .view[:] instead",
262-
DeprecationWarning,
263-
stacklevel=2,
264-
)
265-
return_array = np.asarray(self.view[:])
266-
return_array.flags.writeable = False
267-
return return_array
268-
269257
@property
270258
def view(self) -> BoundedArrayView:
271259
"""A view into the computational domain of the underlying data"""

ndsl/stencils/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
from .corners import CopyCorners, CopyCornersXY, FillCornersBGrid
1+
from .corners import CopyCornersXY, FillCornersBGrid
22

33

4-
__all__ = [
5-
"CopyCorners",
6-
"CopyCornersXY",
7-
"FillCornersBGrid",
8-
]
4+
__all__ = ["CopyCornersXY", "FillCornersBGrid"]

ndsl/stencils/corners.py

Lines changed: 1 addition & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,14 @@
1-
import warnings
21
from collections.abc import Sequence
32

43
from gt4py.cartesian import gtscript
54
from gt4py.cartesian.gtscript import PARALLEL, computation, horizontal, interval, region
65

76
from ndsl import StencilFactory
8-
from ndsl.constants import (
9-
X_DIM,
10-
X_INTERFACE_DIM,
11-
Y_DIM,
12-
Y_INTERFACE_DIM,
13-
Z_INTERFACE_DIM,
14-
)
7+
from ndsl.constants import X_INTERFACE_DIM, Y_INTERFACE_DIM, Z_INTERFACE_DIM
158
from ndsl.dsl.stencil import GridIndexing
169
from ndsl.dsl.typing import FloatField
1710

1811

19-
class CopyCorners:
20-
"""
21-
Helper-class to copy corners corresponding to the fortran functions
22-
copy_corners_x or copy_corners_y respectively
23-
"""
24-
25-
def __init__(self, direction: str, stencil_factory: StencilFactory) -> None:
26-
"""The grid for this stencil"""
27-
warnings.warn(
28-
"Usage of the GT4Py implementation of CopyCorners is discouraged and will"
29-
"be removed in the next release. Use `CopyCornersX` or `CopyCornersY` in PyFV3"
30-
"for a more future-proof implementation of the same code.",
31-
DeprecationWarning,
32-
2,
33-
)
34-
grid_indexing = stencil_factory.grid_indexing
35-
36-
n_halo = grid_indexing.n_halo
37-
origin, domain = grid_indexing.get_origin_domain(
38-
dims=[X_DIM, Y_DIM, Z_INTERFACE_DIM], halos=(n_halo, n_halo)
39-
)
40-
41-
ax_offsets = grid_indexing.axis_offsets(origin, domain)
42-
if direction == "x":
43-
self._copy_corners = stencil_factory.from_origin_domain(
44-
func=copy_corners_x_stencil_defn,
45-
origin=origin,
46-
domain=domain,
47-
externals={
48-
**ax_offsets,
49-
},
50-
)
51-
elif direction == "y":
52-
self._copy_corners = stencil_factory.from_origin_domain(
53-
func=copy_corners_y_stencil_defn,
54-
origin=origin,
55-
domain=domain,
56-
externals={
57-
**ax_offsets,
58-
},
59-
)
60-
else:
61-
raise ValueError("Direction must be either 'x' or 'y'")
62-
63-
def __call__(self, field: FloatField):
64-
"""
65-
Fills cell quantity field using corners from itself and multipliers
66-
in the direction specified initialization of the instance of this class.
67-
"""
68-
self._copy_corners(field, field)
69-
70-
7112
class CopyCornersXY:
7213
"""
7314
Helper-class to copy corners corresponding to the Fortran functions
@@ -313,126 +254,6 @@ def fill_corners_3cells_mult_y(
313254
return q
314255

315256

316-
def copy_corners_x_stencil_defn(q_in: FloatField, q_out: FloatField):
317-
from __externals__ import i_end, i_start, j_end, j_start
318-
319-
with computation(PARALLEL), interval(...):
320-
with horizontal(
321-
region[i_start - 3, j_start - 3], region[i_end + 3, j_start - 3]
322-
):
323-
q_out = q_in[0, 5, 0]
324-
with horizontal(
325-
region[i_start - 2, j_start - 3], region[i_end + 3, j_start - 2]
326-
):
327-
q_out = q_in[-1, 4, 0]
328-
with horizontal(
329-
region[i_start - 1, j_start - 3], region[i_end + 3, j_start - 1]
330-
):
331-
q_out = q_in[-2, 3, 0]
332-
with horizontal(
333-
region[i_start - 3, j_start - 2], region[i_end + 2, j_start - 3]
334-
):
335-
q_out = q_in[1, 4, 0]
336-
with horizontal(
337-
region[i_start - 2, j_start - 2], region[i_end + 2, j_start - 2]
338-
):
339-
q_out = q_in[0, 3, 0]
340-
with horizontal(
341-
region[i_start - 1, j_start - 2], region[i_end + 2, j_start - 1]
342-
):
343-
q_out = q_in[-1, 2, 0]
344-
with horizontal(
345-
region[i_start - 3, j_start - 1], region[i_end + 1, j_start - 3]
346-
):
347-
q_out = q_in[2, 3, 0]
348-
with horizontal(
349-
region[i_start - 2, j_start - 1], region[i_end + 1, j_start - 2]
350-
):
351-
q_out = q_in[1, 2, 0]
352-
with horizontal(
353-
region[i_start - 1, j_start - 1], region[i_end + 1, j_start - 1]
354-
):
355-
q_out = q_in[0, 1, 0]
356-
with horizontal(region[i_start - 3, j_end + 1], region[i_end + 1, j_end + 3]):
357-
q_out = q_in[2, -3, 0]
358-
with horizontal(region[i_start - 2, j_end + 1], region[i_end + 1, j_end + 2]):
359-
q_out = q_in[1, -2, 0]
360-
with horizontal(region[i_start - 1, j_end + 1], region[i_end + 1, j_end + 1]):
361-
q_out = q_in[0, -1, 0]
362-
with horizontal(region[i_start - 3, j_end + 2], region[i_end + 2, j_end + 3]):
363-
q_out = q_in[1, -4, 0]
364-
with horizontal(region[i_start - 2, j_end + 2], region[i_end + 2, j_end + 2]):
365-
q_out = q_in[0, -3, 0]
366-
with horizontal(region[i_start - 1, j_end + 2], region[i_end + 2, j_end + 1]):
367-
q_out = q_in[-1, -2, 0]
368-
with horizontal(region[i_start - 3, j_end + 3], region[i_end + 3, j_end + 3]):
369-
q_out = q_in[0, -5, 0]
370-
with horizontal(region[i_start - 2, j_end + 3], region[i_end + 3, j_end + 2]):
371-
q_out = q_in[-1, -4, 0]
372-
with horizontal(region[i_start - 1, j_end + 3], region[i_end + 3, j_end + 1]):
373-
q_out = q_in[-2, -3, 0]
374-
375-
376-
def copy_corners_y_stencil_defn(q_in: FloatField, q_out: FloatField):
377-
from __externals__ import i_end, i_start, j_end, j_start
378-
379-
with computation(PARALLEL), interval(...):
380-
with horizontal(
381-
region[i_start - 3, j_start - 3], region[i_start - 3, j_end + 3]
382-
):
383-
q_out = q_in[5, 0, 0]
384-
with horizontal(
385-
region[i_start - 2, j_start - 3], region[i_start - 3, j_end + 2]
386-
):
387-
q_out = q_in[4, 1, 0]
388-
with horizontal(
389-
region[i_start - 1, j_start - 3], region[i_start - 3, j_end + 1]
390-
):
391-
q_out = q_in[3, 2, 0]
392-
with horizontal(
393-
region[i_start - 3, j_start - 2], region[i_start - 2, j_end + 3]
394-
):
395-
q_out = q_in[4, -1, 0]
396-
with horizontal(
397-
region[i_start - 2, j_start - 2], region[i_start - 2, j_end + 2]
398-
):
399-
q_out = q_in[3, 0, 0]
400-
with horizontal(
401-
region[i_start - 1, j_start - 2], region[i_start - 2, j_end + 1]
402-
):
403-
q_out = q_in[2, 1, 0]
404-
with horizontal(
405-
region[i_start - 3, j_start - 1], region[i_start - 1, j_end + 3]
406-
):
407-
q_out = q_in[3, -2, 0]
408-
with horizontal(
409-
region[i_start - 2, j_start - 1], region[i_start - 1, j_end + 2]
410-
):
411-
q_out = q_in[2, -1, 0]
412-
with horizontal(
413-
region[i_start - 1, j_start - 1], region[i_start - 1, j_end + 1]
414-
):
415-
q_out = q_in[1, 0, 0]
416-
with horizontal(region[i_end + 1, j_start - 3], region[i_end + 3, j_end + 1]):
417-
q_out = q_in[-3, 2, 0]
418-
with horizontal(region[i_end + 2, j_start - 3], region[i_end + 3, j_end + 2]):
419-
q_out = q_in[-4, 1, 0]
420-
with horizontal(region[i_end + 3, j_start - 3], region[i_end + 3, j_end + 3]):
421-
q_out = q_in[-5, 0, 0]
422-
with horizontal(region[i_end + 1, j_start - 2], region[i_end + 2, j_end + 1]):
423-
q_out = q_in[-2, 1, 0]
424-
with horizontal(region[i_end + 2, j_start - 2], region[i_end + 2, j_end + 2]):
425-
q_out = q_in[-3, 0, 0]
426-
with horizontal(region[i_end + 3, j_start - 2], region[i_end + 2, j_end + 3]):
427-
q_out = q_in[-4, -1, 0]
428-
with horizontal(region[i_end + 1, j_start - 1], region[i_end + 1, j_end + 1]):
429-
q_out = q_in[-1, 0, 0]
430-
with horizontal(region[i_end + 2, j_start - 1], region[i_end + 1, j_end + 2]):
431-
q_out = q_in[-2, -1, 0]
432-
with horizontal(region[i_end + 3, j_start - 1], region[i_end + 1, j_end + 3]):
433-
q_out = q_in[-3, -2, 0]
434-
435-
436257
def copy_corners_xy_stencil_defn(
437258
q_in: FloatField, q_out_x: FloatField, q_out_y: FloatField
438259
):

0 commit comments

Comments
 (0)