On Tue, Aug 19, 2014 at 8:51 AM, Robert Bradshaw <
robe...@gmail.com> wrote:
> Generally, if the problem is due to being on Windows, we're counting
> on someone with knowledge about and access to Windows to answer. In
> other words, windows users are expected to support other windows
> users, just as linux users and mac users support each other (with the
> added benefit that the latter two groups include developers).
>
> As it looks like you can reproduce this issue on other platforms; I
> can look into it.
On this note, the thread you bumped was titled "Buffer dtype mismatch
error on Windows but not OSX" which made it sound very Windows
specific.
> On Tue, Aug 19, 2014 at 4:51 AM, Gregorio Bastardo
> <
gregorio...@gmail.com> wrote:
>> Hello,
>>
>> We experienced this issue also under OS X, see the updated gist for details.
>>
>>>
https://gist.github.com/gregorio-bastardo/f2be00493a5b8c186c08
See below for a smaller example of this error.
The problem seems to be that if the full struct has size a multiple of
4 then the Py_buffer format string numpy gives drops the alignment
parameter (which is still use to align sub-structs). For example, when
using the code below numpy specifies a buffer format of
T{T{h:s:b:t:}:a:b:x:}
which, per
https://docs.python.org/2/library/struct.html#module-struct
, says to use native alignment
but uncommenting y (adding an extra byte, bringing the total to 5 bytes) we get
T{T{=h:s:b:t:}:a:b:x:b:y:}
which does give us alignment information and our internal struct
format agrees with this numpy format string.
One short term solution is to add a dummy byte at the end, but
hopefully we should have a fix out soon.
--------------------------------------
import numpy as np
cimport numpy as np
cdef packed struct A:
np.int16_t s
np.int8_t t
a = [
('s', np.int16),
('t', np.int8),
]
cdef packed struct B:
A a
np.int8_t x
# np.int8_t y
b = [
('a', a),
('x', np.int8),
# ('y', np.int8),
]
cdef test_it():
print sizeof(B)
print "try"
cdef np.ndarray[B, ndim=1] input = np.zeros(10, dtype=b)
print "ok"
test_it()
--------------------------------------