Skip to content

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

Merged
jaimefrio merged 2 commits into
numpy:masterfrom
seberg:array-too-large
Mar 26, 2016
Merged

jaimefrio merged 2 commits into
numpy:masterfrom
seberg:array-too-large

Conversation

@seberg

@seberg seberg commented Mar 26, 2016

Copy link
Copy Markdown
Member

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

Comment thread numpy/core/tests/test_multiarray.py Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread numpy/core/src/multiarray/ctors.c Outdated
}

/* Check dimensions */
size = sd;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

3 participants