After installing Yosemite, I had to update numpy, PyOpenGL, etc.
Now the previously running program gives me the following stack trace:
file "latebind.pyx", line 44, in OpenGL_accelerate.latebind.Curry.__call__ (src/latebind.c:1201) File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/OpenGL/GL/VERSION/GL_1_5.py", line 89, in glBufferData return baseOperation( target, size, data, usage ) File "latebind.pyx", line 32, in OpenGL_accelerate.latebind.LateBind.__call__ (src/latebind.c:989) File "wrapper.pyx", line 314, in OpenGL_accelerate.wrapper.Wrapper.__call__ (src/wrapper.c:6505) File "wrapper.pyx", line 311, in OpenGL_accelerate.wrapper.Wrapper.__call__ (src/wrapper.c:6439) ctypes.ArgumentError: ("argument 3: <class 'OpenGL.error.CopyError'>: from_param received a non-contiguous array! []", (GL_ARRAY_BUFFER, 0, array([], dtype=[('time', '<f8'), ('data', [('cluster_index', '<i4'), ('delta_diag_out', '<f8')])]), GL_STREAM_DRAW))
It looks like PyOpenGL wants my array to be contiguous. Looking at the source in numpy_formathandler.pyx in PyOpenGL:
if not PyArray_ISCARRAY( instance ): raise CopyError( """from_param received a non-contiguous array! %s"""%( working, ) )
And PyArray_ISCARRAY (arr) "Evaluates true if the data region arr is continuous C-shaped and PyArray_ISBEHAVED (arr) is true." "PyArray_ISBEHAVED (arr) Evalutes true if the data region arr is aligned and written in machine byte orders according to its descriptor.
However, the flags attribute of the array that was ported to OpenGL:
C_CONTIGUOUS : True F_CONTIGUOUS : True OWNDATA : False WRITEABLE : True ALIGNED : False UPDATEIFCOPY : False
Maybe I need to align the array? But using numpy.require with requirements={'ALIGNED': True} does not work.
I looked at the changes in numpy 1.9 that indicate:
A new compilation environment variable NPY_RELAXED_STRIDES_CHECKING will appear. If this variable is set to 1, then numpy will consider a larger number of arrays as C- or F-adjacent - for example, it becomes possible to have a column vector that counts as C- and F-adjacent at the same time. The new definition is more precise, allows faster code that makes less unnecessary copies, and simplifies the numpys internal code. However, this may also violate third-party libraries, which make too strong assumptions about the step value of C- and F-adjacent arrays. (It is currently known that this violates the Cython code using memoryviews, which will be fixed in Keaton.) THIS WILL BE DEFAULT IN THE FUTURE RELEASE, SO PLEASE TEST YOUR CODE NOW AGAINST THE NUMBERS BUILT IN:
NPY_RELAXED_STRIDES_CHECKING = 1 install python setup.py
You can check if NPY_RELAXED_STRIDES_CHECKING is running by doing:
np.ones ((10, 1), order = "C"). flags.f_contiguous
This will be True if smooth rewind is checked, and False otherwise. A typical problem that we have seen so far is C code, which works with C-adjacent arrays and suggests that access to the elements can be obtained by looking at the last element of the PyArray_STRIDES (arr) array. When steps relax acts, this is wrong (and in fact it was never true in some cases). Use PyArray_ITEMSIZE (arr) instead.
However, np.ones((10, 1), order="C").flags.f_contiguous is false on my system. Therefore, I am at a standstill. What has changed, what makes opengl think that the arrays I'm sending are not contiguous or aligned? Is there a way to align the array using force?