[Numpy-discussion] RuntimeWarning: Item size computed from the PEP 3118

Pauli Virtanen pav@iki...
Wed Nov 17 04:07:20 CST 2010


Wed, 17 Nov 2010 08:40:50 +0100, Laurent Gautier wrote:
[clip]
> __main__:1: RuntimeWarning: Item size computed from the PEP 3118 buffer
> format string does not match the actual item size.
[clip]
> I tried tracing a bit further but I am a little confused by what is the
> intent (a lot of nested calls).

Numpy is warning you that the view that you passed to it is inconsistent, 
and it indicates that it refuses to consider it as a PEP 3118 buffer. If 
you use it on Python 2.x, it probably falls back to using the legacy 
buffer interface which does not care about the format string.

> my buffer format is 'f', and the view has itemsize set as:
> view->itemsize = sizeof(double);
> 
> Any pointer regarding what might be going on ?

See http://docs.python.org/library/struct.html#format-strings

The format 'f' means 32-bit float, so the view itemsize should be 
sizeof(float) and not sizeof(double). If your view really contains floats 
in sizeof(double) bytes, the buffer format string probably should 
indicate the padding.

-- 
Pauli Virtanen



More information about the NumPy-Discussion mailing list