From: W. Trevor King Date: Tue, 10 Aug 2010 12:33:32 +0000 (-0400) Subject: Allow None values for plot clicks or SI values X-Git-Url: http://git.tremily.us/?p=hooke.git;a=commitdiff_plain;h=15fd82f73ab0c89bba823d89eb042ad5a1fa0e3e Allow None values for plot clicks or SI values --- diff --git a/hooke/ui/gui/panel/plot.py b/hooke/ui/gui/panel/plot.py index 66cc64d..602ee65 100644 --- a/hooke/ui/gui/panel/plot.py +++ b/hooke/ui/gui/panel/plot.py @@ -189,6 +189,8 @@ class PlotPanel (Panel, wx.Panel): return d = self._config.get('plot decimals', 2) x,y = (event.xdata, event.ydata) + if None in [x, y]: + return xt = ppSI(value=x, unit=self._x_unit, decimals=d) yt = ppSI(value=y, unit=self._y_unit, decimals=d) point_indexes = [] diff --git a/hooke/util/si.py b/hooke/util/si.py index 48fe4e0..ac3e633 100644 --- a/hooke/util/si.py +++ b/hooke/util/si.py @@ -111,7 +111,7 @@ def ppSI(value, unit='', decimals=None, power=None, pad=False): """ if value == 0: return '0' - if isnan(value): + if value == None or isnan(value): return 'NaN' if power == None: # auto-detect power