()
| 21 | |
| 22 | |
| 23 | def 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 | |
| 47 | def test_meta_from_1darray(): |
nothing calls this directly
no test coverage detected