Skip to content

Small clean to SymmetricalLogLocator #14308

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 4 commits into from
May 31, 2019
Merged

Conversation

dstansby
Copy link
Member

  • Replace variable names b, t with base, linthresh
  • Add some more inline comments
  • Instead of doing -vmin, -vmax, use np.abs(), as the intent is to make sure the value passed to get_log_range() is positive.

@dstansby dstansby added this to the v3.2.0 milestone May 27, 2019
@@ -2468,22 +2468,23 @@ def tick_values(self, vmin, vmax):
# "simple" mode is when the range falls entirely within (-t,
# t) -- it should just display (vmin, 0, vmax)

# Determine which of the three ranges we have
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the whole thing can be simplified to

if -linthresh <= vmin <= vmax <= 0 or 0 <= vmin <= vmax <= linthresh:
    return [vmin, vmax]
has_a = (vmin < -linthresh)
has_b = (-linthresh < vmin < linthresh or -linthresh < vmax < linthresh)
has_c = (linthresh < vmax)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think SymLogNorm needs quite a few more tests, which I plan to add in for 3.2 at some point; I think this is a good suggestion, but might save it for after I've written tests that exercise this logic properly.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure

if has_a:
if has_b:
a_range = get_log_range(t, -vmin + 1)
a_range = get_log_range(linthresh, np.abs(vmin) + 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

can use (builtin) abs() instead of np.abs()

@dstansby
Copy link
Member Author

Going to merge, since this has two approvals.

@dstansby dstansby merged commit fdc7a8c into matplotlib:master May 31, 2019
@dstansby dstansby deleted the symlog-clean branch May 31, 2019 12:22
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.

4 participants