MCPcopy
hub / github.com/pandas-dev/pandas / test_open_args

Function test_open_args

pandas/tests/io/pytables/test_file_handling.py:154–180  ·  view source on GitHub ↗
(using_infer_string)

Source from the content-addressed store, hash-verified

152
153
154def test_open_args(using_infer_string):
155 not_written = f"{uuid.uuid4()}.h5"
156 df = DataFrame(
157 1.1 * np.arange(120).reshape((30, 4)),
158 columns=Index(list("ABCD"), dtype=object),
159 index=Index([f"i-{i}" for i in range(30)], dtype=object),
160 )
161
162 # create an in memory store
163 store = HDFStore(
164 not_written, mode="a", driver="H5FD_CORE", driver_core_backing_store=0
165 )
166 store["df"] = df
167 store.append("df2", df)
168
169 expected = df.copy()
170 if using_infer_string:
171 expected.index = expected.index.astype("str")
172 expected.columns = expected.columns.astype("str")
173
174 tm.assert_frame_equal(store["df"], expected)
175 tm.assert_frame_equal(store["df2"], expected)
176
177 store.close()
178
179 # the file should not have actually been written
180 assert not os.path.exists(not_written)
181
182
183def test_flush(temp_h5_path):

Callers

nothing calls this directly

Calls 9

appendMethod · 0.95
closeMethod · 0.95
DataFrameClass · 0.90
IndexClass · 0.90
HDFStoreClass · 0.90
existsMethod · 0.80
reshapeMethod · 0.45
copyMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected