Skip to content

Commit 1687b7a

Browse files
committed
traversal.{to,from}_numpy: mark deprecated
1 parent 754deae commit 1687b7a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

arraycontext/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
flat_size_and_dtype,
5252
flatten,
5353
freeze,
54-
from_numpy,
54+
from_numpy, # pyright: ignore[reportDeprecated]
5555
map_array_container,
5656
map_reduce_array_container,
5757
mapped_over_array_containers,
@@ -66,7 +66,7 @@
6666
rec_multimap_reduce_array_container,
6767
stringify_array_container_tree,
6868
thaw,
69-
to_numpy,
69+
to_numpy, # pyright: ignore[reportDeprecated]
7070
unflatten,
7171
with_array_context,
7272
)

arraycontext/container/traversal.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
from arraycontext.typing import (
107107
ArrayContainer,
108108
ArrayContainerT,
109+
NumpyOrContainerOrScalar,
110+
ScalarLike,
109111
is_scalar_like,
110112
shape_is_int_only,
111113
)
@@ -1108,11 +1110,14 @@ def _flat_size(subary: ArrayOrContainerOrScalar) -> Array | int | np.integer:
11081110

11091111
# }}}
11101112

1113+
11111114
class _HasOuterBcastTypes(Protocol):
11121115
_outer_bcast_types: ClassVar[Collection[type]]
11131116

1117+
11141118
# {{{ numpy conversion
11151119

1120+
@deprecated("use ArrayContext.from_numpy")
11161121
def from_numpy(
11171122
ary: np.ndarray | ScalarLike,
11181123
actx: ArrayContext) -> ArrayOrContainerOrScalar:
@@ -1128,7 +1133,10 @@ def from_numpy(
11281133
return actx.from_numpy(ary)
11291134

11301135

1131-
def to_numpy(ary: ArrayOrContainer, actx: ArrayContext) -> ArrayOrContainer:
1136+
@deprecated("use ArrayContext.to_numpy")
1137+
def to_numpy(
1138+
ary: ArrayOrContainerOrScalar, actx: ArrayContext
1139+
) -> NumpyOrContainerOrScalar:
11321140
"""Convert all arrays in the :class:`~arraycontext.ArrayContainer` to
11331141
:mod:`numpy` using the provided :class:`~arraycontext.ArrayContext` *actx*.
11341142

0 commit comments

Comments
 (0)