GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • 
  • Consortium for Python Data API Standards
  • API specification
  • Array object
  • Purpose and scope
  • Terms and Definitions
  • Use cases
  • Assumptions
  • Design topics & constraints
  • Future API standard evolution
  • Broadcasting
  • Constants
  • Creation Functions
  • Data Type Functions

This view

  • Original page
  • New address

GeezerVison is showing data-apis.org — __int__ — Python array API standard DRAFT documentation

__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 a TypeError.

Returns:

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

Notes

Special cases

For boolean operands,

  • If self is True, the result is 1.

  • If self is False, the result is 0.

For floating-point operands,

  • If self is a finite number, the result is the integer part of self.

  • If self is -0, the result is 0.

Raises

For floating-point operands,

  • If self is either +infinity or -infinity, raise OverflowError.

  • If self is NaN, raise ValueError.

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 a ValueError instead.

Changed in version 2022.12: Added boolean and complex data type support.

Changed in version 2023.12: Allowed lazy implementations to error.

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.