File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -292,13 +292,23 @@ def test_matrix_norm(x, kw):
292
292
# res = _array_module.linalg.matrix_norm(x, **kw)
293
293
pass
294
294
295
+ matrix_power_n = shared (integers (- 1000 , 1000 ), key = 'matrix_power n' )
295
296
@given (
296
- x = xps .arrays (dtype = xps .floating_dtypes (), shape = shapes ),
297
- n = integers (),
297
+ # Generate any square matrix if n >= 0 but only invertible matrices if n < 0
298
+ x = matrix_power_n .flatmap (lambda n : invertible_matrices () if n < 0 else
299
+ xps .arrays (dtype = xps .floating_dtypes (),
300
+ shape = square_matrix_shapes )),
301
+ n = matrix_power_n ,
298
302
)
299
303
def test_matrix_power (x , n ):
300
- # res = _array_module.linalg.matrix_power(x, n)
301
- pass
304
+ res = _array_module .linalg .matrix_power (x , n )
305
+ if n == 0 :
306
+ true_val = lambda x : _array_module .eye (x .shape [0 ], dtype = x .dtype )
307
+ else :
308
+ true_val = None
309
+ # _test_stacks only works with array arguments
310
+ func = lambda x : _array_module .linalg .matrix_power (x , n )
311
+ _test_stacks (func , x , res = res , true_val = true_val )
302
312
303
313
@given (
304
314
x = xps .arrays (dtype = xps .floating_dtypes (), shape = shapes ),
You can’t perform that action at this time.
0 commit comments