Skip to content

Commit

Permalink
start adding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 21, 2024
1 parent 6bc9116 commit 75a1514
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
2 changes: 1 addition & 1 deletion narwhals/pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def to_pandas(self) -> Any:
def to_dict(self, *, as_series: bool = True) -> dict[str, Any]:
if as_series:
return {col: self._dataframe[col] for col in self._dataframe.columns}
return self._dataframe.to_dict(orient="list")
return self._dataframe.to_dict(orient="list") # type: ignore[no-any-return]


class LazyFrame(LazyFrameProtocol):
Expand Down
4 changes: 2 additions & 2 deletions narwhals/pandas_like/group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def agg(
out[result_keys.name].append(result_keys.item())

results_keys = dataframe_from_dict(out, implementation=implementation)
results_keys = horizontal_concat(
results_df = horizontal_concat(
[results_keys, *dfs], implementation=implementation
).loc[:, output_names]
return self._from_dataframe(results_keys)
return self._from_dataframe(results_df)

def _from_dataframe(self, df: DataFrame) -> LazyFrame:
from narwhals.pandas_like.dataframe import LazyFrame
Expand Down
24 changes: 0 additions & 24 deletions tests/test_common.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/tpch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def compare_dicts(result: dict[str, Any], expected: dict[str, Any]) -> None:
def test_q1(df_raw: Any) -> None:
var_1 = datetime(1998, 9, 2)
df, pl = to_polars_api(df_raw, version="0.20")
result = (
query_result = (
df.filter(pl.col("l_shipdate") <= var_1)
.group_by(["l_returnflag", "l_linestatus"])
.agg(
Expand All @@ -53,7 +53,7 @@ def test_q1(df_raw: Any) -> None:
)
.sort(["l_returnflag", "l_linestatus"])
)
result = result.collect().to_dict(as_series=False)
result = query_result.collect().to_dict(as_series=False)
expected = {
"l_returnflag": ["A", "N", "N", "R"],
"l_linestatus": ["F", "F", "O", "F"],
Expand Down

0 comments on commit 75a1514

Please sign in to comment.