Thanks to visit codestin.com
Credit goes to github.com

Skip to content

In LogTransform, clip after log, not before. #9477

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
Oct 25, 2017

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Oct 19, 2017

In LogTransform, clip after log, not before.

When clipping before taking the log, the clip value in the output array
cannot be beyond log(epsilon) ~ -300. When clipping after taking the
log, the clip value can be much further (see comments regarding choice
of value).

This allows setting the default nonpos mode back to "clip".

Some test images had to be updated as this effectively moves the
position of the "clip point", slightly changing the slope of the line
that goes to that point and thus the rasterization (by a tiny amount).

I think this is a better fix than #9305.

PR Summary

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 anntzer force-pushed the clip-log-further branch 3 times, most recently from 33efc48 to 0f89c30 Compare October 20, 2017 01:53
When clipping before taking the log, the clip value in the output array
cannot be beyond log(epsilon) ~ -300.  When clipping after taking the
log, the clip value can be much further (see comments regarding choice
of value).

This allows setting the default nonpos mode back to "clip".

Some test images had to be updated as this effectively moves the
position of the "clip point", slightly changing the slope of the line
that goes to that point and thus the rasterization (by a tiny amount).
@tacaswell tacaswell added this to the v2.1.1 milestone Oct 21, 2017
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Oct 21, 2017
Set the default in `LogScale.__init__`, not in `Axes.set_{x,y}scale`
Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

Added some tests + doc changes.

@@ -1673,6 +1674,7 @@ def semilogy(self, *args, **kwargs):
self.cla()
d = {'basey': kwargs.pop('basey', 10),
'subsy': kwargs.pop('subsy', None),
'nonposy': kwargs.pop('nonposy', 'mask'),
Copy link
Member

Choose a reason for hiding this comment

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

Why mask here instead of 'clip' like semilogx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because typo. But actually both should be using "mask" mode if we want to keep backcompatibility (that's what we had before). Feel free to push either option (but it seems normal to return to the 2.0.1 behavior for now).

@tacaswell
Copy link
Member

I am in favor of putting this in for 2.1.1. It is an API change, but it is reverting an API change in 2.1.0 that was more disruptive than we expected. The change to errorbars is a very nice perk.

This will also fix #9149

raise ValueError(("provided too many kwargs, can only pass "
"{'basex', 'subsx', nonposx'} or "
"{'basey', 'subsy', nonposy'}. You passed ") +
"{!r}".format(kwargs))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just format the entire string? no need to add, also no need for !r as repr(dict) == format(dict, "")

Copy link
Member

Choose a reason for hiding this comment

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

If you try to format the whole string it blows up on a key error with "'basex', 'subsx', nonposx'".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"{" -> "{{".
If you think it's not an improvement, then at least replace "{!r}.format(...)" by repr(...), no? seems a bit perverse otherwise :)

@dopplershift
Copy link
Contributor

See #9288 and #9457 for relevant issues.

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

👍 on the change for 2.1.1 because it closes some very real, confusing behavior.

I'll let @tacaswell and @anntzer sort out the error message formatting. 😁

@anntzer
Copy link
Contributor Author

anntzer commented Oct 23, 2017

it's fine if you want to leave the error formatting as it is too... i'll just clean it some day.

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.

I'm happy with the API reversion.

@tacaswell tacaswell merged commit 7bd5d64 into matplotlib:master Oct 25, 2017
@anntzer anntzer deleted the clip-log-further branch October 25, 2017 18:17
dstansby added a commit that referenced this pull request Oct 26, 2017
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.

4 participants