Skip to content

Conversation

@OmarManzoor
Copy link
Contributor

Fixes #491

  • Adds the union1d function.

@lucascolley lucascolley added enhancement New feature or request new function labels Oct 24, 2025
@lucascolley lucascolley changed the title ENH Add union1d ENH: new function union1d Oct 24, 2025
@lucascolley lucascolley self-requested a review October 24, 2025 11:54
@lucascolley lucascolley added this to the 0.9.1 milestone Oct 28, 2025
@lucascolley
Copy link
Member

Relevant upstream context from data-apis/array-api#25 @kgryte :

NumPy includes additional set functions (e.g., in1d, intersect1d, isin, setdiff1d, union1d, setxor1d); however, these functions are not widely implemented by other analyzed array libraries ( see here) and, thus, were not included in this initial specification. Should additional set functions be necessary, they can be proposed in follow-up proposals.

Given @paddyroddy's analysis in gh-491, it looks like absence from PyTorch might still be a blocker for inclusion in the standard? If so, probably fine to proceed with this PR.

Copy link
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

thanks @OmarManzoor, looks good!

@lucascolley lucascolley requested review from lucascolley and removed request for lucascolley November 7, 2025 10:06
@lucascolley
Copy link
Member

@hameerabbasi is there an existing discussion about sparse returning NumPy arrays for functions with naturally dense return values? Blosc does a similar thing with decompressed arrays, and there was a brief discussion at data-apis/array-api#968 (reply in thread) about whether this could be more aligned with the standard.

@OmarManzoor in the meantime, would wrapping the xp.unique_values call in xp.asarray fix the tests for sparse?

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 union1d

2 participants