numba/numba
在 GitHub 查看Function overloads of some NumPy functions with scalar input are not exhaustive
Open
#10,522 创建于 2026年4月5日
buggood first issue
描述
This is a follow-up to this comment in #10408. The recent changes in the PRs linked to #10408 may not exhaustively handle all scalar input types. For example, at the time of writing this, the np.min and np.max overloads do not support scalar inputs of type np.datetime64 or np.timedelta64. Below is what happens when you attempt to call the JIT-compiled np.min in nopython mode with a np.datetime64 argument.
>>> @njit
... def foo(a):
... return np.min(a)
...
>>> np.min(np.datetime64(0, 'Y'))
np.datetime64('1970')
>>> foo(np.datetime64(0, 'Y'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/izruff/miniconda3/envs/playground/lib/python3.12/site-packages/numba/core/dispatcher.py", line 424, in _compile_for_args
error_rewrite(e, 'typing')
File "/home/izruff/miniconda3/envs/playground/lib/python3.12/site-packages/numba/core/dispatcher.py", line 365, in error_rewrite
raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
No implementation of function Function(<function min at 0x792a335b2200>) found for signature:
>>> min(datetime64[Y])
There are 2 candidate implementations:
- Of which 2 did not match due to:
Overload of function 'min': File: numba/np/arraymath.py: Line 491.
With argument(s): '(datetime64[Y])':
No match.
During: resolving callee type: Function(<function min at 0x792a335b2200>)
During: typing of call at <stdin> (3)
File "<stdin>", line 3:
<source missing, REPL/exec in use?>
During: Pass nopython_type_inference
There are potentially other NumPy functions with the same problem. One way to detect them is to add/modify the test suite to exhaust all possible scalar types, and making sure all NumPy overloads go through this test suite.