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

Function test_meta_from_array

dask/dataframe/io/tests/test_io.py:23–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22
23def test_meta_from_array():
24 x = np.array([[1, 2], [3, 4]], dtype=np.int64)
25 res = _meta_from_array(x)
26 assert isinstance(res, pd.DataFrame)
27 assert res[0].dtype == np.int64
28 assert res[1].dtype == np.int64
29 tm.assert_index_equal(res.columns, pd.Index([0, 1]))
30
31 x = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64)
32 res = _meta_from_array(x, columns=["a", "b"])
33 assert isinstance(res, pd.DataFrame)
34 assert res["a"].dtype == np.float64
35 assert res["b"].dtype == np.float64
36 tm.assert_index_equal(res.columns, pd.Index(["a", "b"]))
37
38 with pytest.raises(ValueError):
39 _meta_from_array(x, columns=["a", "b", "c"])
40
41 np.random.seed(42)
42 x = np.random.rand(201, 2)
43 x = dd.from_array(x, chunksize=50, columns=["a", "b"])
44 assert len(x.divisions) == 6 # Should be 5 partitions and the end
45
46
47def test_meta_from_1darray():

Callers

nothing calls this directly

Calls 2

_meta_from_arrayFunction · 0.90
seedMethod · 0.45

Tested by

no test coverage detected