-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify Axis.get_{major,minor}_ticks. #10303
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
Conversation
|
||
self._lastNumMajorTicks = numticks | ||
ticks = self.majorTicks[:numticks] | ||
while len(self.majorTicks) < numticks: |
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.
Did we decide that the _lastNumMajorTicks
logic wasn't needed? What did all that do and why can we remove it? Certainly your change is simpler, but it seems most of the un-simpleness in the old code was because of the _lastNumMajorTicks
logic.
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's private, unused anywhere else, and, to the best of my understanding, this implementation does the same thing...
It was introduced in 08610fc and never touched since.
Thinking again, the purpose of the whole mechanism seems to be to manage an numticks-length sublist of the currently used ticks. Is tick creation that expensive so that it's beneficial or necessary to keep them around for later use? The whole mechanism looks like a premature optimization to me. I also do not understand when So in short, the PR does not do exactly the same, but the current implementation is not completely reasonable anyway. It all comes down to if the properties can change later on. If they cannot, the PR is correct. |
Tick properties can be changed by |
Semi OT: Probably AFAIK |
Tick instantiation is costly enough that we're going through hoops to make that lazy... |
There (the lazy stuff), whole sets of ticks were created multiple times for each Axes instantiation. The code here just gives a benefit if the tick number is decreased and then increased again for the same axis. IMO this is rarely the case. Maybe in interactive plots. In which time is particularly critical, so you could still be right. |
I don't mind getting rid of it (assuming the speed cost is OK), but that's not the point of this PR, which, to the best of my knowledge, does exactly the same thing as before, just in fewer lines and in a less convoluted (IMO) fashion. |
Ok, back on topic: As discussed above, it does not do exactly the same: it does not call
|
The original version only called copy_tick_props to |
After some testing, I've come to the conclusion that this PR indeed works as one would expect and the original code just did some unnecessary work. |
One additional question, that does not necessarily have to be targeted in this PR: Would it make sense to restore the descriptors in We currently have two possible paths of initialization: The descriptor and Just wanted to bring this to attention. If the additional change is not reasonable or requires a lot of other changes, don't hold up this 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.
This works for me, and is indeed simpler.
@timhoffm reset_ticks does reset the descriptors. |
@anntzer Sorry, I've been looking at the code of another branch. You're right of course. |
@meeseeksdev backport v2.2 |
Something went wrong ... Please have a look at my logs. |
? There's no 2.2 branch. |
hummmsorry was not paying attention. |
PR Summary
Extracted from #9727 and its review.
PR Checklist