Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ndsl/stencils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
set_value_2D,
sign,
)
from .corners import CopyCornersXY, FillCornersBGrid
from .corners import FillCornersBGrid


__all__ = [
"CopyCornersXY",
"FillCornersBGrid",
"copy",
"adjustmentfactor_stencil",
Expand Down
66 changes: 0 additions & 66 deletions ndsl/stencils/corners.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import warnings
from collections.abc import Sequence

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

Expand All @@ -10,69 +7,6 @@
from ndsl.dsl.typing import FloatField


class CopyCornersXY:
"""
Helper-class to copy corners corresponding to the Fortran functions
copy_corners_x and copy_corners_y
"""

def __init__(
self,
stencil_factory: StencilFactory,
dims: Sequence[str],
y_field,
) -> None:
"""
Args:
stencil_factory: creates stencils
dims: dimensionality of the data to be copied
y_field: 3D gt4py storage to use for y-differenceable field
(x-differenceable field uses same memory as base field)
"""
warnings.warn(
"Usage of CopyCornersXY is deprecated and will be removed in the next release. "
"Use `CopyCornersX` and `CopyCornersY` in PyFV3 for a more future-proof "
"implementation of the corner code.",
DeprecationWarning,
stacklevel=2,
)
grid_indexing = stencil_factory.grid_indexing
origin, domain = grid_indexing.get_origin_domain(
dims=dims, halos=(grid_indexing.n_halo, grid_indexing.n_halo)
)

self._y_field = y_field

ax_offsets = grid_indexing.axis_offsets(origin, domain)
self._copy_corners_xy = stencil_factory.from_origin_domain(
func=copy_corners_xy_stencil_defn,
origin=origin,
domain=domain,
externals={
**ax_offsets,
},
)

def __call__(self, field: FloatField):
"""
Fills cell quantity field using corners from itself.

Args:
field: field to fill corners

Returns:
x_differenceable: input field, updated so it can be differenced
in x-direction
y_differenceable: copy of input field which can be differenced
in y-direction
"""
# we could avoid aliasing field for the x-differenceable output, but this
# requires selectively validating the halos, since the Fortran code does the
# final (x-direction) corners copy directly on the base field
self._copy_corners_xy(field, field, self._y_field)
return field, self._y_field


def kslice_from_inputs(
kstart: int, nk: int | None, grid_indexer: GridIndexing
) -> tuple[slice, int]:
Expand Down
8 changes: 0 additions & 8 deletions tests/stencils/test_stencils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ndsl.constants import X_DIM, Y_DIM, Z_DIM
from ndsl.dsl.gt4py import FORWARD, computation, interval
from ndsl.dsl.typing import Float, FloatField, FloatFieldIJ, set_4d_field_size
from ndsl.stencils import CopyCornersXY
from ndsl.stencils.column_operations import (
column_max,
column_max_ddim,
Expand Down Expand Up @@ -165,10 +164,3 @@ def test_column_operations(boilerplate):
assert min_index_ddim.field[:] == 5 + np.argmin(
data_ddim.field[:, :, 5:, 1], axis=2
)


def test_CopyCornersXY_deprecation(boilerplate) -> None:
stencil_factory, _ = boilerplate

with pytest.deprecated_call(match="Usage of CopyCornersXY is deprecated"):
CopyCornersXY(stencil_factory, [X_DIM, Y_DIM, Z_DIM], None)