File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 23
23
positive_definite_matrices , MAX_ARRAY_SIZE ,
24
24
invertible_matrices ,
25
25
mutually_promotable_dtypes )
26
+ from .pytest_helpers import raises
26
27
27
28
from . import _array_module
28
29
@@ -246,8 +247,18 @@ def test_inv(x):
246
247
x2 = xps .arrays (dtype = xps .floating_dtypes (), shape = shapes ),
247
248
)
248
249
def test_matmul (x1 , x2 ):
249
- # res = _array_module.linalg.matmul(x1, x2)
250
- pass
250
+ if (x1 .shape == () or x2 .shape == ()
251
+ or len (x1 .shape ) == len (x2 .shape ) == 1 and x1 .shape != x2 .shape
252
+ or len (x1 .shape ) == 1 and len (x2 .shape ) >= 2 and x1 .shape [0 ] != x2 .shape [- 2 ]
253
+ or len (x2 .shape ) == 1 and len (x1 .shape ) >= 2 and x2 .shape [0 ] != x1 .shape [- 1 ]
254
+ or len (x1 .shape ) >= 2 and len (x2 .shape ) >= 2 and x1 .shape [- 1 ] != x2 .shape [- 2 ]):
255
+ # The spec doesn't specify what kind of exception is used here. Most
256
+ # libraries will use a custom exception class.
257
+ raises (Exception , lambda : _array_module .linalg .matmul (x1 , x2 ),
258
+ "matmul did not raise an exception for invalid shapes" )
259
+ return
260
+ else :
261
+ res = _array_module .linalg .matmul (x1 , x2 )
251
262
252
263
@given (
253
264
x = xps .arrays (dtype = xps .floating_dtypes (), shape = shapes ),
You can’t perform that action at this time.
0 commit comments