[Numpy-discussion] 1.6.0b1 half float buffer bug?
Eli Stevens (Gmail)
Fri Mar 25 13:12:10 CDT 2011
On Fri, Mar 25, 2011 at 10:21 AM, Pauli Virtanen <email@example.com> wrote:
> The buffer interface cannot be used to export the half-float types, since
> the type is not specified in PEP 3118. Numpy cannot unilaterally add
> nonstandard format codes to the spec.
> What can be done instead is exporting the half-float items (and any other
> non-3118 types) as plain bytes. I think this is the way to go.
What about as uint16s? Won't plain bytes have endian issues?
case NPY_HALF: if (_append_char(str, 'H')) return -1; break;
Something like that? I am also still curious about where unit tests
for things like this should go.
> On the Cython side, you'd need to detect when you are working with Numpy
> arrays, and get the half-float type information from the Numpy dtype
> rather than from the exported buffer.
Hrm, okay. I'll have to follow up with the Cython folks about that.
I hope that my fears about that ending up being a sweeping change are
unfounded (having already gone through and made the changes to
unilaterally add support for 'e' buffer types, it seems like it's
baked in; we'll see). :-/
More information about the NumPy-Discussion