Skip to content

DEP: Raise TypeError on attempt to convert array with ndim > 0 to scalar #29835

@hpkfft

Description

@hpkfft

Proposed new feature or change:

Using NumPy version 2.3.3:

>>> import numpy as np
>>> a = np.array([1.0], dtype=np.float64)
>>> float(a)
<python-input-2>:1: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
1.0

I would like to suggest that the future is now and that it would be preferable to raise TypeError.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions