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

Support for xp.linalg.lu (not yet part of the Array API spec) #45

Open
ogrisel opened this issue May 17, 2023 · 5 comments
Open

Support for xp.linalg.lu (not yet part of the Array API spec) #45

ogrisel opened this issue May 17, 2023 · 5 comments

Comments

@ogrisel
Copy link

ogrisel commented May 17, 2023

Context adding LU factorization to the Array API spec:

Since numpy.linalg.lu does not exist yet (but scipy.linalg.lu does), @rgommers suggested working out an API candidate as part of array-api-compat first by reviewing the API choices and options implemented in various libraries targeting Array API support.

A short term implementation for numpy could probably delegate the work to scipy.linalg.lu in a first iteration.

Based on this work, numpy.linalg could subsequently be extended to directly implement the correct API to be submitted for a future revision of the spec.

Motivation: this is needed to add Array API support to the randomized linear algebra solver for the Principal Component Analysis estimator in scikit-learn:

Non exhaustive list of available implementations:

Related methods in scipy:

@rgommers
Copy link
Member

Thanks @ogrisel! It looks like you only have a single usage in scikit-learn (here), with lu(x, permute_l=True), so if that is covered you should be good for now, right?

I think for the API design decisions, it's best to put them on data-apis/array-api#627. And then let's implement it here. I'll try to post some thoughts there within the next few hours.

@ogrisel
Copy link
Author

ogrisel commented May 17, 2023

It looks like you only have a single usage in scikit-learn (here), with lu(x, permute_l=True), so if that is covered you should be good for now, right?

Yes, this is also what I found out via git grep.

@ntessore
Copy link

If numpy support relied scipy.linalg.lu(), could this be implemented by conditionally adding lu() to numpy-compat's linalg namespace only when scipy is installed, and not making scipy a requirement?

@rgommers
Copy link
Member

That sounds like the right thing to do to me, we don't want this package to have a direct dependency on scipy.

@asmeurer
Copy link
Member

Based on the scope of array-api-compat, lu should be added first to a draft version of the standard. Then we can add it here. It's better to discuss design specifics of it in the array-api repo. For actual implementations, it would be better to discuss that with specific libraries.

Regarding the scipy question, if lu were added, I wouldn't see an issue with making only that function (in the numpy wrapper) depend on scipy.

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

No branches or pull requests

4 participants