Movatterモバイル変換


[0]ホーム

URL:


Skip to content

__float__

array.__float__()float

Converts a zero-dimensional array to a Pythonfloat object.

Note

Casting integer values outside the representable bounds of Python’s float type is not specified and is implementation-dependent.

Parameters:

self (array) – zero-dimensional array instance. Should have a real-valued or boolean data type. Ifself has a complex floating-point data type, the function must raise aTypeError.

Returns:

out (float) – a Pythonfloat object representing the single element of the array instance.

Notes

Special cases

For boolean operands,

  • Ifself isTrue, the result is1.

  • Ifself isFalse, the result is0.

Lazy implementations

The Python language requires the return value to be of typefloat. 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.


[8]ページ先頭

©2009-2025 Movatter.jp