Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST/BUG: run all tests on all backends; fix backend-specific bugs #88

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

crusaderky
Copy link
Contributor

@crusaderky crusaderky commented Jan 13, 2025

  • Fix create_diagonal on JAX
  • Fix kron on JAX, CuPy, and PyTorch
  • Fix pad on JAX
  • Fix in1d on PyTorch
  • Run all tests vs. all backends
  • Individually mark all outstanding failures
  • New public private functions xp_assert_equal and xp_assert_close.
    Note that I have no plans to use these in scipy, as there are enough extra nuances
    there to warrant bespoke variants.

@@ -54,7 +54,9 @@ def in1d(
order = xp.argsort(ar, stable=True)
reverse_order = xp.argsort(order, stable=True)
sar = xp.take(ar, order, axis=0)
if sar.size >= 1:
ar_size = _compat.size(sar)
assert ar_size is not None, "xp.unique*() on lazy backends raises"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Caveat: this is missing data-apis/array-api-compat#231


# mypy: disable-error-code=no-untyped-usage
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The return type of xp.anything is untyped, because xp is a ModuleType

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.

I looked over everything apart from the changes under tests/ to start off with - seems like a good idea, thanks!

Copy link
Member

@lucascolley lucascolley Jan 13, 2025

Choose a reason for hiding this comment

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

could you detail how these functions deviate from the ones in scipy._lib._array_api? If we are going to expose these here, it would be good to be able to remove them from SciPy.

Also, consider #17 (comment). But given we have since changed the scope of array-api-extra to include paths specific to known backends, I think they probably are in-scope now.

EDIT: given

Note that I have no plans to use these in scipy, as there are enough extra nuances
there to warrant bespoke variants.

perhaps there is a way to make these extensible for library-specific nuances, to remove code-duplication somewhat?

Copy link
Contributor Author

@crusaderky crusaderky Jan 13, 2025

Choose a reason for hiding this comment

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

  • no default_ctx context variable
  • no ability to cherry-pick disabling shape, dtype, and/or namespace validation
  • no special casing for 0d

All of these features could be catered for here, but I feel they're all severely overdesigned for ensuring the health of array-api-extra.
My goal was to write something that serves well array-api-extra, and as a nice bonus allows other people to use it.
I'm open to making the whole new module private if you'd prefer it that way.

Copy link
Member

Choose a reason for hiding this comment

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

let's keep it private for now and explain the situation in gh-17. If there are requests for them to be made public in the future, we should reconsider.

@lucascolley lucascolley added the bug Something isn't working label Jan 13, 2025
@lucascolley
Copy link
Member

Also, see #72 for my vision of how I would like to include delegation to library-specific implementations more broadly. The testing introduced here should be enough to push that PR over the line too 🎉

@crusaderky
Copy link
Contributor Author

Made the functions private.
codecov is (correctly) complaining about code paths specific to cupy and sparse.
Ready for final review and merge.

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.

this is fantastic, thanks @crusaderky !

@lucascolley lucascolley merged commit cc9f403 into data-apis:main Jan 14, 2025
8 of 10 checks passed
@crusaderky crusaderky deleted the test_all_xps branch January 14, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants