-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
TST, MAINT: Make sure exceptions of inner
and dot
match for different cases
#6987
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
Conversation
8996992
to
724c915
Compare
c = 1. | ||
A = np.array((1,1), dtype='i,i') | ||
|
||
try: |
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.
Any reason not to use assert_raises
here?
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.
None, I wasn't sure the right way to do this in numpy
's test suite and took test_mul
as an example.
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.
Would you prefer it changed?
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.
It was changed to assert_raises
.
IIRC, there was a suggestion that |
I feel like one of these is a bug, but I am just not sure which one. I agree that |
FWIW, if we decided changing the exception is just not ok, it would be trivial to preserve the current behavior in PR ( #6968 ), but I just wanted to raise this oddity separately so it could be discussed more directly. |
Another nice consequence of changing everything to
It will still work. |
Interesting, seeing a failure on |
e94fbb3
to
9fb0d0c
Compare
I can reproduce this here with 3.4.4. A bit more info is in the comment in the cpython code.
|
f29c32a
to
85ce899
Compare
inner
and dot
match for different cases
Failures on AppVeyor ( #6991 ) had not previously occurred for this PR with exception of the segmentation fault issue (also happened on Travis), which has since been resolved. I believe these to be unrelated to the content of this PR. |
fabb617
to
3b47987
Compare
As AppVeyor is merging with master, which is broken, it is currently failing the tests there. So, I ran my own AppVeyor build without this merge (this is rebased on a commit on |
3b47987
to
b898b60
Compare
@jakirkham Needs a rebase. |
☔ The latest upstream changes (presumably #6968) made this pull request unmergeable. Please resolve the merge conflicts. |
Sure, @charris, can do. Are we actually happy with this change though or should we switch everything to |
b898b60
to
b9cdc50
Compare
I rebased it so hopefully the proposed change is clearer to see. |
37bda68
to
8ef338c
Compare
Honestly, I kind of think they all of them should be |
Yeah, lets go with |
Sure, I'll update it. There are a couple other cases in the same file where it raises a |
8ef338c
to
5fc07a2
Compare
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This behaviour mimics that of other functions such as ``np.inner``. If the two | ||
arguments cannot be cast to a common type, ``np.dot`` will now always raise a | ||
``TypeError``. Before it had raise ``ValueError`` in some cases. |
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.
had -> could
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 realized after rereading this there were many issues and so rewrote it. Also, is this in the right place? I wasn't sure where this sort of change went so just stuck it here.
51d8764
to
6ccba3c
Compare
No worries. It was a pretty minor one. Thanks for the feedback. |
Well, I would not worry about changing this at all. Changing it the other way around (dot) maybe a little, but also not too much, if you feel strongly that the current error type is bad, I think I won't stop you. |
I'd put iot under compatibility notes rather than changes. |
Or maybe both ;) |
…nnot be cast to a common type.
6ccba3c
to
ef09a84
Compare
TST, MAINT: Make sure exceptions of `inner` and `dot` match for different cases
Thanks @jakirkham . |
Sure. Thanks everyone. |
Related: #6988
Fixes an issue with
dot
where it wasValueError
or aTypeError
depending on the order of its arguments. This differs frominner
, which always raises aTypeError
. Below is an example of the current behavior, which seems odd. This PR makes all cases raise aTypeError
.