[enhancement] catch and error on unsized numpy types
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 298
- Avg merge
- 4m
- Merged PRs (30d)
- 1
Description
While writing some code examples to become more familiar with pycuda, I figured out that there seems to be an issue with pycuda.driver.Function.prepare. Hoping that this is helpful, I attached an example that demonstrates, how prepare() makes a difference between passing np.complex and np.complex128 as the expected data type (same for np.float and np.float64)
[multiply_prepared.py.txt](https://github.com/inducer/pycuda/files/2360862/multiply_prepared.py.txt)
My guess is that this problem traces back to checking np.number in arg_type.__mro__
For clarity, here a snippet extracted from function_prepare() in driver.py:
```
>>> import numpy as np
>>>
>>> arg_types = [np.complex, np.complex64, np.complex128, np.float, np.float32, np.float64]
>>> arg_format = ""
>>>
>>> for i, arg_type in enumerate(arg_types):
... if (isinstance(arg_type, type)
... and np is not None and np.number in arg_type.__mro__):
... arg_format += np.dtype(arg_type).char
... elif isinstance(arg_type, str):
... arg_format += arg_type
... else:
... arg_format += np.dtype(np.uintp).char
...
>>> print(arg_format)
LFDLfd
```
In my understanding the output should be more like "DFDdfd" since
```
>>> np.dtype(np.complex).type
>>> np.dtype(np.float).type
```
Best
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.