Skip to content

Fix InvertedLog10Transform.inverted() #10242

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 7 commits into from
Jan 29, 2018

Conversation

fkloosterman
Copy link
Contributor

PR Summary

Closes issue #10202

InvertedLog10Transform.inverted() method fails because position argument nonpos is missing. To fix this, a default value for the nonpos argument is added in constructor of LogTransformBase base class (and to be consistent, also to LogitTransform and LogisticTransform constructors). While testing it was noted that repr of Log/Logit/LogisticTransform objects results in max recursion error, because the Transform base class implements __repr__ with a call to str(self) and no __str__ methods are implemented for the Log/Logit/LogisticTransform classes. This was fixed as well.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer
Copy link
Contributor

anntzer commented Jan 13, 2018

Fixng a RecursionError seems release-critical...

@anntzer anntzer added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jan 13, 2018
@anntzer anntzer added this to the v2.2 milestone Jan 13, 2018
Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! We try to conform to the PEP8 coding guidelines to make our code neat, and it looks like there's a couple of exceptions: https://travis-ci.org/matplotlib/matplotlib/jobs/328459556#L2105

I think the things that need changing are:

  • Lines need to be 79 characters or shorter
  • There needs to be two blank lines between classes/methods that are at the lowest indent level

@@ -93,7 +93,7 @@ class LogTransformBase(Transform):
is_separable = True
has_inverse = True

def __init__(self, nonpos):
def __init__(self, nonpos='mask'):
Copy link
Member

Choose a reason for hiding this comment

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

This should probably default to 'clip' as this is the default else where.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, LogScale uses clip as default and so should LogTransform. Fixed in the PR.

@fkloosterman
Copy link
Contributor Author

@dstansby: I made the changes to conform to PEP8 and all checks pass now.

@dstansby dstansby dismissed their stale review January 21, 2018 19:23

Problems fixed

@@ -448,7 +455,7 @@ class LogitTransform(Transform):
is_separable = True
has_inverse = True

def __init__(self, nonpos):
def __init__(self, nonpos='mask'):
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs changing to 'clip' instead of 'mask'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For consistency, I used the same default for LogitTransform (and LogisticTransform) as for LogitScale, which already uses 'mask'.

Copy link
Member

Choose a reason for hiding this comment

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

👍

def test_logscale_transform_repr():
fig, ax = plt.subplots()
ax.set_yscale('log')
s = repr(ax.transData)
Copy link
Member

Choose a reason for hiding this comment

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

show we assert anything there?

Copy link
Member

Choose a reason for hiding this comment

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

ping @fkloosterman - can this test do more than just make sure it runs?

Copy link
Contributor Author

@fkloosterman fkloosterman Jan 25, 2018

Choose a reason for hiding this comment

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

you mean something like:
s = repr(matplotlib.scale.Log10Transform(nonpos='clip'))
assert s=="Log10Transform('clip')"

Copy link
Member

Choose a reason for hiding this comment

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

@fkloosterman yes something like that. Note, the pep8 checker will complain about the last line unless you put spaces around the == operator:
assert s == "Log10Transform('clip')"

def test_logscale_transform_repr():
fig, ax = plt.subplots()
ax.set_yscale('log')
s = repr(ax.transData)
Copy link
Member

Choose a reason for hiding this comment

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

@fkloosterman yes something like that. Note, the pep8 checker will complain about the last line unless you put spaces around the == operator:
assert s == "Log10Transform('clip')"

@jklymak
Copy link
Member

jklymak commented Jan 29, 2018

@phobson is this one OK by you now?

@phobson
Copy link
Member

phobson commented Jan 29, 2018

@jklymak Looks good to me. Travis failure seems unrelated, yeah?

@jklymak
Copy link
Member

jklymak commented Jan 29, 2018

Yeah, I think sometimes Travis has a minor problem with tex...

@jklymak jklymak merged commit b05becd into matplotlib:master Jan 29, 2018
@jklymak
Copy link
Member

jklymak commented Jan 29, 2018

Thanks a lot @fkloosterman!

@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants