Skip to content

Commit

Permalink
Address code coverage in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gitosaurus committed Nov 26, 2024
1 parent e817e45 commit e247940
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nested_pandas/nestedframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def reduce(self, func, *args, **kwargs) -> NestedFrame: # type: ignore[override
Takes a function and applies it to each top-level row of the NestedFrame.
The user may specify which columns the function is applied to, with
columns from the 'base' layer being passsed to the function as
columns from the 'base' layer being passed to the function as
scalars and columns from the nested layers being passed as numpy arrays.
Parameters
Expand Down
8 changes: 8 additions & 0 deletions tests/nested_pandas/nestedframe/test_nestedframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,14 @@ def offset_avg(offset, col_to_avg, column_names):
for i in range(len(result)):
assert result["offset_avg"].values[i] == expected_offset_avg[i]

# Verify that we can understand a string argument to the reduce function,
# so long as it isn't a column name.
def make_id(col1, prefix_str):
return f"{prefix_str}{col1}"

result = nf.reduce(make_id, "b", "some_id_")
assert result[0][1] == "some_id_4"


def test_reduce_duplicated_cols():
"""Tests nf.reduce() to correctly handle duplicated column names."""
Expand Down

0 comments on commit e247940

Please sign in to comment.