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

Function test_random_partitions

dask/dataframe/tests/test_dataframe.py:1951–1976  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1949
1950
1951def test_random_partitions():
1952 a, b = d.random_split([0.5, 0.5], 42)
1953 assert isinstance(a, dd.DataFrame)
1954 assert isinstance(b, dd.DataFrame)
1955 assert a._name != b._name
1956 np.testing.assert_array_equal(a.index, sorted(a.index))
1957
1958 assert len(a.compute()) + len(b.compute()) == len(full)
1959 a2, b2 = d.random_split([0.5, 0.5], 42)
1960 assert a2._name == a._name
1961 assert b2._name == b._name
1962
1963 a, b = d.random_split([0.5, 0.5], 42, True)
1964 a2, b2 = d.random_split([0.5, 0.5], 42, True)
1965 assert_eq(a, a2)
1966 assert_eq(b, b2)
1967 with pytest.raises(AssertionError):
1968 np.testing.assert_array_equal(a.index, sorted(a.index))
1969
1970 parts = d.random_split([0.4, 0.5, 0.1], 42)
1971 names = {p._name for p in parts}
1972 names.update([a._name, b._name])
1973 assert len(names) == 5
1974
1975 with pytest.raises(ValueError):
1976 d.random_split([0.4, 0.5], 42)
1977
1978
1979def test_series_round():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
random_splitMethod · 0.80
computeMethod · 0.45

Tested by

no test coverage detected