-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix typo in Axes3D.set_autoscalez_on. #7859
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
wow… nice catch. |
+1 from me barring any issues raised by CI |
I am a bit concerned that this hasn't been noticed for so long. I would have expected an attribute error if this codepath was actually active |
Well… The correct attribute is used in the code, so I think this is more a case of code that doesn't crash but does not behave as expected. |
I'll skip the test myself, given the number of things that are untested in mplot3d anyways... :-) |
Yeah… I am not 100% convinced this is the right strategy :) |
The setter is one attribute, while the getter is a different attribute, so I would expect an attribute error |
ah, set_zlim3d() is setting the other attribute directly instead of using the setter, so that's how the attribute error is getting avoided |
failures are unrelated (one of them was a failure for |
Should we start backporting? |
Yes 👍 to backporting. |
@NelleV Now can I get a coffee instead? |
eh... something unrelatedly wrong happened to the tests?
|
I think your test needs a cleanup decorator otherwise that figure will leak into other tests. |
b58614d
to
f050673
Compare
Now everyone knows I don't know how to write a test... |
Current coverage is 62.16% (diff: 86.36%)@@ master #7859 diff @@
==========================================
Files 174 174
Lines 56072 56072
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 34833 34857 +24
+ Misses 21239 21215 -24
Partials 0 0
|
mx, my = args | ||
elif len(args) == 3: | ||
mx, my, mz = args | ||
else: | ||
raise ValueError("more than three arguments were supplied") | ||
raise TypeError( | ||
"Axes3D.margins takes at most three positional arguments") |
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 raised a ValueError here originally because that what the 2d Axes.margins() does when given more than two arguments.
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.
May or may not be a gratuitious backwards compatible change but arguments mismatching the signature normally raise a TypeError. Should we change it in Axes.margins too? (hem hem)
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.
along the same line of thinking, wouldn't the 2d version of this function suffer the same problem that you are trying to fix here with an empty args list?
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.
Nope. Haven't checked the impl. but it must have been fixed at some point.
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.
just took a look, it seems like the 2d version doesn't have this else-clause, so it silently allows more arguments than expected.
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.
Open a separate issue? :)
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.
grrr, misread the code... it doesn't have an else clause... it has a "len(args) > 2" clause that then raises the ValueError, but also skips the case of no positional args. We are fine, then.
As for ValueError vs. TypeError, I really don't have a preference except that the 2d and 3d version be the same.
scaley = self._autoscaleYon | ||
self._autoscaleYon = scaley = bool(enable) | ||
else: | ||
scaly = False |
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.
typo, plus, the else-clause isn't needed as the scale{x,y,z} variables are already initialized to False
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.
Forgot to remove the initialization. Fixed now; I think this is more readable.
@@ -469,6 +469,19 @@ def test_lines_dists(): | |||
ax.set_ylim(0, 300) | |||
|
|||
|
|||
|
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.
too many whitespace lines
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.
fixed.
f050673
to
a437517
Compare
@anntzer You've earned your coffee. Let me know when and where you want it :) |
This will need a rebase due to the pytest migration. Plus, the remaining sticking point about the exception raised hasn't been resolved. I honestly don't care which one we raise, but they should be the same for both 2D and 3D. We could make a change for it to be in a separate PR, as it really is out of scope here. |
@anntzer Do you mind rebasing and (/or) fixing @WeatherGod 's very minor one-line of change comment? |
(See surrounding code to confirm that the correct attribute name is indeed `_autoscaleZon`.)
a437517
to
effe642
Compare
Rebased and made it a ValueError instead as per @WeatherGod's suggestion. Will open a separate issue for that. |
Thanks @anntzer |
Needs backport? |
I wouldn't bother, the code has been broken basically forever without anyone noticing (channeling @NelleV here :p). |
I wouldn't bother either. |
Please update the milestone if you don't plan on backporting things. |
(See surrounding code to confirm that the correct attribute name is
indeed
_autoscaleZon
.)Split out of #5538.