| 65 | |
| 66 | |
| 67 | def test_api_default_format_path(temp_h5_path): |
| 68 | df = DataFrame( |
| 69 | 1.1 * np.arange(120).reshape((30, 4)), |
| 70 | columns=Index(list("ABCD")), |
| 71 | index=Index([f"i-{i}" for i in range(30)]), |
| 72 | ) |
| 73 | |
| 74 | with pd.option_context("io.hdf.default_format", "fixed"): |
| 75 | df.to_hdf(temp_h5_path, key="df") |
| 76 | with HDFStore(temp_h5_path) as store: |
| 77 | assert not store.get_storer("df").is_table |
| 78 | msg = "Can only append to Tables" |
| 79 | with pytest.raises(ValueError, match=msg): |
| 80 | df.to_hdf(temp_h5_path, key="df2", append=True) |
| 81 | |
| 82 | with pd.option_context("io.hdf.default_format", "table"): |
| 83 | df.to_hdf(temp_h5_path, key="df3") |
| 84 | with HDFStore(temp_h5_path) as store: |
| 85 | assert store.get_storer("df3").is_table |
| 86 | df.to_hdf(temp_h5_path, key="df4", append=True) |
| 87 | with HDFStore(temp_h5_path) as store: |
| 88 | assert store.get_storer("df4").is_table |
| 89 | |
| 90 | |
| 91 | def test_put(temp_hdfstore): |