-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
@@ -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 |
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.
It is a shame we have to allow list the whole function and can't only list the offending parameter.
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.
X-ref python/mypy#13703
def lmplot( | ||
data: Incomplete | None = None, | ||
data: pd.DataFrame, |
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.
sharex: bool | Literal["col", "row"] | None = None, # deprecated | ||
sharey: bool | Literal["col", "row"] | None = None, # deprecated |
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.
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.
x: str | _Vector | None = None, | ||
y: str | _Vector | None = None, |
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.
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
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, |
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.
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] |
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.
_Vector
is defined according to this function. All parameters annotated with _Vector
are handled by this function
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!
No description provided.