-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: annotate plotting._matplotlib.tools #35968
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
TYP: annotate plotting._matplotlib.tools #35968
Conversation
@@ -340,15 +351,21 @@ def _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey): | |||
_remove_labels_from_axis(ax.yaxis) | |||
|
|||
|
|||
def _flatten(axes): | |||
def _flatten(axes: Union["Axes", Sequence["Axes"]]) -> Sequence["Axes"]: |
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.
return is 1d np.ndarray? axes can also be (np.ndarray, IndexClass)?
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.
Index.ravel returns an ndarray, so we always get ndarray here
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.
can you update return type
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.
to what?
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.
np.ndarray?
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.
If there were a way to indicate ndarray["Axes"]
I'd agree. until then, it is the "Axes" that is most relevant
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.
so mypy is green since np.ndarray resolves to Any, so Any is compatible with Sequence["Axes"].
I guess that we could add result = cast(Sequence["Axes"], result)
when numpy types are available.
…notate-plotting-tools
…notate-plotting-tools
Thanks @jbrockmendel |
Same idea as #35960, focused on clarifying Axis vs Axes