Passing in dtype to array fails on NumPy master in pip-installed version
See original GitHub issueReporting a bug
- I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- I have included below a minimal working reproducer (if you are unsure how to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).
Please note that this doesn’t happen on the conda-installed version, only pip-installed
import numba
import numpy as np
dt1 = np.dtype("float64")
dt2 = np.dtype("float64")
dtr = np.result_type(dt1, dt2)
@numba.jit(
nopython=True,
nogil=True,
locals={"data_curr": numba.np.numpy_support.from_dtype(dtr)},
)
def _dot_coo_coo(coords1, data1, coords2, data2): # pragma: no cover
return np.empty((0,), dtype=dtr)
coords1 = np.array([], dtype=np.int64).reshape((2, 0))
coords2 = coords1
data1 = np.array([], dtype=dt1)
data2 = data1
_dot_coo_coo(coords1, data1, coords2, data2)
Output
Traceback (most recent call last):
File "sandbox.py", line 23, in <module>
_dot_coo_coo(coords1, data1, coords2, data2)
TypeError: expected dtype object, got 'numpy.dtype[float64]'
Original issue by @TomAugspurger in pydata/sparse#383
Package Version
---------- -------------------
llvmlite 0.33.0
numba 0.50.1
numpy 1.20.0.dev0+1ce5457
pip 20.1.1
scipy 1.5.2
setuptools 49.2.0
sparse 0.10.0
wheel 0.34.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Tensorflow 2 Object Detection API: Numpy Version Errors
This error may indicate that you're trying to pass a Tensor to a NumPy call, ... /tensorflow/blob/master/tensorflow/python/ops/array_ops.py
Read more >Release Notes — NumPy v1.13 Manual
This release by-passes the failing algorithm by using heuristics to detect the presence of the PPC double double format. A side-effect of using...
Read more >NumPy 1.20.0 Release Notes
The Python versions supported for this release are 3.7-3.9, support for Python 3.6 has been ... Array creation and casting using np.array(arr, dtype)...
Read more >NumPy 1.23.0 Release Notes
Changes to the promotion and comparisons of structured dtypes. Improvements to f2py. See below for the details,. New functions#. A masked array specialization ......
Read more >Structured arrays — NumPy v1.24 Manual
Changed in version 1.23: Before NumPy 1.23, a warning was given and False returned when promotion to a common dtype failed. Further, promotion...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Note from Numba core dev meeting, preference is to fix up Numba’s use of the macro so as to not have to move NumPy base versions.
This is probably because there is an ABI change in numpy 1.20, which means that numba must be recompiled. If you rebuild numpy master from source then numba from source, I expect the problem to go away.