Skip to content

Commit 7850b41

Browse files
committed
Introduce conservative x.__complex__()
1 parent 8949817 commit 7850b41

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

spec/API_specification/array_api/array_object.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@ def __bool__(self: array, /) -> bool:
237237
a Python ``bool`` object representing the single element of the array.
238238
"""
239239

240+
def __complex__(self: array, /) -> bool:
241+
"""
242+
Converts a zero-dimensional complex array to a Python ``complex`` object.
243+
244+
Parameters
245+
----------
246+
self: array
247+
zero-dimensional array instance. Must have a complex data type.
248+
249+
Returns
250+
-------
251+
out: complex
252+
a Python ``complex`` object representing the single element of the array.
253+
"""
254+
240255
def __dlpack__(self: array, /, *, stream: Optional[Union[int, Any]] = None) -> PyCapsule:
241256
"""
242257
Exports the array for consumption by :func:`~array_api.from_dlpack` as a DLPack capsule.

spec/API_specification/array_object.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ Methods
283283
array.__and__
284284
array.__array_namespace__
285285
array.__bool__
286+
array.__complex__
286287
array.__dlpack__
287288
array.__dlpack_device__
288289
array.__eq__

0 commit comments

Comments
 (0)