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

seaborn: fix and complete seaborn.regression #11043

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

hamdanal
Copy link
Contributor

No description provided.

@@ -1,3 +1,5 @@
seaborn._core.scales.(Pipeline|TransFuncs) # aliases defined in `if TYPE_CHECKING` block
seaborn.external.docscrape.ClassDoc.__init__ # stubtest doesn't like ABC class as default value
seaborn.external.docscrape.NumpyDocString.__str__ # weird signature

seaborn(\.regression)?\.lmplot # the `data` argument is required but it defaults to `None` at runtime
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a shame we have to allow list the whole function and can't only list the offending parameter.

Copy link
Member

Choose a reason for hiding this comment

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

def lmplot(
data: Incomplete | None = None,
data: pd.DataFrame,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +31 to +32
sharex: bool | Literal["col", "row"] | None = None, # deprecated
sharey: bool | Literal["col", "row"] | None = None, # deprecated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/mwaskom/seaborn/blob/d4b8de81f74a153bb3c15af760d956d32aad980b/seaborn/regression.py#L601-L603. I'll handle the deprecations of seaborn using typing_extensions.deprecated in another PR.

Comment on lines +98 to +99
x: str | _Vector | None = None,
y: str | _Vector | None = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

x, y and the like can only be str if data is provided as a data frame, otherwise they must be vectors: https://seaborn.pydata.org/generated/seaborn.regplot.html

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

x_estimator: Incomplete | None = None,
x_bins: Incomplete | None = None,
legend_out: bool | None = None, # deprecated
x_estimator: Callable[[Incomplete], Incomplete] | None = None,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure how to type the argument and return type of this callable. It is documented as "callable that maps vector -> scalar", something like numpy.mean but I think it will require Higher-Kinded TypeVars and a lot of overloads to get it right (unless I am missing something trivial about it)


from .axisgrid import FacetGrid
from .utils import _Palette, _Seed

__all__ = ["lmplot", "regplot", "residplot"]

_Vector: TypeAlias = list[Incomplete] | pd.Series[Incomplete] | pd.Index[Incomplete] | NDArray[Incomplete]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

_Vector is defined according to this function. All parameters annotated with _Vector are handled by this function

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau merged commit aef6e22 into python:main Nov 21, 2023
47 checks passed
@hamdanal hamdanal deleted the seaborn-regression branch November 25, 2023 07:32
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

Successfully merging this pull request may close these issues.

3 participants