Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Added __repr__ implementation on all locators and formators#25767
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
For unit testing because of the nature of the feature, any parameters that get added/ changed in anyway will be coupled to the test, can someone recommend some safe classes that I can use? |
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping@matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join uson gitter for real-time discussion.
For details on testing, writing docs, and our review process, please seethe developer guide
We strive to be a welcoming and open project. Please follow ourCode of Conduct.
I think an easy test is seeing if you can reproduce the locator and formatter examples (e.g.https://matplotlib.org/devdocs/gallery/ticks/tick-locators.html), but replace the titles with the reprs. |
This is modifying the reported runtime signature of all Formatters to have |
lib/matplotlib/ticker.py Outdated
tmin = ((vmin - t0) // minorstep + 1) * minorstep | ||
tmax = ((vmax - t0) // minorstep + 1) * minorstep | ||
locs = np.arange(tmin, tmax, minorstep) + t0 |
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.
This change seems unreleated, though I think it was included in a different recent PR
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.
Must have been an artifact when I set the branch up. I'll remove it
Yea I think I need to rebind the signature to my wrappers. Would doing something like.
work? |
That may work, but the more standard/complete way of doing it is to use |
Gotcha I'll give that a shot |
Seems like it fixed the wrapping issue, but now I have the problem where args is added to the signature when I think I'm creating an init method for classes that don't have one defined. Not sure exactly what's going on, because I still get the same issue when I don't add anything from this commit:d3aef45 |
I figured it out after my morning run today :) Basically checking for null doesn't account for the case when we inherit aninit method. My solution is I added a marker property and checked for it. I don't want to add it to the stubs though because it's only used for this. Is there a better / standard way of adding an arbitrary marker to the function? |
I think you'll want to be checking |
This is very nice technical work, however the Unfortunately I think the solution here is much less sophisticated and much more rote: write This does bring up the issue that there are attributes on these objects that influence how they render (and thus knowing the repr of two objects is the same is not enough to be sure that they are functionally the same), but I think that it is fair to say that is (well) out of scope. @Daniil-Aleshechkin I'm sorry we led you down this path and asked you to do a bunch of work that is not going to land in its current state 😞 |
story645 commentedMay 4, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@tacaswell, just a heads up that needing to be current state was discussed in the issue and@Daniil-Aleshechkin already prototyped something there#21898 (comment) |
e8f2a0a
to23d9ba9
CompareNot sure exactly what's going on but is the test agent in a bad state? Only the python 3.10 agent is throwing an exception: "Traceback (most recent call last):\n File "", line 1, in \n File "/Users/runner/work/1/s/lib/matplo...ion (%s) doesn't match libtk.a version (%s)"\nRuntimeError: tk.h version (8.5) doesn't match libtk.a version (8.6)\n" |
That's a known issue, but the other test failures are for the new tests here. |
Managed to fix those. Do we know how to fix this issue? |
That's up to Microsoft. |
@@ -287,6 +287,9 @@ class ThetaLocator(mticker.Locator): | |||
locations of every 45 degrees are returned. | |||
""" | |||
def __repr__(self): | |||
return f"{self.__class__.__name__}(base={self.base.__repr__()})" |
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.
These__repr__
should all be:
returnf"{self.__class__.__name__}(base={self.base.__repr__()})" | |
returnf"{self.__class__.__name__}(base={self.base!r})" |
ping@Daniil-Aleshechkin any bandwidth for continuing with this? |
Daniil-Aleshechkin commentedJun 27, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ah completely forgot about this. I stopped working on it cause I was blocked on that issue with the python 3.10 test runner. Did that get resolved? If so, I can resume working :) |
PR Summary
Added aninit_subclass implementation on the TickerHelper class that creates a wrapper over all the subclass'init methods. I'm assuming the following:
Thiscloses#21898
PR Checklist
Linked Issue
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst