diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index dfd8f429bb2c..aaf73fd5ed47 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -94,11 +94,11 @@ def test_LogLocator_set_params(): Should not exception. """ loc = mticker.LogLocator() - loc.set_params(numticks=8, numdecs=8, subs=[2.0], base=8) - nose.tools.assert_equal(loc.numticks, 8) + loc.set_params(numticks=7, numdecs=8, subs=[2.0], base=4) + nose.tools.assert_equal(loc.numticks, 7) nose.tools.assert_equal(loc.numdecs, 8) - nose.tools.assert_equal(loc.base, 8) - nose.tools.assert_equal(loc.subs, [2.0]) + nose.tools.assert_equal(loc._base, 4) + nose.tools.assert_equal(list(loc._subs), [2.0]) def test_NullLocator_set_params(): diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 4aff074e5503..02109e8bd991 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -1757,7 +1757,7 @@ 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=(1.0,), numdecs=4, numticks=15): """ place ticks on the location= base**i*subs[j] """ @@ -1770,9 +1770,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: @@ -1782,7 +1782,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): """ @@ -1791,7 +1791,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' @@ -1839,6 +1839,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