-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
FIX Add check array for empirical_covariance #26108
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
FIX Add check array for empirical_covariance #26108
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @qbarthelemy. We don't need it for _oas
because it's a private function only called by OAS
which already validates X.
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about that again, I think it deserves an entry in the changelog. Please add an entry in v1.3.rst
, saying that now empirical_covariance
gives an informative error message when input is not appropriate.
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Than you for the PR!
354b832
to
f75cb70
Compare
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update! LGTM
@@ -84,7 +84,7 @@ def empirical_covariance(X, *, assume_centered=False): | |||
[0.25, 0.25, 0.25], | |||
[0.25, 0.25, 0.25]]) | |||
""" | |||
X = np.asarray(X) | |||
X = check_array(X, ensure_2d=False, force_all_finite=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers, I think it's okay to set force_all_finite=False
here, which is consistent with the behavior on main
. If we set force_all_finite=True
, then there can be a performance regression when empirical_covariance
is called. The alternative is to set config_context(assume_finite=True)
everywhere, but it adds the context manager to many places.
Th 8000 ere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @qbarthelemy
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Reference Issues/PRs
Fixes #25519
What does this implement/fix? Explain your changes.
It adds
check_array
toempirical_covariance
.