From 1021e26f4766e79cc541c8dbf5131ef1eef7899e Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 20 Oct 2022 16:26:59 +0200 Subject: [PATCH 1/2] API: Specify that DLPack should use BufferError I would actually like MUST, but since most implementations currently don't actually give a ``BufferError``, writing it as SHOULD instead. First part of closing https://github.com/numpy/numpy/issues/20742 --- spec/API_specification/array_api/array_object.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/API_specification/array_api/array_object.py b/spec/API_specification/array_api/array_object.py index 94dac2d1d..7334047c8 100644 --- a/spec/API_specification/array_api/array_object.py +++ b/spec/API_specification/array_api/array_object.py @@ -290,6 +290,15 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P ------- capsule: PyCapsule a DLPack capsule for the array. See :ref:`data-interchange` for details. + + Raises + ------ + BufferError + Implementations should raise ``BufferError`` when the data cannot + cannot be exported as DLPack (e.g. incompatible dtype or strides). + Other errors are raised when export fails for other reasons + (e.g. incorrect arguments passed or out of memory). + """ def __dlpack_device__(self: array, /) -> Tuple[Enum, int]: From 3c91ce21259616edb504a6b6a3a58f612b0d5961 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 3 Nov 2022 10:55:48 -0700 Subject: [PATCH 2/2] Fix duplicated word --- spec/API_specification/array_api/array_object.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/array_api/array_object.py b/spec/API_specification/array_api/array_object.py index 7334047c8..cc24a3bbe 100644 --- a/spec/API_specification/array_api/array_object.py +++ b/spec/API_specification/array_api/array_object.py @@ -295,9 +295,9 @@ def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> P ------ BufferError Implementations should raise ``BufferError`` when the data cannot - cannot be exported as DLPack (e.g. incompatible dtype or strides). - Other errors are raised when export fails for other reasons - (e.g. incorrect arguments passed or out of memory). + be exported as DLPack (e.g., incompatible dtype or strides). Other + errors are raised when export fails for other reasons (e.g., incorrect + arguments passed or out of memory). """