FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: add `nanmean` by ushnah · Pull Request #910 · data-apis/array-api-extra · GitHub

ENH: add nanmean - #910

Merged
lucascolley merged 4 commits into
data-apis:mainfrom
ushnah:nanmean
Aug 25, 2026
Merged

ENH: add nanmean#910
lucascolley merged 4 commits into
data-apis:mainfrom
ushnah:nanmean

Conversation

ushnah commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Towards #789

  • add support for nanmean

lucascolley self-requested a review August 12, 2026 14:04
lucascolley added enhancement New feature or request new function labels Aug 12, 2026
lucascolley changed the title ENH: add nanmean ENH: add nanmean Aug 12, 2026
lucascolley added this to the 0.11.2 milestone Aug 12, 2026

Copy link
Copy Markdown
Member

cc @OmarManzoor

lucascolley removed their request for review August 12, 2026 18:08
lucascolley linked an issue Aug 12, 2026 that may be closed by this pull request
4 tasks

qbarthelemy 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Branch must be rebased, because code has been moved to src\array_api_extra\_agnostic\_statistical.py

Comment thread src/array_api_extra/_lib/_funcs.py Outdated
Comment thread src/array_api_extra/_lib/_funcs.py Outdated
Comment thread src/array_api_extra/_lib/_funcs.py Outdated
ushnah force-pushed the nanmean branch 3 times, most recently from 4eaf451 to 1ba49d5 Compare August 23, 2026 22:46
Comment thread tests/main/test_statistical.py Outdated
applying changes for mean

Co-authored-by: Omar Salman <omar.salman@arbisoft.com>

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Thank you @ushnah

Copy link
Copy Markdown
Contributor

CC: @lucascolley I think this looks fine to merge

lucascolley self-requested a review August 25, 2026 12:25

lucascolley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

thanks all! One question

Comment on lines +170 to +181
safe_count = xp.astype(
xp.where(count == 0, xp.ones_like(count), count),
sum_.dtype,
copy=False,
)
result = sum_ / safe_count
if xp.any(count == 0):
result = xp.where(
count == 0,
xp.full_like(result, xp.nan),
result,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

why is one of these xp.where calls gated behind xp.any(count == 0), but the other isn't?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Valid point! Maybe we can just remove this extra condition, the where clause is checking for 0s anyways

Copy link
Copy Markdown
Member

In case you are interested in contributing another PR @ushnah, checking off the last item in gh-100 would be a good contribution. That would involve following the instructions at https://data-apis.org/array-api-extra/contributing.html#delegation for

def angle(z: Array, /, *, deg: bool = False, xp: ArrayNamespace | None = None) -> Array:

lucascolley merged commit 52fe44d into data-apis:main Aug 25, 2026
34 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request new function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: add support for nanmin, nanmax, nanmean and nansum

5 participants


Back | FazBrowse Home | New Git URL