Skip to content

Commit

Permalink
Fine-tune tests when pyarrow is not included (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
berland authored Mar 30, 2020
1 parent 1a57b69 commit edcb534
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_virtualensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,20 @@ def test_todisk(tmpdir):
for frame in vens.keys():
if frame == "STATUS":
continue

assert (vens.get_df(frame).columns == fromdisk.get_df(frame).columns).all()

# Columns that only contains NaN will not have their
# type preserved, this is too much to ask for, especially
# with CSV files. So we drop columns with NaN
virtframe = vens.get_df(frame).dropna("columns")
diskframe = fromdisk.get_df(frame).dropna("columns")

assert (virtframe.columns == diskframe.columns).all()

# It would be nice to be able to use pd.Dataframe.equals,
# but it is too strict, as columns with mixed type number/strings
# will easily be wrong.

for column in virtframe.columns:
for column in set(virtframe.columns).intersection(set(diskframe.columns)):
if object in (virtframe[column].dtype, diskframe[column].dtype):
# Ensure we only compare strings when working with object dtype
assert (
Expand Down

0 comments on commit edcb534

Please sign in to comment.