Skip to content

BUG: Fix error in fromstring function from numpy.core.records (#9369) #9372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2017

Conversation

charris
Copy link
Member

@charris charris commented Jul 6, 2017

Backport of #9369.

the shape was computer using true division and
ndarray expects a tuple of integers as shape parameter

…9369)

BUG: fix error in fromstring function from numpy.core.records

the shape was computer using true division and
ndarray expects a tuple of integers as shape parameter
@charris charris added this to the 1.13.1 release milestone Jul 6, 2017
@charris charris merged commit b1ad262 into numpy:maintenance/1.13.x Jul 6, 2017
@charris charris deleted the backport-9369 branch July 6, 2017 16:09
@@ -704,7 +704,7 @@ def fromstring(datastring, dtype=None, shape=None, offset=0, formats=None,

itemsize = descr.itemsize
if (shape is None or shape == 0 or shape == -1):
shape = (len(datastring) - offset) / itemsize
shape = (len(datastring) - offset) // itemsize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking here that the remainder is 0 too?

@danielhrisca
Copy link
Contributor

from numpy import dtype
from numpy.core.records import fromstring

data = bytes(list(range(256)))

dtypes = dtype( [('res1', '>u4'), ('t', 'f4')] )

recs = fromstring(data, dtypes)

@charris this simple code gives TypeError: 'float' object cannot be interpreted as an integer in numpy 1.13, and in 1.11 it gives a deprecation warning

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

Successfully merging this pull request may close these issues.

3 participants