8000 fixed a bug in ticker.py that was causing a ZeroDivisionError · matplotlib/matplotlib@b9e6cba · GitHub
[go: up one dir, main page]

Skip to content

Commit b9e6cba

Browse files
committed
fixed a bug in ticker.py that was causing a ZeroDivisionError
svn path=/trunk/matplotlib/; revision=1413
1 parent ce75bbb commit b9e6cba

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-06-03 Fixed a bug in ticker.py causing a ZeroDivisionError
4+
35
2005-06-02 backend_gtk.py remove DBL_BUFFER, add line to expose_event to
46
try to fix pygtk 2.6 redraw problem - SC
57

lib/matplotlib/ticker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class Formatter(TickHelper):
143143

144144
# some classes want to see all the locs to help format
145145
# individual ones
146-
locs = None
146+
locs = []
147147
def __call__(self, x, pos=0):
148148
'Return the format for tick val x at position pos'
149149
raise NotImplementedError('Derived must overide')
@@ -201,7 +201,7 @@ def __call__(self, x, pos=0):
201201
return self.fmt % x
202202

203203

204-
class _ScalarFormatter(Formatter):
204+
class OldScalarFormatter(Formatter):
205205
"""
206206
Tick location is a plain old number. If viewInterval is set, the
207207
formatter will use %d, %1.#f or %1.ef as appropriate. If it is
@@ -260,7 +260,7 @@ def __init__(self, useOffset=True, useMathText=False):
260260

261261
def __call__(self, x, pos=0):
262262
'Return the format for tick val x at position pos'
263-
if self.locs==None:
263+
if len(self.locs)==0:
264264
return ''
265265
else:
266266
return self.pprint_val(x)
@@ -272,7 +272,7 @@ def format_data(self,value):
272272

273273
def get_offset(self):
274274
"""Return scientific notation, plus offset"""
275-
if self.locs==None: return ''
275+
if len(self.locs)==0: return ''
276276
if self.orderOfMagnitude or self.offset:
277277
offsetStr = ''
278278
sciNotStr = ''
@@ -289,7 +289,7 @@ def get_offset(self):
289289
def set_locs(self, locs):
290290
'set the locations of the ticks'
291291
self.locs = locs
292-
if self.locs != None:
292+
if len(self.locs) > 0:
293293
self.verify_intervals()
294294
d = abs(self.viewInterval.span())
295295
if self._useOffset: self._set_offset(d)

0 commit comments

Comments
 (0)
0