Skip to content

Commit 6d737ba

Browse files
authored
Refactor test_complex.py to use HDFStore directly
1 parent 945385d commit 6d737ba

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pandas/tests/io/pytables/test_complex.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Series,
88
)
99
import pandas._testing as tm
10-
from pandas.tests.io.pytables.common import ensure_clean_store
10+
from pandas import HDFStore
1111

1212
from pandas.io.pytables import read_hdf
1313

@@ -103,7 +103,8 @@ def test_complex_mixed_table(tmp_path, setup_path):
103103
index=list("abcd"),
104104
)
105105

106-
with ensure_clean_store(setup_path) as store:
106+
path = tmp_path / setup_path
107+
with HDFStore(path) as store:
107108
store.append("df", df, data_columns=["A", "B"])
108109
result = store.select("df", where="A>2")
109110
tm.assert_frame_equal(df.loc[df.A > 2], result)
@@ -139,7 +140,7 @@ def test_complex_across_dimensions(tmp_path, setup_path):
139140
tm.assert_frame_equal(df, reread)
140141

141142

142-
def test_complex_indexing_error(setup_path):
143+
def test_complex_indexing_error(tmp_path, setup_path):
143144
complex128 = np.array(
144145
[1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j, 1.0 + 1.0j], dtype=np.complex128
145146
)
@@ -156,7 +157,8 @@ def test_complex_indexing_error(setup_path):
156157
"values to data_columns when initializing the table."
157158
)
158159

159-
with ensure_clean_store(setup_path) as store:
160+
path = tmp_path / setup_path
161+
with HDFStore(path) as store:
160162
with pytest.raises(TypeError, match=msg):
161163
store.append("df", df, data_columns=["C"])
162164

@@ -183,15 +185,16 @@ def test_complex_series_error(tmp_path, setup_path):
183185
tm.assert_series_equal(s, reread)
184186

185187

186-
def test_complex_append(setup_path):
188+
def test_complex_append(tmp_path, setup_path):
187189
df = DataFrame(
188190
{
189191
"a": np.random.default_rng(2).standard_normal(100).astype(np.complex128),
190192
"b": np.random.default_rng(2).standard_normal(100),
191193
}
192194
)
193195

194-
with ensure_clean_store(setup_path) as store:
196+
path = tmp_path / setup_path
197+
with HDFStore(path) as store:
195198
store.append("df", df, data_columns=["b"])
196199
store.append("df", df)
197200
result = store.select("df")

0 commit comments

Comments
 (0)