Package: pandas / 0.23.3+dfsg-3

array_series_matmul.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Description: Fix ordering of np.array @ Series

Author: Ming Li
Origin: upstream
Bug-Debian: https://bugs.debian.org/923708
Forwarded: not-needed

--- pandas-0.23.3+dfsg.orig/pandas/core/series.py
+++ pandas-0.23.3+dfsg/pandas/core/series.py
@@ -2058,7 +2058,7 @@ class Series(base.IndexOpsMixin, generic
 
     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'])
--- pandas-0.23.3+dfsg.orig/pandas/tests/series/test_analytics.py
+++ pandas-0.23.3+dfsg/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)