Skip to content

Commit

Permalink
Fix missed tests and correct mistake in error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeTT404 committed Feb 3, 2025
1 parent 6dd0216 commit 500ab5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3528,8 +3528,8 @@ def validate(self, other) -> None:
if c == "values_axes" and sax.kind != oax.kind:
raise TypeError(
f"Cannot serialize the column [{oax.values[0]}] "
f"because its data contents are not [{oax.kind}] "
f"but [{sax.kind}] object dtype"
f"because its data contents are not [{sax.kind}] "
f"but [{oax.kind}] object dtype"
)
# Fallback if other source of difference
raise ValueError(
Expand Down
6 changes: 5 additions & 1 deletion pandas/tests/io/pytables/test_append.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ def test_append_raise(setup_path):
df["foo"] = Timestamp("20130101")
store.append("df", df)
df["foo"] = "bar"
msg = re.escape("Cannot serialize the column [foo] but [string] object dtype")
msg = re.escape(
"Cannot serialize the column [foo] "
"because its data contents are not [string] "
"but [datetime64[s]] object dtype"
)
with pytest.raises(TypeError, match=msg):
store.append("df", df)

Expand Down
11 changes: 4 additions & 7 deletions pandas/tests/io/pytables/test_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,11 @@ def test_table_values_dtypes_roundtrip(setup_path):

# incompatible dtype
msg = re.escape(
"invalid combination of [values_axes] on appending data "
"[name->values_block_0,cname->values_block_0,"
"dtype->float64,kind->float,shape->(1, 3)] vs "
"current table [name->values_block_0,"
"cname->values_block_0,dtype->int64,kind->integer,"
"shape->None]"
"Cannot serialize the column [a] "
"because its data contents are not [float] "
"but [integer] object dtype"
)
with pytest.raises(ValueError, match=msg):
with pytest.raises(TypeError, match=msg):
store.append("df_i8", df1)

# check creation/storage/retrieval of float32 (a bit hacky to
Expand Down

0 comments on commit 500ab5a

Please sign in to comment.