Skip to content

BUG: np.<ufunc>(np.ndarray) should raise TypeError #8877

@mhvk

Description

@mhvk

As noted by @charris in charris#5 (comment)

In [3]: np.add(int, int)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-979cc31d12eb> in <module>()
----> 1 np.add(int, int)

TypeError: unsupported operand type(s) for +: 'type' and 'type'

In [4]: np.add(ndarray, ndarray)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-6dcac5b0c00d> in <module>()
----> 1 np.add(ndarray, ndarray)

ValueError: invalid __array_struct__

Should really both be TypeError.

Similarly, the following is arguably less than useful:

In [2]: np.sin(int)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-0b1d09c17e53> in <module>()
----> 1 np.sin(int)

AttributeError: type object 'int' has no attribute 'sin'

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