I am having trouble passing integers in this memory to this (rather trivial) function. Python gives me this error:
ValueError: Buffer dtype mismatch, expected 'int' but got 'long'
Can someone help me understand what is happening? Searching around stackoverflow, it seems to be related to how python interprets types and how C interprets types.
%%cython def myfunction(int [:] y): pass
This creates a ValueError on top.
EDIT: Here are some other things that I discovered.
To clarify, this error persists if I declare y following ways:
y = np.array([0, 0, 1, 1], dtype='int') y = np.array([0, 0, 1, 1], dtype=np.int) y = np.array([0, 0, 1, 1], dtype=np.int64)
However, it works if I declare y with
y = np.array([0, 0, 1, 1], dtype=np.int32)
Anyone want to give a suggestion why this is so? Will throwing np.int32 work on different computers? (I am using macbook pro retina, 2013.)
python numpy cython memoryview
hlin117
source share