Skip to content

ENH: add nansum - #879

Open
ushnah wants to merge 6 commits into
data-apis:mainfrom
ushnah:nansum
Open

ENH: add nansum#879
ushnah wants to merge 6 commits into
data-apis:mainfrom
ushnah:nansum

Conversation

@ushnah

@ushnah ushnah commented Aug 4, 2026

Copy link
Copy Markdown

Towards #789

  • add support for nansum

@OmarManzoor

Copy link
Copy Markdown
Contributor

@lucascolley I encouraged others in my company to contribute. Could you enable the CI workflows please?

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the PR @ushnah

Comment thread tests/test_funcs.py Outdated
Comment on lines +2358 to +2361
def test_scalar(self, xp: ArrayNamespace):
a = xp.asarray(1.0)
assert nansum(a) == 1.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can remove this test for this function.

Suggested change
def test_scalar(self, xp: ArrayNamespace):
a = xp.asarray(1.0)
assert nansum(a) == 1.0

Comment thread tests/test_funcs.py Outdated
Comment on lines 2374 to 2383
def test_xp(self, axis: int | None, expected_list: list[float], xp: ArrayNamespace):
a = xp.asarray([[4.0, xp.nan, 1.0], [2.0, 3.0, xp.nan]])
res = nansum(a, axis=axis, xp=xp)
expected = xp.asarray(expected_list)
assert_equal(res, expected)


class TestNanMax:
def test_simple(self, xp: ArrayNamespace):
a = xp.asarray([[5, 3], [6, xp.nan]])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can move the TestNanSum after TestNanMax at the end of the file as it is the latest one added.

@OmarManzoor OmarManzoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thank you @ushnah

@OmarManzoor

Copy link
Copy Markdown
Contributor

CC: @lucascolley

@lucascolley
lucascolley self-requested a review August 4, 2026 13:53
@lucascolley lucascolley added this to the 0.11.1 milestone Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants