-
-
Notifications
You must be signed in to change notification settings - Fork 8k
DOC: document fmt_xdata, fmt_ydata, and fmt_zdata #25187
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
base: main
Are you sure you want to change the base?
Conversation
Makes sense to add the same to matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py Lines 161 to 162 in 91d8f2e
? This may just as well go in 3.7? (I guess it would if there was a 3.7-doc? Edit: no, not in 3.7-doc as it also changes the lib-files, but still...) |
Do we want to get this in prior 3.7.1, which we are looking to tag today? |
0b7d532
to
8874cb0
Compare
8874cb0
to
30d8d3b
Compare
Just thought that I'd highlight #17286 as it is sort of related to this. At least the suggestion to rename this attribute and/or have setters/getters for it. Doesn't have to be a show stopper for this PR though. |
If I’m not mistaken, this is the answer to https://discourse.matplotlib.org/t/toolbar-parameters-in-show/25908/2 |
This can't get pulled back to the doc branch (it touches library code). |
I'm a bit torn how to do this properly. The fundamental issue is that attributes are a dynamic concept and it's hard to attach meta information to them. Actually I don't like either approach: Class level type annotations are a bit awkward because we have otherwise pushed all typing to the stubs. OTOH I also don't like to create class attributes for documentation when we actually have instance attributes. If I have to choose between those, I'd go for the type annotations, but YMMV. |
If we have two other instances of using the typing style and @timhoffm prefers it, go with that method! |
Oh it seems it doesn't work for 3D. Is that because we have not typed the module more generally? |
Co-authored-by: Elliott Sales de Andrade <[email protected]>
a07ca82
to
debd606
Compare
Doc build failure due to
But I don't really understand why this is the case. |
Well, the warning seems right, because it doesn't seem like it's there: https://output.circle-artifacts.com/output/job/1e67683f-805a-4e9c-aa1c-f54e82d0df21/artifacts/0/doc/build/html/api/toolkits/mplot3d/axes3d.html#interactive |
@@ -57,6 +58,15 @@ class Axes3D(Axes): | |||
Axes._shared_axes["z"] = cbook.Grouper() | |||
Axes._shared_axes["view"] = cbook.Grouper() | |||
|
|||
fmt_zdata: Callable[[float], str] | 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.
Setting this to something seems to fix it, though again, not sure why it doesn't seem necessary on the others.
fmt_zdata: Callable[[float], str] | None | |
fmt_zdata: Callable[[float], str] | 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 just had an idea... Neither of these exist as attributes on the class:
>>> from matplotlib.axes import Axes
>>> Axes.fmt_xdata
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
Axes.fmt_xdata
AttributeError: type object 'Axes' has no attribute 'fmt_xdata'. Did you mean: 'format_xdata'?
>>> from mpl_toolkits.mplot3d.axes3d import Axes3D
>>> Axes3D.fmt_zdata
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
Axes3D.fmt_zdata
AttributeError: type object 'Axes3D' has no attribute 'fmt_zdata'. Did you mean: 'format_zdata'?
and yet the former works.
But the difference between 2D and 3D Axes is the former has type stubs and the latter doesn't. Unfortunately, removing fmt_xdata
/fmt_ydata
from the _base.pyi
type stub did not break the docs. So I still don't know why it doesn't work.
PR Summary
Closes #9593
This documents the exact call chain so we can leave the monkey patching route implicit ;)