Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pandas/tests/io/pytables/test_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import pandas as pd
from pandas import (
DataFrame,
HDFStore,
Series,
read_hdf,
)
import pandas._testing as tm
from pandas.tests.io.pytables.common import ensure_clean_store

from pandas.io.pytables import read_hdf
tables = pytest.importorskip("tables")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this added?

Copy link
Author

@micol-altomare micol-altomare Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke I added that line because pytables (and its HDF5 dependency) aren't available in the Pyodide environment. Thus it skips those tests but keeps full test coverage where the dependency is present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is effectively called in pandas/tests/io/pytables/common.py already so it's not needed here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke Thanks! I have removed the importorskip("tables") and included from pandas.tests.io.pytables.common import tables.

from pandas.tests.io.pytables.common import tables

_ = tables

However, I'm seeing this error frequently come up: Error: ENOENT: no such file or directory, lstat '/home/runner/work/_temp/setup-micromamba/micromamba-shell' This appears to be an issue with the post-run cleanup phase and seems unrelated to my changes. Could you please trigger a retry of the CI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just remove these lines all together. I would consider this an unrelated change that can be addressed in a follow up if needed

Copy link
Author

@micol-altomare micol-altomare Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke Awesome, I just deleted those two lines as requested.

I still have failing automated tests, but I noticed that they're the same as what's failing in the main branch so they're unrelated to my changes. I believe it's ready for another review!



def test_complex_fixed(tmp_path, setup_path):
Expand Down Expand Up @@ -103,7 +104,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)
Expand Down Expand Up @@ -139,7 +141,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
)
Expand All @@ -156,7 +158,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"])

Expand All @@ -183,15 +186,16 @@ 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),
"b": np.random.default_rng(2).standard_normal(100),
}
)

with ensure_clean_store(setup_path) as store:
path = tmp_path / setup_path
with HDFStore(path, mode="a") as store:
store.append("df", df, data_columns=["b"])
store.append("df", df)
result = store.select("df")
Expand Down
9 changes: 4 additions & 5 deletions pandas/tests/io/pytables/test_file_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
)
from pandas.tests.io.pytables.common import (
_maybe_remove,
ensure_clean_store,
tables,
)

Expand Down Expand Up @@ -188,8 +187,8 @@ def test_open_args(tmp_path, setup_path, using_infer_string):
assert not os.path.exists(path)


def test_flush(setup_path):
with ensure_clean_store(setup_path) as store:
def test_flush(tmp_path, setup_path):
with HDFStore(tmp_path / setup_path) as store:
store["a"] = Series(range(5))
store.flush()
store.flush(fsync=True)
Expand Down Expand Up @@ -316,8 +315,8 @@ def test_complibs(tmp_path, lvl, lib, request):
@pytest.mark.skipif(
not is_platform_little_endian(), reason="reason platform is not little endian"
)
def test_encoding(setup_path):
with ensure_clean_store(setup_path) as store:
def test_encoding(tmp_path, setup_path):
with HDFStore(tmp_path / setup_path) as store:
df = DataFrame({"A": "foo", "B": "bar"}, index=range(5))
df.loc[2, "A"] = np.nan
df.loc[3, "B"] = np.nan
Expand Down
Loading