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

Laurent Gautier lgautier@gmail....
Wed Nov 17 21:36:34 CST 2010


Thanks for the reply.

On 11/17/10 7:00 PM, Pauli Virtanen<pav@iki.fi> wrote:
>
> 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.

That would be the __array_struct__ attribute, I suppose.

>> >  my buffer format is 'f', and the view has itemsize set as:
>> >  view->itemsize = sizeof(double);
>> >
>> >  Any pointer regarding what might be going on ?
> Seehttp://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.

It seems that I have been mislead by some documentation (which I cannot 
find again). I had something that 'f' indicated a "Python float", which 
I understand to be represented by a double at C-level.



Laurent


> -- Pauli Virtanen



More information about the NumPy-Discussion mailing list