Skip to content

Commit 6e51116

Browse files
Add test for dpnp.linalg.matrix_transpose()
1 parent 57687bd commit 6e51116

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_linalg.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,27 @@ def test_matrix_rank_errors(self):
21092109
)
21102110

21112111

2112+
# numpy.linalg.matrix_transpose() is available since numpy >= 2.0
2113+
@testing.with_requires("numpy>=2.0")
2114+
# dpnp.linalg.matrix_transpose() calls dpnp.matrix_transpose()
2115+
# 1 test to increase code coverage
2116+
def test_matrix_transpose():
2117+
a = numpy.arange(6).reshape((2, 3))
2118+
a_dp = inp.array(a)
2119+
2120+
expected = numpy.linalg.matrix_transpose(a)
2121+
result = inp.linalg.matrix_transpose(a_dp)
2122+
2123+
assert_allclose(expected, result)
2124+
2125+
with assert_raises_regex(
2126+
ValueError, "array must be at least 2-dimensional"
2127+
):
2128+
inp.linalg.matrix_transpose(a_dp[:, 0])
2129+
2130+
assert_raises(ValueError, inp.linalg.matrix_transpose, a_dp[:, 0])
2131+
2132+
21122133
class TestNorm:
21132134
def setup_method(self):
21142135
numpy.random.seed(42)

0 commit comments

Comments
 (0)