Skip to content

FIX: LogLocator.set_params() was clobbering methods #7045

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 2 commits into from
Sep 11, 2016
Merged
Changes from 1 commit
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
Next Next commit
FIX: LogLocator.set_params() was clobbering methods
  • Loading branch information
efiring committed Sep 10, 2016
commit 177f56040a4d75c67f0bb4413e9d7c614e64c589
13 changes: 8 additions & 5 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,11 +1757,13 @@ class LogLocator(Locator):
Determine the tick locations for log axes
"""

def __init__(self, base=10.0, subs=[1.0], numdecs=4, numticks=15):
def __init__(self, base=10.0, subs=None, numdecs=4, numticks=15):
"""
place ticks on the location= base**i*subs[j]
"""
self.base(base)
if subs is None:
subs = [1.0]
self.subs(subs)
# this needs to be validated > 1 with traitlets
self.numticks = numticks
Expand All @@ -1770,9 +1772,9 @@ def __init__(self, base=10.0, subs=[1.0], numdecs=4, numticks=15):
def set_params(self, base=None, subs=None, numdecs=None, numticks=None):
"""Set parameters within this locator."""
if base is not None:
self.base = base
self.base(base)
if subs is not None:
self.subs = subs
self.subs(subs)
if numdecs is not None:
self.numdecs = numdecs
if numticks is not None:
Expand All @@ -1782,7 +1784,7 @@ def base(self, base):
"""
set the base of the log scaling (major tick every base**i, i integer)
"""
self._base = base + 0.0
self._base = float(base)

def subs(self, subs):
"""
Expand All @@ -1791,7 +1793,7 @@ def subs(self, subs):
if subs is None:
self._subs = None # autosub
else:
self._subs = np.asarray(subs) + 0.0
self._subs = np.asarray(subs, dtype=float)

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

Expand Down