array_series_matmul
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 27 Oct 2019 11:38:37 +0000 (11:38 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 27 Oct 2019 11:38:37 +0000 (11:38 +0000)
Author: Ming Li
Origin: upstream
Bug-Debian: https://bugs.debian.org/923708
Forwarded: not-needed

Gbp-Pq: Name array_series_matmul.patch

pandas/core/series.py
pandas/tests/series/test_analytics.py

index 6b005c673c7cd55ccaf6f5d70e046b4b1322aec1..2b93423e9b6702cf4a58957c5f35000e1f430616 100644 (file)
@@ -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'])
index 1e6ea96a5de513c074267998611475d6273a7329..23b33508c2244c717116ef6762d8dc0b1432cfc1 100644 (file)
@@ -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)