Skip to content

ENH: vectorize cov#507

Merged
lucascolley merged 2 commits into
data-apis:mainfrom
mdhaber:gh502
Nov 4, 2025
Merged

ENH: vectorize cov#507
lucascolley merged 2 commits into
data-apis:mainfrom
mdhaber:gh502

Conversation

@mdhaber

@mdhaber mdhaber commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Closes gh-502

@mdhaber mdhaber left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should address the lint failures.

Comment thread tests/test_funcs.py Outdated
Comment thread src/array_api_extra/_delegation.py Outdated
Comment thread tests/test_funcs.py Outdated
@lucascolley lucascolley self-requested a review October 31, 2025 23:51
Comment thread src/array_api_extra/_lib/_funcs.py
Comment thread src/array_api_extra/_lib/_funcs.py
@lucascolley lucascolley added the enhancement New feature or request label Nov 1, 2025
@lucascolley lucascolley added this to the 0.9.1 milestone Nov 1, 2025
Comment thread tests/test_funcs.py Outdated

@lucascolley 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.

thanks Matt, LGTM!

@lucascolley lucascolley merged commit 39f5889 into data-apis:main Nov 4, 2025
11 checks passed

@mdhaber mdhaber left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BTW @lucascolley, while we were at it, I wanted to ask about 1) enforcing use of double precision and 2) squeezing all singleton dimensions at the end.

I've heard it argued that double precision arithmetic is essential for accurate covariance calculations.
Double precision arithmetic is essentially always important for "accurate" calculations. Personally, I've never used float32 intentionally, but I understand it's important, and I don't see why fundamental libraries should make the choice for the user.

As for the "indescriminate squeeze", I can see why you might want to eliminate a dimension if the covariance between two univariate samples were viewed as a reducing operation. But that calculation is not really possible with one-argument cov, and there is no reason to use cov to take the variance of a single univariate sample. So really, I don't see any good use case for 1D input anyway, and for any other dimensionality, it's not good to eliminate singleton batch dimensions.

@lucascolley

Copy link
Copy Markdown
Member

I don't see why fundamental libraries should make the choice for the user

+1

So really, I don't see any good use case for 1D input anyway, and for any other dimensionality, it's not good to eliminate singleton batch dimensions.

Agreed.

@mdhaber

mdhaber commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

Does array_api_extra need deprecation and all that, or can we just change it?

@mdhaber

mdhaber commented Nov 4, 2025

Copy link
Copy Markdown
Contributor Author

Hmm this seems to have caused a lot of failures in scipy.spatial / scipy/scipy#23929:

Will investigate.

No - there is something between 2059369 and this commit that is causing failures, but I haven't bisected it yet.

@lucascolley

Copy link
Copy Markdown
Member

Does array_api_extra need deprecation and all that

currently TBC: #324

I'd probably be happy to ship the proposed changes in a 0.10.0, supposing no further movement on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: vectorize cov

2 participants