__int__¶
- array.__int__() int ¶
Converts a zero-dimensional array to a Python
int
object.- Parameters:
self (array) – zero-dimensional array instance. Should have a real-valued or boolean data type. If
self
has a complex floating-point data type, the function must raise aTypeError
.- Returns:
out (int) – a Python
int
object representing the single element of the array instance.
Notes
Special cases
For boolean operands,
If
self
isTrue
, the result is1
.If
self
isFalse
, the result is0
.
For floating-point operands,
If
self
is a finite number, the result is the integer part ofself
.If
self
is-0
, the result is0
.
Raises
For floating-point operands,
If
self
is either+infinity
or-infinity
, raiseOverflowError
.If
self
isNaN
, raiseValueError
.
Notes
Lazy implementations
The Python language requires the return value to be of type
int
. Lazy implementations are therefore not able to return any kind of lazy/delayed object here and should raise aValueError
instead.Changed in version 2022.12: Added boolean and complex data type support.
Changed in version 2023.12: Allowed lazy implementations to error.