Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH: adding covariance param to corrcoef - see ticket #19852 #21434

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
Loading
from

Conversation

kpalmer29
Copy link

@kpalmer29 kpalmer29 commented May 3, 2022

Param cov was added to corrcoef func in order to accept a pre-calculated covariance matrix

@kpalmer29 kpalmer29 changed the title ENH: adding covariance param to corrcoef - see ticket #19852 -draft ENH: adding covariance param to corrcoef - see ticket #19852 May 4, 2022
Copy link
Member

@seberg seberg left a comment

Choose a reason for hiding this comment

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

Thank you! I am not sure where the decision was standing on adding this, but it seems reasonable to me.

I added a few comments for things that need to be fixed. But the main task implementation-wise will be to add tests for the new feature and also for all the relevant error paths!

@@ -2681,14 +2681,14 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None,
return c.squeeze()


def _corrcoef_dispatcher(x, y=None, rowvar=None, bias=None, ddof=None, *,
def _corrcoef_dispatcher(x=None, cov = None, y=None, rowvar=None, bias=None, ddof=None, *,
Copy link
Member

Choose a reason for hiding this comment

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

The new parameter must be added at the end (or after the *, since order is irrelevant after that). In principle we could add it last, but in practice we want users to write cov=... anyway.

@@ -2728,6 +2728,9 @@ def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *,

.. versionadded:: 1.20

cov : _NoValue, optional
Copy link
Member

Choose a reason for hiding this comment

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

This should be the actual type, i.e. array_like probably

@@ -2818,7 +2821,12 @@ def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *,
# 2015-03-15, 1.10
warnings.warn('bias and ddof have no effect and are deprecated',
DeprecationWarning, stacklevel=3)
c = cov(x, y, rowvar, dtype=dtype)
if x is None and cov is None:
raise ValueError("'x' or 'cov' must be passed as a parameter")
Copy link
Member

Choose a reason for hiding this comment

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

This sould be a TypeError, it should be similar to what you currently get for np.corrcoef() after all.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you check for both being passed. We need to check that exactly one of them is passed only.

@@ -2839,6 +2847,9 @@ def corrcoef(x, y=None, rowvar=True, bias=np._NoValue, ddof=np._NoValue, *,
return c





Copy link
Member

Choose a reason for hiding this comment

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

Please remove these additional blank lines again.

Kavi Palmer and others added 2 commits May 4, 2022 16:02
@seberg seberg added the 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified. label May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Enhancement 62 - Python API Changes or additions to the Python API. Mailing list should usually be notified.
Projects
Status: Pending authors' response
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.