diff --git a/arraycontext/context.py b/arraycontext/context.py index 8b42bca76e9b4288458193cb44449a13fdb46b58..0640e5a1e3d89dc24d438b59a8d6abb04e8e0712 100644 --- a/arraycontext/context.py +++ b/arraycontext/context.py @@ -297,12 +297,6 @@ class ArrayContext(ABC): def __hash__(self) -> int: raise TypeError(f"unhashable type: '{type(self).__name__}'") - @abstractmethod - def empty(self, - shape: Union[int, Tuple[int, ...]], - dtype: "np.dtype[Any]") -> Array: - pass - def zeros(self, shape: Union[int, Tuple[int, ...]], dtype: "np.dtype[Any]") -> Array: @@ -312,20 +306,6 @@ class ArrayContext(ABC): return self.np.zeros(shape, dtype) - def empty_like(self, ary: Array) -> Array: - warn(f"{type(self).__name__}.empty_like is deprecated and will stop " - "working in 2023. Prefer actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.empty(shape=ary.shape, dtype=ary.dtype) - - def zeros_like(self, ary: Array) -> Array: - warn(f"{type(self).__name__}.zeros_like is deprecated and will stop " - "working in 2023. Use actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.zeros(shape=ary.shape, dtype=ary.dtype) - @abstractmethod def from_numpy(self, array: NumpyOrContainerOrScalar diff --git a/arraycontext/impl/jax/__init__.py b/arraycontext/impl/jax/__init__.py index 0304541900d784b36b1ee8213761bffa2a6570a7..26cb9db50d85792bdda0037b24a84f354f9fb4dc 100644 --- a/arraycontext/impl/jax/__init__.py +++ b/arraycontext/impl/jax/__init__.py @@ -87,38 +87,6 @@ class EagerJAXArrayContext(ArrayContext): # {{{ ArrayContext interface - def empty(self, shape, dtype): - from warnings import warn - warn(f"{type(self).__name__}.empty is deprecated and will stop " - "working in 2023. Prefer actx.np.zeros instead.", - DeprecationWarning, stacklevel=2) - - import jax.numpy as jnp - return jnp.empty(shape=shape, dtype=dtype) - - def zeros(self, shape, dtype): - import jax.numpy as jnp - return jnp.zeros(shape=shape, dtype=dtype) - - def empty_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.empty_like is deprecated and will stop " - "working in 2023. Prefer actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - def _empty_like(array): - return self.empty(array.shape, array.dtype) - - return self._rec_map_container(_empty_like, ary) - - def zeros_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.zeros_like is deprecated and will stop " - "working in 2023. Use actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.np.zeros_like(ary) - def from_numpy(self, array): def _from_numpy(ary): import jax diff --git a/arraycontext/impl/pyopencl/__init__.py b/arraycontext/impl/pyopencl/__init__.py index 9be77a444b1788af23855fe26a5c541e8f846355..de188cbdb611843c1c18971c55e81a42efe1f957 100644 --- a/arraycontext/impl/pyopencl/__init__.py +++ b/arraycontext/impl/pyopencl/__init__.py @@ -198,41 +198,6 @@ class PyOpenCLArrayContext(ArrayContext): # {{{ ArrayContext interface - def empty(self, shape, dtype): - from warnings import warn - warn(f"{type(self).__name__}.empty is deprecated and will stop " - "working in 2023. Prefer actx.np.zeros instead.", - DeprecationWarning, stacklevel=2) - - import arraycontext.impl.pyopencl.taggable_cl_array as tga - return tga.empty(self.queue, shape, dtype, allocator=self.allocator) - - def zeros(self, shape, dtype): - import arraycontext.impl.pyopencl.taggable_cl_array as tga - return tga.zeros(self.queue, shape, dtype, allocator=self.allocator) - - def empty_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.empty_like is deprecated and will stop " - "working in 2023. Prefer actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - import arraycontext.impl.pyopencl.taggable_cl_array as tga - - def _empty_like(array): - return tga.empty(self.queue, array.shape, array.dtype, - allocator=self.allocator, axes=array.axes, tags=array.tags) - - return self._rec_map_container(_empty_like, ary) - - def zeros_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.zeros_like is deprecated and will stop " - "working in 2023. Use actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.np.zeros_like(ary) - def from_numpy(self, array): import arraycontext.impl.pyopencl.taggable_cl_array as tga diff --git a/arraycontext/impl/pytato/__init__.py b/arraycontext/impl/pytato/__init__.py index 8737e5fae5b003d5de119c7e7a22e4d005aac478..5ece78e9d1e8a6e0101759118e2a338fbd23eb6b 100644 --- a/arraycontext/impl/pytato/__init__.py +++ b/arraycontext/impl/pytato/__init__.py @@ -171,22 +171,6 @@ class _BasePytatoArrayContext(ArrayContext, abc.ABC): Returns valid frozen array types for the array context. """ - # {{{ ArrayContext interface - - def empty(self, shape, dtype): - raise NotImplementedError( - f"{type(self).__name__}.empty is not supported") - - def zeros(self, shape, dtype): - import pytato as pt - return pt.zeros(shape, dtype) - - def empty_like(self, ary): - raise NotImplementedError( - f"{type(self).__name__}.empty_like is not supported") - - # }}} - # {{{ compilation def transform_dag(self, dag: pytato.DictOfNamedArrays @@ -380,14 +364,6 @@ class PytatoPyOpenCLArrayContext(_BasePytatoArrayContext): # {{{ ArrayContext interface - def zeros_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.zeros_like is deprecated and will stop " - "working in 2023. Use actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.np.zeros_like(ary) - def from_numpy(self, array): import pytato as pt @@ -776,14 +752,6 @@ class PytatoJAXArrayContext(_BasePytatoArrayContext): # {{{ ArrayContext interface - def zeros_like(self, ary): - from warnings import warn - warn(f"{type(self).__name__}.zeros_like is deprecated and will stop " - "working in 2023. Use actx.np.zeros_like instead.", - DeprecationWarning, stacklevel=2) - - return self.np.zeros_like(ary) - def from_numpy(self, array): import jax import pytato as pt