Skip to content

Commit

Permalink
Pyarrow test
Browse files Browse the repository at this point in the history
  • Loading branch information
ramedina86 committed Jul 3, 2023
1 parent 7932f45 commit 32279e8
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pandas as pd
import pytest
import altair
import pyarrow as pa
import urllib

raw_state_dict = {
"name": "Robert",
Expand Down Expand Up @@ -453,18 +455,6 @@ def test_numpy_array_with_complex(self) -> None:
with pytest.raises(StateSerialiserException):
self.sts.serialise(d)

def test_multiindex_in_dataframe(self) -> None:
data = {
("column_a", 1): [1, 2, 3, 4],
("column_b", 2): [5, 6, 7, 8],
}
d = {
"name": "Multiindex dataframe",
"df": pd.DataFrame(data)
}
s = self.sts.serialise(d)
assert s.get("df").get("data").get("('column_a', 1)") is not None

def test_nans_in_dataframe(self) -> None:
data = {
"column_a": [1, 2, np.nan, 4],
Expand Down Expand Up @@ -494,11 +484,13 @@ def test_pandas_df(self) -> None:
"df": pd.read_csv(self.df_path)
}
s = self.sts.serialise(d)
df_d = s.get("df").get("data")
assert s.get("name") == "Normal name"
assert df_d.get("name").get("0") == "Byte"
assert df_d.get("length_cm").get("2") == 32

df_durl = s.get("df")
df_buffer = urllib.request.urlopen(df_durl)
reader = pa.ipc.open_file(df_buffer)
table = reader.read_all()
assert table.column("name")[0].as_py() == "Byte"
assert table.column("length_cm")[2].as_py() == 32

class TestEvaluator:

Expand Down

0 comments on commit 32279e8

Please sign in to comment.