@@ -221,6 +221,8 @@ def dtype(self) -> "np.dtype[Any]":
221221 "ArrayOrContainerOrScalarT" ,
222222 bound = ArrayOrContainerOrScalar )
223223
224+ NumpyOrContainerOrScalar = Union [np .ndarray , "ArrayContainer" , ScalarLike ]
225+
224226# }}}
225227
226228
@@ -304,25 +306,28 @@ def zeros_like(self, ary: Array) -> Array:
304306
305307 @abstractmethod
306308 def from_numpy (self ,
307- array : Union [ "np.ndarray[Any, Any]" , ScalarLike ]
308- ) -> Union [ Array , ScalarLike ] :
309+ array : ArrayOrContainerOrScalar
310+ ) -> NumpyOrContainerOrScalar :
309311 r"""
310312 :returns: the :class:`numpy.ndarray` *array* converted to the
311313 array context's array type. The returned array will be
312- :meth:`thaw`\ ed.
314+ :meth:`thaw`\ ed. When working with array containers each leaf
315+ must be an :class:`~numpy.ndarray` or scalar, which is then converted
316+ to the context's array type leaving the container structure
317+ intact.
313318 """
314- pass
315319
316320 @abstractmethod
317321 def to_numpy (self ,
318- array : Union [ Array , ScalarLike ]
319- ) -> Union [ "np.ndarray[Any, Any]" , ScalarLike ] :
322+ array : NumpyOrContainerOrScalar
323+ ) -> ArrayOrContainerOrScalar :
320324 r"""
321- :returns: *array*, an array recognized by the context, converted
322- to a :class:`numpy.ndarray`. *array* must be
323- :meth:`thaw`\ ed.
325+ :returns: an :class:`numpy.ndarray` for each array recognized by the
326+ context. The input *array* must be :meth:`thaw`\ ed.
327+ When working with array containers each leaf must be one of
328+ the context's array types or a scalar, which is then converted to
329+ an :class:`~numpy.ndarray` leaving the container structure intact.
324330 """
325- pass
326331
327332 @abstractmethod
328333 def call_loopy (self ,
@@ -351,8 +356,6 @@ def freeze(self, array: ArrayOrContainerOrScalarT) -> ArrayOrContainerOrScalarT:
351356 Freezing makes the array independent of this :class:`ArrayContext`;
352357 it is permitted to :meth:`thaw` it in a different one, as long as that
353358 context understands the array format.
354-
355- See also :func:`arraycontext.freeze`.
356359 """
357360
358361 @abstractmethod
@@ -366,8 +369,6 @@ def thaw(self, array: ArrayOrContainerOrScalarT) -> ArrayOrContainerOrScalarT:
366369 the data in *array*.
367370
368371 The returned array may not be used with other contexts while thawed.
369-
370- See also :func:`arraycontext.thaw`.
371372 """
372373
373374 def freeze_thaw (
@@ -387,10 +388,11 @@ def freeze_thaw(
387388 @abstractmethod
388389 def tag (self ,
389390 tags : ToTagSetConvertible ,
390- array : ArrayT ) -> ArrayT :
391+ array : ArrayOrContainerOrScalarT ) -> ArrayOrContainerOrScalarT :
391392 """If the array type used by the array context is capable of capturing
392393 metadata, return a version of *array* with the *tags* applied. *array*
393- itself is not modified.
394+ itself is not modified. When working with array containers, the
395+ tags are applied to each leaf of the container.
394396
395397 See :ref:`metadata` as well as application-specific metadata types.
396398
@@ -400,10 +402,11 @@ def tag(self,
400402 @abstractmethod
401403 def tag_axis (self ,
402404 iaxis : int , tags : ToTagSetConvertible ,
403- array : ArrayT ) -> ArrayT :
405+ array : ArrayOrContainerOrScalarT ) -> ArrayOrContainerOrScalarT :
404406 """If the array type used by the array context is capable of capturing
405407 metadata, return a version of *array* in which axis number *iaxis* has
406- the *tags* applied. *array* itself is not modified.
408+ the *tags* applied. *array* itself is not modified. When working with
409+ array containers, the tags are applied to each leaf of the container.
407410
408411 See :ref:`metadata` as well as application-specific metadata types.
409412
0 commit comments