Skip to content

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

Merged
merged 3 commits into from
Jan 28, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jan 17, 2017

(See surrounding code to confirm that the correct attribute name is
indeed _autoscaleZon.)

Split out of #5538.

@NelleV
Copy link
Member

NelleV commented Jan 17, 2017

wow… nice catch.
Is it possible to add a test for this one?

@WeatherGod
Copy link
Member

+1 from me barring any issues raised by CI

@WeatherGod
Copy link
Member

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

@NelleV
Copy link
Member

NelleV commented Jan 17, 2017

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.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 17, 2017

I'll skip the test myself, given the number of things that are untested in mplot3d anyways... :-)

@NelleV
Copy link
Member

NelleV commented Jan 17, 2017

Yeah… I am not 100% convinced this is the right strategy :)

@WeatherGod
Copy link
Member

The setter is one attribute, while the getter is a different attribute, so I would expect an attribute error

@WeatherGod
Copy link
Member

ah, set_zlim3d() is setting the other attribute directly instead of using the setter, so that's how the attribute error is getting avoided

@WeatherGod
Copy link
Member

failures are unrelated (one of them was a failure for git clean to remove result_images/index.html for some reason?)

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0.1 (next bug fix release) Jan 17, 2017
@tacaswell tacaswell changed the title Fix typo in Axes3D.set_autoscalez_on. [MRG+1] Fix typo in Axes3D.set_autoscalez_on. Jan 17, 2017
@NelleV
Copy link
Member

NelleV commented Jan 18, 2017

Should we start backporting?

@tacaswell
Copy link
Member

Yes 👍 to backporting.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 18, 2017

@NelleV Now can I get a coffee instead?
(I did catch another bug -- Axes3D.margins would error if passed three keyword arguments...)

@anntzer
Copy link
Contributor Author

anntzer commented Jan 18, 2017

eh... something unrelatedly wrong happened to the tests?

======================================================================
ERROR: test suite for <function test_divider_append_axes at 0x7fffe8d450c8>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/plugins/multiprocess.py", line 788, in run
    self.setUp()
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/suite.py", line 292, in setUp
    self.setupContext(ancestor)
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/plugins/multiprocess.py", line 770, in setupContext
    super(NoSharedFixtureContextSuite, self).setupContext(context)
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/suite.py", line 315, in setupContext
    try_run(context, names)
  File "/home/travis/build/matplotlib/matplotlib/venv/lib/python2.7/site-packages/nose/util.py", line 490, in try_run
    return func()
  File "/home/travis/build/matplotlib/matplotlib/lib/matplotlib/testing/decorators.py", line 268, in setup
    ' (`%s`)' % getattr(func, '__qualname__', func.__name__))
AssertionError: Figures and baseline_images count are not the same (`test_divider_append_axes`)

@jenshnielsen
Copy link
Member

I think your test needs a cleanup decorator otherwise that figure will leak into other tests.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 18, 2017

Now everyone knows I don't know how to write a test...

@codecov-io
Copy link

codecov-io commented Jan 18, 2017

Current coverage is 62.16% (diff: 86.36%)

Merging #7859 into master will increase coverage by 0.04%

@@             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          

Powered by Codecov. Last update 2374c9b...a437517

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")
Copy link
Member

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.

Copy link
Contributor Author

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)

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open a separate issue? :)

Copy link
Member

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
Copy link
Member

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

Copy link
Contributor Author

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)



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many whitespace lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@NelleV
Copy link
Member

NelleV commented Jan 18, 2017

@anntzer You've earned your coffee. Let me know when and where you want it :)

@WeatherGod
Copy link
Member

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.

@NelleV
Copy link
Member

NelleV commented Jan 27, 2017

@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`.)
@anntzer
Copy link
Contributor Author

anntzer commented Jan 27, 2017

Rebased and made it a ValueError instead as per @WeatherGod's suggestion. Will open a separate issue for that.

@NelleV NelleV merged commit ec8cf08 into matplotlib:master Jan 28, 2017
@NelleV
Copy link
Member

NelleV commented Jan 28, 2017

Thanks @anntzer

@anntzer anntzer deleted the set_autoscalez_on branch January 28, 2017 19:25
@QuLogic QuLogic changed the title [MRG+1] Fix typo in Axes3D.set_autoscalez_on. Fix typo in Axes3D.set_autoscalez_on. Jan 28, 2017
@QuLogic
Copy link
Member

QuLogic commented Jan 28, 2017

Needs backport?

@anntzer
Copy link
Contributor Author

anntzer commented Jan 29, 2017

I wouldn't bother, the code has been broken basically forever without anyone noticing (channeling @NelleV here :p).

@NelleV
Copy link
Member

NelleV commented Jan 29, 2017

I wouldn't bother either.

@QuLogic
Copy link
Member

QuLogic commented Jan 29, 2017

Please update the milestone if you don't plan on backporting things.

@QuLogic QuLogic modified the milestones: 2.1 (next point release), 2.0.1 (next bug fix release) Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants