Skip to content
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

BUG: fix array too big error for wide dtypes. #7463

Merged
merged 2 commits into from
Mar 26, 2016

Conversation

seberg
Copy link
Member

@seberg seberg commented Mar 26, 2016

The error was not being raised when arr.size * arr.dtype.itemsize
was too large, but only when arr.size was too large alone.

Closes gh-7451

np.ndarray(buffer=buf, strides=(0,),
shape=(max_bytes//itemsize,), dtype=dtype)
assert_raises(ValueError, np.ndarray, buffer=buf, strides=(0,),
shape=(max_bytes//itemsize + itemsize,), dtype=dtype)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be shape=(max_bytes//itemsize + 1,)? I think that's the first size that will error...

Copy link
Member Author

Choose a reason for hiding this comment

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

Hah, yes, I had that first and some other error (I think dtype was missing first), and then without thinking put that ;). Fixed.

The error was not being raised when arr.size * arr.dtype.itemsize
was too large, but only when arr.size was too large alone.

Closes numpygh-7451
@@ -950,6 +949,8 @@ PyArray_NewFromDescr_int(PyTypeObject *subtype, PyArray_Descr *descr, int nd,
}
}

/* Check dimensions */
size = sd;
Copy link
Member

Choose a reason for hiding this comment

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

This is brilliantly simple!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm, could rename size to nbytes or so maybe if you like.

Copy link
Member

Choose a reason for hiding this comment

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

I'm OK with the name, I'm just amazed at how simply you have solved this: I took a look at this a couple of days ago and didn't find any clean way of fixing it.

@jaimefrio
Copy link
Member

Thanks for bearing with my (justified, of course) paranoia. Will merge it as soon as Appveyor gives its OK. Thanks Sebastian!

@jaimefrio jaimefrio merged commit 6cdb45f into numpy:master Mar 26, 2016
@jaimefrio
Copy link
Member

And in it goes!

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.

None yet

3 participants