Skip to content

Small clean to SymmetricalLogLocator#14308

Merged
dstansby merged 4 commits intomatplotlib:masterfrom
dstansby:symlog-clean
May 31, 2019
Merged

Small clean to SymmetricalLogLocator#14308
dstansby merged 4 commits intomatplotlib:masterfrom
dstansby:symlog-clean

Conversation

@dstansby
Copy link
Copy Markdown
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
# "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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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