()
| 1132 | |
| 1133 | |
| 1134 | def test_get_partition(): |
| 1135 | pdf = pd.DataFrame(np.random.randn(10, 5), columns=list("abcde")) |
| 1136 | ddf = dd.from_pandas(pdf, chunksize=4) |
| 1137 | assert ddf.divisions == (0, 4, 8, 9) |
| 1138 | |
| 1139 | # DataFrame |
| 1140 | div1 = ddf.get_partition(0) |
| 1141 | assert isinstance(div1, dd.DataFrame) |
| 1142 | assert_eq(div1, pdf.loc[0:3]) |
| 1143 | div2 = ddf.get_partition(1) |
| 1144 | assert_eq(div2, pdf.loc[4:7]) |
| 1145 | div3 = ddf.get_partition(2) |
| 1146 | assert_eq(div3, pdf.loc[8:9]) |
| 1147 | assert len(div1) + len(div2) + len(div3) == len(pdf) |
| 1148 | |
| 1149 | # Series |
| 1150 | div1 = ddf.a.get_partition(0) |
| 1151 | assert isinstance(div1, dd.Series) |
| 1152 | assert_eq(div1, pdf.a.loc[0:3]) |
| 1153 | div2 = ddf.a.get_partition(1) |
| 1154 | assert_eq(div2, pdf.a.loc[4:7]) |
| 1155 | div3 = ddf.a.get_partition(2) |
| 1156 | assert_eq(div3, pdf.a.loc[8:9]) |
| 1157 | assert len(div1) + len(div2) + len(div3) == len(pdf.a) |
| 1158 | |
| 1159 | with pytest.raises(ValueError): |
| 1160 | ddf.get_partition(-1) |
| 1161 | |
| 1162 | with pytest.raises(ValueError): |
| 1163 | ddf.get_partition(3) |
| 1164 | |
| 1165 | |
| 1166 | def test_ndim(): |
nothing calls this directly
no test coverage detected