pyopencl
pyopencl copied to clipboard
The `type<n>` cannot be hinted properly in IDEs.
The type<n>
cannot be hinted properly in IDEs.
e.g
import pyopencl as cl
import pyopencl.cltypes
N = 10
HOST_myArray = np.array([cl.cltypes.make_float4(1, 0, 0, 0)] * N, dtype=cl.cltypes.float4)
The make_float4
function and float4
types are not recognized. They are executed, but I think since they are not explicitly declared in cltypes.py
, the ides have a hard time understanding
That's because they're generated at runtime:
https://github.com/inducer/pyopencl/blob/291649892f4972e46c5823bfa359b37ad94d6cd5/pyopencl/cltypes.py#L72-L83
I suspect it'd be a simple exercise to rewrite this so that it generates source code that can then be read by an IDE? I'd be open to looking at a PR...
I've looked everywhere and tried many things. It's impossible not to declare the variable name before runtime.
I would just add empty containers type<n>=None
and make_type<n>=None
.
It seems to work locally because after all the containers are overridden in the global namespace by the set_global
from the create_vector_types
function call.
Would that be an okay fix?
It's impossible not to declare the variable name before runtime.
I agree. That's why I proposed that we generate the source at install time.