8000 TST: matmul does not conjugate; wrong? · numpy/numpy@09d4504 · GitHub
[go: up one dir, main page]

Skip to content

Commit 09d4504

Browse files
committed
TST: matmul does not conjugate; wrong?
1 parent 354a452 commit 09d4504

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

numpy/_core/code_generators/ufunc_docstrings.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,12 +2965,12 @@ def add_newdoc(place, name, doc):
29652965
Rotate a set of vectors from Y to X along Z.
29662966
29672967
>>> a = np.array([[0., 1., 0.], [-1., 0., 0.], [0., 0., 1.]])
2968-
>>> v = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.], [0., 0.6, 0.8]])
2968+
>>> v = np.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.], [0., 6., 8.]])
29692969
>>> np.matvec(a, v)
2970-
array([[ 0. , -1. , 0. ],
2971-
[ 1. , 0. , 0. ],
2972-
[ 0. , 0. , 1. ],
2973-
[ 0.6, 0. , 0.8]])
2970+
array([[ 0., -1., 0.],
2971+
[ 1., 0., 0.],
2972+
[ 0., 0., 1.],
2973+
[ 6., 0., 8.]])
29742974
29752975
.. versionadded:: 2.0.0
29762976
""")

numpy/_core/tests/test_ufunc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ def test_vecdot_matvec_vecmat_complex(self, ufunc, shape1, shape2, conj):
868868
expected1 = np.array(((arr1.conj() if conj else arr1) * arr2).sum(),
869869
ndmin=min(len(shape1), len(shape2)))
870870
assert_array_equal(actual1, expected1)
871+
# This would fail for conj=True, since matmul omits the conjugate.
872+
if not conj:
873+
assert_array_equal(arr1.reshape(shape1) @ arr2.reshape(shape2),
874+
expected1)
871875

872876
actual2 = ufunc(arr2.reshape(shape1), arr1.reshape(shape2))
873877
expected2 = np.array(((arr2.conj() if conj else arr2) * arr1).sum(),

0 commit comments

Comments
 (0)
0