-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Closed
Description
Describe the issue:
The type hints for interp
assert that the return dtype is a numpy array, but when the function is called with a scaler it gives a float. This raises some mypy errors.
numpy/numpy/lib/_function_base_impl.pyi
Lines 306 to 323 in b85a149
@overload | |
def interp( | |
x: _ArrayLikeFloat_co, | |
xp: _ArrayLikeFloat_co, | |
fp: _ArrayLikeFloat_co, | |
left: None | _FloatLike_co = ..., | |
right: None | _FloatLike_co = ..., | |
period: None | _FloatLike_co = ..., | |
) -> NDArray[float64]: ... | |
@overload | |
def interp( | |
x: _ArrayLikeFloat_co, | |
xp: _ArrayLikeFloat_co, | |
fp: _ArrayLikeComplex_co, | |
left: None | _ComplexLike_co = ..., | |
right: None | _ComplexLike_co = ..., | |
period: None | _FloatLike_co = ..., | |
) -> NDArray[complex128]: ... |
Reproduce the code example:
>>> np.interp(0, [1, 2], [3, 4])
np.float64(3.0)
Error message:
my_code.py::123 error: Incompatible return value type (got "ndarray[Any, Any]", expected "float") [return-value]
Python and NumPy Versions:
python: 3.12.2
numpy: 2.1.3
Runtime Environment:
No response
Context for the issue:
No response