Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update signature and tests
  • Loading branch information
dsaxton committed Apr 14, 2020
commit 85d66abc9a7cddcf1549034a8b49257d5420c110
15 changes: 14 additions & 1 deletion pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pandas._libs import lib, missing as libmissing
from pandas._typing import ArrayLike
from pandas.compat import set_function_name
from pandas.compat.numpy import function as nv
from pandas.util._decorators import cache_readonly

from pandas.core.dtypes.base import ExtensionDtype
Expand Down Expand Up @@ -573,7 +574,19 @@ def _reduce(self, name: str, skipna: bool = True, **kwargs):

return result

def sum(self, skipna: bool = True, min_count: int = 0):
def sum(
self,
axis=None,
dtype=None,
out=None,
keepdims=False,
initial=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove all those unnecessary keywords and put them in a **kwargs ?

skipna=True,
min_count=0,
):
nv.validate_sum(
(), dict(dtype=dtype, out=out, keepdims=keepdims, initial=initial)
)
result = masked_reductions.sum(
values=self._data, mask=self._mask, skipna=skipna, min_count=min_count
)
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/arrays/integer/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def test_integer_array_sum(skipna, min_count):
assert result is pd.NA


@pytest.mark.parametrize(
"values, expected", [([1, 2, 3], 6), ([1, 2, 3, None], 6), ([None], 0)]
)
def test_integer_array_numpy_sum(values, expected):
arr = pd.array(values, dtype="Int64")
result = np.sum(arr)
assert result == expected


# TODO(jreback) - these need testing / are broken

# shift
Expand Down