-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Series dot product __rmatmul__ doesn't allow matrix vector multiplication #21578
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
@minggli : Looks like a good start! Can we also add a |
Codecov Report
@@ Coverage Diff @@
## master #21578 +/- ##
=======================================
Coverage 91.9% 91.9%
=======================================
Files 153 153
Lines 49549 49549
=======================================
Hits 45539 45539
Misses 4010 4010
Continue to review full report at Codecov.
|
raised an issue #21581 regarding error message when this is an existing error. need advice. fix it in the same PR and how to do that or should we handle it separately? @jreback |
result = operator.matmul(a.values, a) | ||
# GH 21530 | ||
# vector (list) @ Series (__rmatmul__) | ||
result = operator.matmul(a.values.tolist(), a) |
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.
what about the np.array @ Series
? is that always calling matmul
(and not rmatmul
)?
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.
for both 1d and 2d. the OP example was 2 d, can you add that as well.
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.
np.array @ Series should call __rmatmul__
, so either list or np.array should be the same, i.e. calling __rmatmul__
np.array @ DataFrame however only calls np.array.__matmul__
actioned.
result = operator.matmul(a.values, a) | ||
# GH 21530 | ||
# vector (list) @ Series (__rmatmul__) | ||
result = operator.matmul(a.values.tolist(), a) |
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.
for both 1d and 2d. the OP example was 2 d, can you add that as well.
7a74af7
to
3db45a9
Compare
thanks @minggli very nice |
git diff upstream/master -u -- "*.py" | flake8 --diff
the new
__rmatmul__
implementation in Series seems to be missing matrix vector multiplication case as raised in the issue in question. Only inner product of two vectors was supported in__rmatmul__
method.This PR uses the same implementation in DataFrame to add support in Series and test case.
matmul operator (
@
,@=
) was added in python 3.5 in https://www.python.org/dev/peps/pep-0465/