-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Conversation
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) |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is brilliantly simple!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Thanks for bearing with my (justified, of course) paranoia. Will merge it as soon as Appveyor gives its OK. Thanks Sebastian! |
And in it goes! |
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