Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80f5c8d

Browse filesBrowse files
authored
Merge pull request #7045 from efiring/LogLocator_set_params_bug
FIX: LogLocator.set_params() was clobbering methods
2 parents b9e0ece + 7c9acc0 commit 80f5c8d
Copy full SHA for 80f5c8d

File tree

Expand file treeCollapse file tree

2 files changed

+10
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-9
lines changed

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def test_LogLocator_set_params():
9494
Should not exception.
9595
"""
9696
loc = mticker.LogLocator()
97-
loc.set_params(numticks=8, numdecs=8, subs=[2.0], base=8)
98-
nose.tools.assert_equal(loc.numticks, 8)
97+
loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4)
98+
nose.tools.assert_equal(loc.numticks, 7)
9999
nose.tools.assert_equal(loc.numdecs, 8)
100-
nose.tools.assert_equal(loc.base, 8)
101-
nose.tools.assert_equal(loc.subs, [2.0])
100+
nose.tools.assert_equal(loc._base, 4)
101+
nose.tools.assert_equal(list(loc._subs), [2.0])
102102

103103

104104
def test_NullLocator_set_params():

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ class LogLocator(Locator):
17571757
Determine the tick locations for log axes
17581758
"""
17591759

1760-
def __init__(self, base=10.0, subs=[1.0], numdecs=4, numticks=15):
1760+
def __init__(self, base=10.0, subs=(1.0,), numdecs=4, numticks=15):
17611761
"""
17621762
place ticks on the location= base**i*subs[j]
17631763
"""
@@ -1770,9 +1770,9 @@ def __init__(self, base=10.0, subs=[1.0], numdecs=4, numticks=15):
17701770
def set_params(self, base=None, subs=None, numdecs=None, numticks=None):
17711771
"""Set parameters within this locator."""
17721772
if base is not None:
1773-
self.base = base
1773+
self.base(base)
17741774
if subs is not None:
1775-
self.subs = subs
1775+
self.subs(subs)
17761776
if numdecs is not None:
17771777
self.numdecs = numdecs
17781778
if numticks is not None:
@@ -1782,7 +1782,7 @@ def base(self, base):
17821782
"""
17831783
set the base of the log scaling (major tick every base**i, i integer)
17841784
"""
1785-
self._base = base + 0.0
1785+
self._base = float(base)
17861786

17871787
def subs(self, subs):
17881788
"""
@@ -1791,7 +1791,7 @@ def subs(self, subs):
17911791
if subs is None:
17921792
self._subs = None # autosub
17931793
else:
1794-
self._subs = np.asarray(subs) + 0.0
1794+
self._subs = np.asarray(subs, dtype=float)
17951795

17961796
def __call__(self):
17971797
'Return the locations of the ticks'
@@ -1839,6 +1839,7 @@ def tick_values(self, vmin, vmax):
18391839
if not self.numticks > 1:
18401840
raise RuntimeError('The number of ticks must be greater than 1 '
18411841
'for LogLocator.')
1842+
# FIXME: The following was designed for integer division in py2.
18421843
while numdec / stride + 1 > self.numticks:
18431844
stride += 1
18441845

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.