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 177f560

Browse filesBrowse files
committed
FIX: LogLocator.set_params() was clobbering methods
1 parent 4e507ae commit 177f560
Copy full SHA for 177f560

File tree

Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-5
lines changed

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+8-5Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,11 +1757,13 @@ 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=None, numdecs=4, numticks=15):
17611761
"""
17621762
place ticks on the location= base**i*subs[j]
17631763
"""
17641764
self.base(base)
1765+
if subs is None:
1766+
subs = [1.0]
17651767
self.subs(subs)
17661768
# this needs to be validated > 1 with traitlets
17671769
self.numticks = numticks
@@ -1770,9 +1772,9 @@ def __init__(self, base=10.0, subs=[1.0], numdecs=4, numticks=15):
17701772
def set_params(self, base=None, subs=None, numdecs=None, numticks=None):
17711773
"""Set parameters within this locator."""
17721774
if base is not None:
1773-
self.base = base
1775+
self.base(base)
17741776
if subs is not None:
1775-
self.subs = subs
1777+
self.subs(subs)
17761778
if numdecs is not None:
17771779
self.numdecs = numdecs
17781780
if numticks is not None:
@@ -1782,7 +1784,7 @@ def base(self, base):
17821784
"""
17831785
set the base of the log scaling (major tick every base**i, i integer)
17841786
"""
1785-
self._base = base + 0.0
1787+
self._base = float(base)
17861788

17871789
def subs(self, subs):
17881790
"""
@@ -1791,7 +1793,7 @@ def subs(self, subs):
17911793
if subs is None:
17921794
self._subs = None # autosub
17931795
else:
1794-
self._subs = np.asarray(subs) + 0.0
1796+
self._subs = np.asarray(subs, dtype=float)
17951797

17961798
def __call__(self):
17971799
'Return the locations of the ticks'
@@ -1839,6 +1841,7 @@ def tick_values(self, vmin, vmax):
18391841
if not self.numticks > 1:
18401842
raise RuntimeError('The number of ticks must be greater than 1 '
18411843
'for LogLocator.')
1844+
# FIXME: The following was designed for integer division in py2.
18421845
while numdec / stride + 1 > self.numticks:
18431846
stride += 1
18441847

0 commit comments

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