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!

xp_assert_equal(res, expected)


@pytest.mark.skip_xp_backend(Backend.SPARSE, reason="unique_values returns arrays")
Copy link
Member

Choose a reason for hiding this comment

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

what is the problem here?

Copy link
Contributor Author

@OmarManzoor OmarManzoor Nov 7, 2025

Choose a reason for hiding this comment

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

I think we get normal arrays not sparse arrays when using unique_values here.

Copy link
Member

Choose a reason for hiding this comment

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

Could you check whether this is a documented limitation, and maybe file a bug report upstream if not?

@lucascolley lucascolley requested review from lucascolley and removed request for lucascolley November 7, 2025 10:06
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