Skip to content

BUG: incorrect type annotations for np.angle #21972

@bmerry

Description

@bmerry

Describe the issue:

The type annotation for np.angle seems to assume the return value is a scalar, but if given an array it returns an array. This causes false positives from mypy.

Reproduce the code example:

import numpy as np

a = np.array([1.0 + 2.0j, 3.0 + 4.0j], dtype=np.dtype(complex))
ang = np.angle(a)
print(ang[0])

Error message:

angle.py:5: error: Value of type "complexfloating[Any, Any]" is not indexable

NumPy/Python version information:

1.23.1 3.8.10 (default, Mar 15 2022, 12:22:08)
[GCC 9.4.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions