From: Debian Science Team Date: Fri, 20 Sep 2019 07:01:37 +0000 (+0100) Subject: array_series_matmul X-Git-Tag: archive/raspbian/0.25.3+dfsg2-2+rpi1~1^2^2^2^2^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fc47a63dbdcd0239b2e898a16dca37133aa02fdd;p=pandas.git array_series_matmul Author: Ming Li Origin: upstream Bug-Debian: https://bugs.debian.org/923708 Forwarded: not-needed Gbp-Pq: Name array_series_matmul.patch --- diff --git a/pandas/core/series.py b/pandas/core/series.py index 6b005c67..2b93423e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2058,7 +2058,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame): def __rmatmul__(self, other): """ Matrix multiplication using binary `@` operator in Python>=3.5 """ - return self.dot(other) + return self.dot(np.transpose(other)).T @Substitution(klass='Series') @Appender(base._shared_docs['searchsorted']) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 1e6ea96a..23b33508 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -950,6 +950,11 @@ class TestSeriesAnalytics(TestData): expected = np.dot(a.values, a.values) assert_almost_equal(result, expected) + # np.array (matrix) @ Series (__rmatmul__) + result = operator.matmul(b.T.values, a) + expected = np.dot(b.T.values, a.values) + assert_almost_equal(result, expected) + # mixed dtype DataFrame @ Series a['p'] = int(a.p) result = operator.matmul(b.T, a)