|
23 | 23 | positive_definite_matrices, MAX_ARRAY_SIZE,
|
24 | 24 | invertible_matrices, two_mutual_arrays,
|
25 | 25 | mutually_promotable_dtypes, one_d_shapes,
|
26 |
| - two_mutually_broadcastable_shapes, SQRT_MAX_ARRAY_SIZE) |
| 26 | + two_mutually_broadcastable_shapes, |
| 27 | + SQRT_MAX_ARRAY_SIZE, finite_matrices) |
27 | 28 | from .pytest_helpers import raises
|
28 | 29 | from . import dtype_helpers as dh
|
29 | 30 |
|
@@ -476,12 +477,31 @@ def test_solve(x1, x2):
|
476 | 477 | pass
|
477 | 478 |
|
478 | 479 | @given(
|
479 |
| - x=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes), |
480 |
| - kw=kwargs(full_matrices=todo) |
| 480 | + x=finite_matrices, |
| 481 | + kw=kwargs(full_matrices=booleans()) |
481 | 482 | )
|
482 | 483 | def test_svd(x, kw):
|
483 |
| - # res = linalg.svd(x, **kw) |
484 |
| - pass |
| 484 | + res = linalg.svd(x, **kw) |
| 485 | + full_matrices = kw.get('full_matrices', True) |
| 486 | + |
| 487 | + *stack, M, N = x.shape |
| 488 | + K = min(M, N) |
| 489 | + |
| 490 | + _test_namedtuple(res, ['u', 's', 'vh'], 'svd') |
| 491 | + |
| 492 | + u, s, vh = res |
| 493 | + |
| 494 | + assert u.dtype == x.dtype, "svd().u did not return the correct dtype" |
| 495 | + assert s.dtype == x.dtype, "svd().s did not return the correct dtype" |
| 496 | + assert vh.dtype == x.dtype, "svd().vh did not return the correct dtype" |
| 497 | + |
| 498 | + assert s.shape == (*stack, K) |
| 499 | + if full_matrices: |
| 500 | + assert u.shape == (*stack, M, M) |
| 501 | + assert vh.shape == (*stack, N, N) |
| 502 | + else: |
| 503 | + assert u.shape == (*stack, M, K) |
| 504 | + assert vh.shape == (*stack, K, N) |
485 | 505 |
|
486 | 506 | @given(
|
487 | 507 | x=xps.arrays(dtype=xps.floating_dtypes(), shape=shapes),
|
|
0 commit comments