8000 BUG: Fix typo in view_limits() for MultipleLocator by dopplershift · Pull Request #12313 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix typo in view_limits() for MultipleLocator #12313

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
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ def test_basic(self):
9.441, 12.588])
assert_almost_equal(loc.tick_values(-7, 10), test_value)

def test_view_limits(self):
"""
Test basic behavior of view limits.
"""
with matplotlib.rc_context({'axes.autolimit_mode': 'data'}):
loc = mticker.MultipleLocator(base=3.147)
assert_almost_equal(loc.view_limits(-5, 5), (-5, 5))

def test_view_limits_round_numbers(self):
"""
Test that everything works properly with 'round_numbers' for auto
limit.
"""
with matplotlib.rc_context({'axes.autolimit_mode': 'round_numbers'}):
loc = mticker.MultipleLocator(base=3.147)
assert_almost_equal(loc.view_limits(-4, 4), (-6.294, 6.294))

def test_set_params(self):
"""
Create multiple locator with 0.7 base, and change it to something else.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ def view_limits(self, dmin, dmax):
"""
if rcParams['axes.autolimit_mode'] == 'round_numbers':
vmin = self._edge.le(dmin) * self._edge.step
vmax = self._base.ge(dmax) * self._edge.step
vmax = self._edge.ge(dmax) * self._edge.step
if vmin == vmax:
vmin -= 1
vmax += 1
Expand Down
0