MCPcopy Create free account
hub / github.com/numpy/numpy / __float__

Method __float__

numpy/array_api/_array_object.py:509–519  ·  view source on GitHub ↗

Performs the operation __float__.

(self: Array, /)

Source from the content-addressed store, hash-verified

507 return self.__class__._new(res)
508
509 def __float__(self: Array, /) -> float:
510 """
511 Performs the operation __float__.
512 """
513 # Note: This is an error here.
514 if self._array.ndim != 0:
515 raise TypeError("float is only allowed on arrays with 0 dimensions")
516 if self.dtype in _complex_floating_dtypes:
517 raise TypeError("float is not allowed on complex floating-point arrays")
518 res = self._array.__float__()
519 return res
520
521 def __floordiv__(self: Array, other: Union[int, float, Array], /) -> Array:
522 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected