Skip to content

More tests on the API #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 1, 2021
Merged
Changes from 2 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
16 changes: 16 additions & 0 deletions protocol/pandas_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,31 @@ def get_chunks(self, n_chunks : Optional[int] = None) -> Iterable['_PandasDataFr
# Roundtrip testing
# -----------------

def test_column(pdcol:pd.Series, col: _PandasColumn):
assert pdcol.size == col.size
assert col.offset == 0
assert pdcol.isnull().sum() == col.null_count

def test__dataframe__(df:pd.DataFrame, dfo: DataFrameObject):
assert dfo.num_columns() == len(df.columns)
assert dfo.num_rows() == len(df)
assert dfo.num_chunks() == 1
assert dfo.column_names() == list(df.columns)
for col in df.columns:
test_column(df[col], dfo.get_column_by_name(col))

def test_float_only():
df = pd.DataFrame(data=dict(a=[1.5, 2.5, 3.5], b=[9.2, 10.5, 11.8]))
df2 = from_dataframe(df)
test__dataframe__(df, df.__dataframe__())
tm.assert_frame_equal(df, df2)


def test_mixed_intfloat():
df = pd.DataFrame(data=dict(a=[1, 2, 3], b=[3, 4, 5],
c=[1.5, 2.5, 3.5], d=[9, 10, 11]))
df2 = from_dataframe(df)
test__dataframe__(df, df.__dataframe__())
tm.assert_frame_equal(df, df2)


Expand Down Expand Up @@ -575,6 +590,7 @@ def test_categorical_dtype():
assert col.describe_categorical == (False, True, {0: 1, 1: 2, 2: 5})

df2 = from_dataframe(df)
test__dataframe__(df, df.__dataframe__())
tm.assert_frame_equal(df, df2)


Expand Down