Skip to content

API: treat xunits=None and yunits=None as "default" #17828

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 1 commit into from
Jul 5, 2020

Conversation

tacaswell
Copy link
Member

PR Summary

If the user passes None, treat as if they had passed nothing and do
not try to change the units on the respective axis.

closes #11095

I still need to write an API changes note (even though this is fixing a regression, it is a very old regression).

I don't think this conflicts with #17824 as the improved error message is a good idea independent of if this goes in.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • Documented in doc/api/next_api_changes/* if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the v3.4.0 milestone Jul 3, 2020

@pytest.mark.style('default')
@check_figures_equal(extensions=["png"])
def test_overliding_units(fig_test, fig_ref):
Copy link
Contributor

Choose a reason for hiding this comment

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

"overliding"?

Copy link
Member Author

Choose a reason for hiding this comment

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

l and r are next to each other on my keyboard. I wish I could blame all of my miss-spellings on poor typing as easily as this one...

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, dvorak? :)

Comment on lines +278 to +284
from datetime import datetime

t0 = datetime(2018, 3, 1)
t1 = datetime(2018, 3, 2)
t2 = datetime(2018, 3, 3)
t3 = datetime(2018, 3, 4)

Copy link
Member

Choose a reason for hiding this comment

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

what's the point of adding in the datetime here if that's not what's being tested?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a converter class that does not care about the value of Axis.units, but I think it is worth putting units on both Axis.

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to test using some data that does care about/use units? I'm wondering if datetime always has the units set to None all the time anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

The string catarogicals do use Axis.units to store critical state (which is what broke in #11095).

Copy link
Member

Choose a reason for hiding this comment

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

Oh woops, I missed that categoricals were being plotted too

Copy link
Member

Choose a reason for hiding this comment

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

@tacaswell so that's what concerns me, that you're putting two potential points of failure in this test - when it fails will it be easy to see that it was the categoricals that broke this?

Copy link
Member Author

Choose a reason for hiding this comment

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

All of our tests as pretty much closer to integration tests than unit tests. I am optimistic that if (when) this break who ever is debugging it will be able to sort out the root cause with out too much trouble.

@tacaswell tacaswell force-pushed the fix_none_units branch 2 times, most recently from 8649ad9 to f0851fc Compare July 3, 2020 16:56
@tacaswell tacaswell marked this pull request as ready for review July 3, 2020 16:56
Comment on lines +278 to +284
from datetime import datetime

t0 = datetime(2018, 3, 1)
t1 = datetime(2018, 3, 2)
t2 = datetime(2018, 3, 3)
t3 = datetime(2018, 3, 4)

Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to test using some data that does care about/use units? I'm wondering if datetime always has the units set to None all the time anyway.

Copy link
Member

@efiring efiring left a comment

Choose a reason for hiding this comment

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

Just typos; otherwise looks fine.

.. warning ::

This method may mutate the dictionary passed in an kwargs and
the Axes instances attached to this Axes.
Copy link
Member

Choose a reason for hiding this comment

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

"passed in an kwargs" -> "passed in as kwargs"
"the Axes instances" -> "the Axis instances"

If the user passes None, treat as if they had passed nothing and do
not try to change the units on the respective axis.

closes matplotlib#11095

Co-authored-by: David Stansby <dstansby@gmail.com>
@efiring efiring merged commit d266e71 into matplotlib:master Jul 5, 2020
@tacaswell tacaswell deleted the fix_none_units branch July 5, 2020 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repeated plot calls with xunits=None throws exception
5 participants