I'm having problems using an (integer) element of a pyopencl array as a
simple number for indexing.
I get the error which I think comes from pyopencl's array.py
'raise IndexError("invalid subindex in axis %d" % index_axis)'
If I understand correctly, this error appears because the condition
'isinstance(index_entry, (int, np.integer))' in line 1295 fails.
And indeed, I can reproduce the phenomenon like this:
import numpy as n
import pyopencl as cl
import pyopencl.array as cl_arr
ctx = cl.create_some_context()
qu = cl.CommandQueue(ctx)
c = cl_arr.empty(qu, (1,), dtype=n.int32).fill(9)
whichc = c.__getitem__(0)
print(whichc) # gives 9
print(whichc.shape) # gives ()
print(isinstance(whichc, n.integer)) # gives False
print(isinstance(whichc, int)) # gives False
print(isinstance(whichc, n.int32)) # gives False
convert = n.int(whichc) # gives error
The error at the last line is:
Traceback (most recent call last):
File "int_test.py", line 19, in <module>
convert = n.int(whichc)
TypeError: int() argument must be a string or a number, not 'Array'
Is it a bug or a feature that the element neither belongs to n.integer,
n.int32, nor int, and somehow still seems to be an Array, even after
Thanks for any hints,