Skip to content

BUG: numpy.einsum indexing arrays now accept numpy int type#16080

Merged
seberg merged 8 commits intonumpy:masterfrom
rlintott:einsum-indexing-int-test-fix
May 16, 2020
Merged

BUG: numpy.einsum indexing arrays now accept numpy int type#16080
seberg merged 8 commits intonumpy:masterfrom
rlintott:einsum-indexing-int-test-fix

Conversation

@rlintott
Copy link
Contributor

@rlintott rlintott commented Apr 26, 2020

Fixes #15961.

All current tests pass. I didn't write any new tests for this though, but perhaps I should do that?

Added tests to check that einsum accepts numpy int64 types and
rejects bool. Rejecting bools is new behaviour in subscript lists.
I changed ValueError to TypeError on line 2496 in multiarraymodule.c
as it is more appropriate. I also modified einsumfunc.py to have the
same behaviour as in the C file when checking subscript list.
(Reject bools but accept anything else from operator.index())
@rlintott
Copy link
Contributor Author

rlintott commented Apr 30, 2020

Please let me know what you think of this new commit! I had to change einsumfunc.py as I did not realise there were two implementations until I started running tests. It does reject bools now. I also changed the valueerror in the C implementation to a typeerror as it seemed more appropriate (and it was causing my tests to fail)

Copy link
Member

@anirudh2290 anirudh2290 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, overall looks good !

@charris
Copy link
Member

charris commented May 7, 2020

Could you add a release note for this under Improvements.

@charris charris added the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label May 7, 2020
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

Just some nits, I may just commit those suggestions and merge in a day or so. If you have some time, happy if you finish it off though (and please see if moving the error creation looks better)!

@seberg seberg self-requested a review May 15, 2020 15:40
@seberg seberg removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label May 16, 2020
@seberg
Copy link
Member

seberg commented May 16, 2020

Thanks Ryan, lets put it in before I wonder if it was nicer before ;).

@seberg seberg merged commit 3ba84d2 into numpy:master May 16, 2020
@rlintott rlintott deleted the einsum-indexing-int-test-fix branch May 10, 2021 08:36
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.

Einsum indexing very fragile, because it tests for int (and int64 is not int)

5 participants