__bool__¶
- array.__bool__() bool¶
Converts a zero-dimensional array to a Python
boolobject.- Parameters:
self (array) – zero-dimensional array instance.
- Returns:
out (bool) – a Python
boolobject representing the single element of the array.
Notes
Special cases
For real-valued floating-point operands,
If
selfisNaN, the result isTrue.If
selfis either+infinityor-infinity, the result isTrue.If
selfis either+0or-0, the result isFalse.
For complex floating-point operands, special cases must be handled as if the operation is implemented as the logical OR of
bool(real(self))andbool(imag(self)).Lazy implementations
The Python language requires the return value to be of type
bool. Lazy implementations are therefore not able to return any kind of lazy/delayed object here and should raise aValueErrorinstead.Changed in version 2022.12: Added boolean and complex data type support.
Changed in version 2023.12: Allowed lazy implementations to error.