(datapath)
| 2318 | |
| 2319 | |
| 2320 | def test_chunked_categorical_partial(datapath): |
| 2321 | dta_file = datapath("io", "data", "stata", "stata-dta-partially-labeled.dta") |
| 2322 | values = ["a", "b", "a", "b", 3.0] |
| 2323 | msg = "series with value labels are not fully labeled" |
| 2324 | with StataReader(dta_file, chunksize=2) as reader: |
| 2325 | with tm.assert_produces_warning(CategoricalConversionWarning, match=msg): |
| 2326 | for i, block in enumerate(reader): |
| 2327 | assert list(block.cats) == values[2 * i : 2 * (i + 1)] |
| 2328 | if i < 2: |
| 2329 | idx = pd.Index(["a", "b"]) |
| 2330 | else: |
| 2331 | idx = pd.Index([3.0], dtype="float64") |
| 2332 | tm.assert_index_equal(block.cats.cat.categories, idx) |
| 2333 | with tm.assert_produces_warning(CategoricalConversionWarning, match=msg): |
| 2334 | with StataReader(dta_file, chunksize=5) as reader: |
| 2335 | large_chunk = reader.__next__() |
| 2336 | direct = read_stata(dta_file) |
| 2337 | tm.assert_frame_equal(direct, large_chunk) |
| 2338 | |
| 2339 | |
| 2340 | @pytest.mark.parametrize("chunksize", (-1, 0, "apple")) |
nothing calls this directly
no test coverage detected