-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
dates.YearLocator doesn't handle inverted axes #3648
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
cc @cimarronm This looks like #3522 / #3524 |
It seems to me that ideally |
I'm comfortable with this change - it needs a test (which should not be a visible test)
That is maybe a nice to have, but is by no means necessary IMHO. Let's get this in, and then any refactoring can be done as a separate activity - the good news is that there will already be a test which exercises the desired behaviour 😉 |
I'm in agreement with @pelson. Let's get this in along with a test and we can look at possibly updating in a separate PR |
The revision needed is a test. |
I've noticed that there is another method of |
In the previous two commits I've moved the fix to the parent class, as described before. This also makes
|
This looks reasonable to me, but it still needs a test. |
I'm not sure I agree with the latest changes. It seems like you are breaking API by changing the return value of the data and view limits instead of returning what was set. I think your original method for handling it inside Note that the equivalent type of thing is done in axis e.g. |
Yes, I agree that it's an API change, but the question is whether anything will notice it. From what I can tell, there are three classes on the receiving end of this change:
That means all of them expect the correct ordering, and all of them have to check and swap the values they receive. So, from their point of view, the return values of |
punting to 1.4.x as this still needs work and has been silent for 2 months. I now agree with @cimarronm that we should not change the API, but can be convinced otherwise. If it does get changed this will need to documented in https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes and have docstrings added to the methods which make clear they are doing the order rectification. This still needs a test. |
The API in this case doesn't seem to have been clearly defined in the first place, since the existing Locators deal with the two possible orientations of axes differently (some do check for direction, some don't). The change I've proposed removes ambiguity and code duplication, which is IMHO an improvement. It also resolves the problem at the root instead of in the branches, which I would also consider the better way. And as far as I can say, there should be not breakage coming from that. As for a test, in a simple form it would have to look something like this:
But I don't know the low level API enough (or at all) to know how to e.g. instantiate an Axis and make it behave the way it would when it's a part of a chart. Also, I don't know your conventions for writing tests. So I'm sorry, but at the moment I don't have the spare energy to invest into learning these things and would rather leave this to somebody with more experience. |
@elpres This needs a rebase |
@tacaswell This was the first time I've ever done a git rebase (I use mercurial for my own projects, and never had to do any sort of modification of this complexity), and looking at the log above I likely messed something up. If I really did, I can open a new, clean pull request, as the patch itself is rather easy to re-create. |
Something has gone very wrong with this rebase, it should have 2 commits, not 200+ 😉 See #2742 for some docs on how to do this right (that PR was stalled on what to call the example remotes). |
Don't make a new PR, just force-push to this branch when you clean it up and gh will 'do the right thing' |
All other Locators are derived from RRuleLocator, which has the following check inside its `__call__` routine: try: dmin, dmax = self.viewlim_to_dt() except ValueError: return [] if dmin > dmax: dmax, dmin = dmin, dmax YearLocator just gets values for `dmin` and `dmax` in the same manner as above and goes on using them without checking for ordering and swapping if necessary. This leads to only one tick on axes using YearLocator.
Ok, this time it seems to have worked out properly (right?). Thank you for linking the rebase howto; it was very helpful. |
still doesn't have a unit test. Don't want to regress this feature in the future. |
FIX: dates.YearLocator doesn't handle inverted axes
Giving up on the unit tests for now. |
All other Locators are derived from RRuleLocator, which has the following check inside its
__call__
routine:YearLocator just gets values for
dmin
anddmax
in the same manner as above and goes on using them without checking for ordering and swapping if necessary. This leads to only one tick on inverted axes using YearLocator.