| 954 | @pytest.mark.parametrize("chunks", [(10, -1), (-1, 10), (9, -1), (-1, 9)]) |
| 955 | @pytest.mark.parametrize("shape", [(10, 100), (100, 10), (10, 10)]) |
| 956 | def test_svd_supported_array_shapes(chunks, shape): |
| 957 | # Test the following cases for tall-skinny, short-fat and square arrays: |
| 958 | # - no chunking |
| 959 | # - chunking that contradicts shape (e.g. a 10x100 array with 9x100 chunks) |
| 960 | # - chunking that aligns with shape (e.g. a 10x100 array with 10x9 chunks) |
| 961 | x = np.random.default_rng().random(shape) |
| 962 | dx = da.from_array(x, chunks=chunks) |
| 963 | |
| 964 | du, ds, dv = da.linalg.svd(dx) |
| 965 | du, dv = da.compute(du, dv) |
| 966 | |
| 967 | nu, ns, nv = np.linalg.svd(x, full_matrices=False) |
| 968 | |
| 969 | # Correct signs before comparison |
| 970 | du, dv = svd_flip(du, dv) |
| 971 | nu, nv = svd_flip(nu, nv) |
| 972 | |
| 973 | assert_eq(du, nu) |
| 974 | assert_eq(ds, ns) |
| 975 | assert_eq(dv, nv) |
| 976 | |
| 977 | |
| 978 | def test_svd_incompatible_chunking(): |