Question

I'm getting the following warning message when I try to use a ctypes array as a numpy array:

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes, numpy
>>> TenByteBuffer = ctypes.c_ubyte * 10
>>> a = TenByteBuffer()
>>> b = numpy.ctypeslib.as_array(a)
C:\Python27\lib\site-packages\numpy\ctypeslib.py:402: RuntimeWarning: Item size
computed from the PEP 3118 buffer format string does not match the actual item s
ize.
  return array(obj, copy=False)
>>> b
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)

The code seems to be working, though. Is it a bad idea to ignore this warning?

Background: I'm calling a C DLL that produces data in real time. I need to pass the DLL a series of buffers to hold the data. While waiting for the next buffer to fill, I'd like to process the most recent buffer with numpy and save the result. I'm generating the buffers with code like above, and things seem to be working, but I don't want to sweep an important problem under the rug.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top