Skip to content

Fix bug in ravel_multi_index for big indices (Issue #7546) - #8109

Merged
charris merged 3 commits into
numpy:masterfrom
skwbc:issue#7546
Oct 22, 2016
Merged

charris merged 3 commits into
numpy:masterfrom
skwbc:issue#7546

Conversation

@skwbc

@skwbc skwbc commented Oct 2, 2016

Copy link
Copy Markdown
Contributor

I fixed bug on Issue #7546 .

1st commit:

As @jaimefrio said, I just changed type of variable s from int to npy_intp.

2nd commit (not confident):

I added checking for array size overflow using npy_mul_with_overflow_intp, similar to PR #7463 .
It's my understanding that in PR #7463 @seberg checked wheather arr.size * arr.dtype.itemsize is greater than np.iinfo(np.intp).max.
However, in ravel_multi_index we don't know the type of the array defined by dims argument.
So, I just checked whether arr.size is greater than np.iinfo(np.intp).max. Is this fix okay?

@seberg seberg left a comment

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.

Seems good to me, could fix that indentation (best squashed into the other commites).
We don't have to make sure that the index is valid for a specific array here after all, we just have to make sure we don't get a wrong result.

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.

Extra level of indentation would be nice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I modified indentation here by editing 2nd commit (git rebase -i).

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.

Thanks, will merge soon unless someone else wants to chime in I think. Remind me if I forget ;).

@charris

charris commented Oct 22, 2016

Copy link
Copy Markdown
Member

Thanks @skwbc .

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