Description
Describe the issue:
While type checking, numpy.union1d
outputs an array of type ndarray[tuple[int, ...], dtype[floating[_64Bit]]]
even if both the arguments are of the type ndarray[tuple[int, ...], dtype[float64]]
-- failing mypy checks.
Reproduce the code example:
import numpy.typing as npt
import numpy as np
def do_something(a: npt.NDArray[np.float64], b: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
return np.union1d(a, b)
Error message:
% mypy mypy_rep.py
mypy_rep.py:6: error: Incompatible return value type (got "ndarray[tuple[int, ...], dtype[floating[_64Bit]]]", expected "ndarray[tuple[int, ...], dtype[float64]]") [return-value]
Found 1 error in 1 file (checked 1 source file)
Python and NumPy Versions:
2.2.2
3.13.1 (main, Dec 3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)]
mypy 1.14.1 (compiled: yes)
No extra configuration
Runtime Environment:
[{'numpy_version': '2.2.2',
'python': '3.13.1 (main, Dec 3 2024, 17:59:52) [Clang 16.0.0 '
'(clang-1600.0.26.4)]',
'uname': uname_result(system='Darwin', node='Saranshs-MacBook-Pro.local', release='24.2.0', version='Darwin Kernel Version 24.2.0: Fri Dec 6 19:02:41 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6030', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}}]
Context for the issue:
No response