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

Function test_complibs

pandas/tests/io/pytables/test_file_handling.py:266–301  ·  view source on GitHub ↗
(tmp_path, lvl, lib, request)

Source from the content-addressed store, hash-verified

264@pytest.mark.parametrize("lib", tables.filters.all_complibs)
265@pytest.mark.filterwarnings("ignore:object name is not a valid")
266def test_complibs(tmp_path, lvl, lib, request):
267 # GH14478
268 if is_platform_linux() and lib == "blosc2" and lvl != 0:
269 request.applymarker(pytest.mark.xfail(reason=f"Fails for {lib} on Linux"))
270 df = DataFrame(
271 np.ones((30, 4)), columns=list("ABCD"), index=np.arange(30).astype(np.str_)
272 )
273
274 # Remove lzo if its not available on this platform
275 if not tables.which_lib_version("lzo"):
276 pytest.skip("lzo not available")
277 # Remove bzip2 if its not available on this platform
278 if not tables.which_lib_version("bzip2"):
279 pytest.skip("bzip2 not available")
280
281 tmpfile = tmp_path / f"{lvl}_{lib}.h5"
282 gname = f"{lvl}_{lib}"
283
284 # Write and read file to see if data is consistent
285 df.to_hdf(tmpfile, key=gname, complib=lib, complevel=lvl)
286 result = read_hdf(tmpfile, gname)
287 tm.assert_frame_equal(result, df)
288
289 is_mac = is_platform_mac()
290
291 # Open file and check metadata for correct amount of compression
292 with tables.open_file(tmpfile, mode="r") as h5table:
293 for node in h5table.walk_nodes(where="/" + gname, classname="Leaf"):
294 assert node.filters.complevel == lvl
295 if lvl == 0:
296 assert node.filters.complib is None
297 elif is_mac and lib == "blosc2":
298 res = node.filters.complib
299 assert res in [lib, "blosc2:blosclz"], res
300 else:
301 assert node.filters.complib == lib
302
303
304@pytest.mark.skipif(

Callers

nothing calls this directly

Calls 6

is_platform_linuxFunction · 0.90
DataFrameClass · 0.90
read_hdfFunction · 0.90
is_platform_macFunction · 0.90
to_hdfMethod · 0.80
astypeMethod · 0.45

Tested by

no test coverage detected