From 6d737ba7560e1ef5fef10f1f1f6f1025d4fc8dac Mon Sep 17 00:00:00 2001 From: Jixun Sun <160219251+AnonToky@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:13:19 +0800 Subject: [PATCH 1/2] Refactor test_complex.py to use HDFStore directly --- pandas/tests/io/pytables/test_complex.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pandas/tests/io/pytables/test_complex.py b/pandas/tests/io/pytables/test_complex.py index 80e7664d1969e..afc7c56ad48e0 100644 --- a/pandas/tests/io/pytables/test_complex.py +++ b/pandas/tests/io/pytables/test_complex.py @@ -7,7 +7,7 @@ Series, ) import pandas._testing as tm -from pandas.tests.io.pytables.common import ensure_clean_store +from pandas import HDFStore from pandas.io.pytables import read_hdf @@ -103,7 +103,8 @@ def test_complex_mixed_table(tmp_path, setup_path): index=list("abcd"), ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: store.append("df", df, data_columns=["A", "B"]) result = store.select("df", where="A>2") tm.assert_frame_equal(df.loc[df.A > 2], result) @@ -139,7 +140,7 @@ def test_complex_across_dimensions(tmp_path, setup_path): tm.assert_frame_equal(df, reread) -def test_complex_indexing_error(setup_path): +def test_complex_indexing_error(tmp_path, setup_path): complex128 = np.array( [1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex128 ) @@ -156,7 +157,8 @@ def test_complex_indexing_error(setup_path): "values to data_columns when initializing the table." ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: with pytest.raises(TypeError, match=msg): store.append("df", df, data_columns=["C"]) @@ -183,7 +185,7 @@ def test_complex_series_error(tmp_path, setup_path): tm.assert_series_equal(s, reread) -def test_complex_append(setup_path): +def test_complex_append(tmp_path, setup_path): df = DataFrame( { "a": np.random.default_rng(2).standard_normal(100).astype(np.complex128), @@ -191,7 +193,8 @@ def test_complex_append(setup_path): } ) - with ensure_clean_store(setup_path) as store: + path = tmp_path / setup_path + with HDFStore(path) as store: store.append("df", df, data_columns=["b"]) store.append("df", df) result = store.select("df") From 1224a82294bbf1fe82c09fb7cad3e4d6de4bdbd6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:18:56 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pandas/tests/io/pytables/test_complex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/pytables/test_complex.py b/pandas/tests/io/pytables/test_complex.py index afc7c56ad48e0..e92e2164f36ff 100644 --- a/pandas/tests/io/pytables/test_complex.py +++ b/pandas/tests/io/pytables/test_complex.py @@ -4,10 +4,10 @@ import pandas as pd from pandas import ( DataFrame, + HDFStore, Series, ) import pandas._testing as tm -from pandas import HDFStore from pandas.io.pytables import read_hdf