MCPcopy Create free account
hub / github.com/dask/dask / test_svd_supported_array_shapes

Function test_svd_supported_array_shapes

dask/array/tests/test_linalg.py:956–975  ·  view source on GitHub ↗
(chunks, shape)

Source from the content-addressed store, hash-verified

954@pytest.mark.parametrize("chunks", [(10, -1), (-1, 10), (9, -1), (-1, 9)])
955@pytest.mark.parametrize("shape", [(10, 100), (100, 10), (10, 10)])
956def 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
978def test_svd_incompatible_chunking():

Callers

nothing calls this directly

Calls 4

svd_flipFunction · 0.90
assert_eqFunction · 0.90
randomMethod · 0.45
computeMethod · 0.45

Tested by

no test coverage detected