| 332 | ) |
| 333 | @pytest.mark.parametrize("dtype", ["category", None]) |
| 334 | def test_latin_encoding(temp_h5_path, dtype, val): |
| 335 | enc = "latin-1" |
| 336 | nan_rep = "" |
| 337 | key = "data" |
| 338 | |
| 339 | val = [x.decode(enc) if isinstance(x, bytes) else x for x in val] |
| 340 | ser = Series(val, dtype=dtype) |
| 341 | |
| 342 | ser.to_hdf(temp_h5_path, key=key, format="table", encoding=enc, nan_rep=nan_rep) |
| 343 | retr = read_hdf(temp_h5_path, key) |
| 344 | |
| 345 | # TODO:(3.0): once Categorical replace deprecation is enforced, |
| 346 | # we may be able to re-simplify the construction of s_nan |
| 347 | if dtype == "category": |
| 348 | if nan_rep in ser.cat.categories: |
| 349 | s_nan = ser.cat.remove_categories([nan_rep]) |
| 350 | else: |
| 351 | s_nan = ser |
| 352 | else: |
| 353 | s_nan = ser.replace(nan_rep, np.nan) |
| 354 | |
| 355 | tm.assert_series_equal(s_nan, retr) |
| 356 | |
| 357 | |
| 358 | def test_multiple_open_close(temp_h5_path): |