Skip to content

Numpy 1.9 on my Centos build chops int64s into two int32s#11

Open
LeeKamentsky wants to merge 1 commit intoCellH5:masterfrom
LeeKamentsky:np1.9bug
Open

Numpy 1.9 on my Centos build chops int64s into two int32s#11
LeeKamentsky wants to merge 1 commit intoCellH5:masterfrom
LeeKamentsky:np1.9bug

Conversation

@LeeKamentsky
Copy link
Contributor

This bug fixes some problems I'm seeing on our Linux build. I'm not sure if this is a change in behavior in Numpy 1.9 or is something caused by differences in the way the arrays are built. The basic problem is this construct:

> import numpy
> dtype = numpy.dtype([("A", "int32", "B", "int32")])
> a = numpy.array([[1, 2]], int).view(dtype)
> a.shape
(2, 1)

The problem is that "view" looks at the buffer, (0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,) and looks at the dtype which is two integers at four bytes apiece and carves the 16 bytes above into two 8 byte rows. The solution is to explicitly type arrays as numpy.int32 when this construct is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant