Skip to content

TYP: type annotations for nancorr #44227

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

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions pandas/_libs/algos.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,14 @@ def kth_smallest(
# Pairwise correlation/covariance

def nancorr(
mat: np.ndarray, # const float64_t[:, :]
mat: npt.NDArray[np.float64], # const float64_t[:, :]
cov: bool = ...,
minp=...,
) -> np.ndarray: ... # ndarray[float64_t, ndim=2]
minp: int | None = ...,
Copy link
Member Author

Choose a reason for hiding this comment

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

we may pass None from pandas/core/frame.py:9667. base_cov = libalgos.nancorr(mat, cov=True, minp=min_periods)

In nancorr_spearman we don't allow None, if not specified, the default is 1, specified in the function signature.

The default is also 1 in nancorr, coded if None which is the signature default.

Not sure whether this inconsistency is a big deal.

Copy link
Contributor

Choose a reason for hiding this comment

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

could open an issue about this

) -> npt.NDArray[np.float64]: ... # ndarray[float64_t, ndim=2]
def nancorr_spearman(
mat: np.ndarray, # ndarray[float64_t, ndim=2]
mat: npt.NDArray[np.float64], # ndarray[float64_t, ndim=2]
minp: int = ...,
) -> np.ndarray: ... # ndarray[float64_t, ndim=2]
def nancorr_kendall(
Copy link
Member Author

Choose a reason for hiding this comment

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

this was removed in #43403

mat: np.ndarray, # ndarray[float64_t, ndim=2]
minp: int = ...,
) -> np.ndarray: ... # ndarray[float64_t, ndim=2]
) -> npt.NDArray[np.float64]: ... # ndarray[float64_t, ndim=2]
Copy link
Member

Choose a reason for hiding this comment

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

have you heard anything about if/when/how npt.NDArray is going to support something equivalent to ndim=2?


# ----------------------------------------------------------------------

Expand Down