__complex__

array.__complex__() complex

Converts a zero-dimensional array to a Python complex object.

Parameters:

self (array) – zero-dimensional array instance.

Returns:

out (complex) – a Python complex object representing the single element of the array instance.

Notes

Special cases

For boolean operands,

  • If self is True, the result is 1+0j.

  • If self is False, the result is 0+0j.

For real-valued floating-point operands,

  • If self is NaN, the result is NaN + NaN j.

  • If self is +infinity, the result is +infinity + 0j.

  • If self is -infinity, the result is -infinity + 0j.

  • If self is a finite number, the result is self + 0j.

Lazy implementations

The Python language requires the return value to be of type complex. Lazy implementations are therefore not able to return any kind of lazy/delayed object here and should raise a ValueError instead.

New in version 2022.12.

Changed in version 2023.12: Allowed lazy implementations to error.