X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=datamodel.py;fp=datamodel.py;h=2914fc37a8ba2d82a5bda4a98e37e29359bb1dfa;hb=5baa1f4bc3a1aa4d220be163fca98e79bd01cb2e;hp=5ad084cc1001d60667d44f243b9debeefa58a0c4;hpb=86862cb44ace09720744eee2e80ae50c174e903f;p=sigrok-meter.git diff --git a/datamodel.py b/datamodel.py index 5ad084c..2914fc3 100644 --- a/datamodel.py +++ b/datamodel.py @@ -20,6 +20,7 @@ import collections import itertools +import math import qtcompat import sigrok.core as sr import util @@ -65,9 +66,6 @@ class MeasurementDataModel(QtGui.QStandardItemModel): # idRole holds tuples, and using them to sort doesn't work. self.setSortRole(MeasurementDataModel.descRole) - # Used in 'format_value()' to check against. - self.inf = float('inf') - # A generator for the colors of the channels. self._colorgen = self._make_colorgen() @@ -103,7 +101,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel): return '' def format_value(self, mag): - if mag == self.inf: + if math.isinf(mag): return u'\u221E' return '{:f}'.format(mag) @@ -160,9 +158,10 @@ class MeasurementDataModel(QtGui.QStandardItemModel): # The samples role is a dictionary that contains the old samples for each unit. # Should be trimmed periodically, otherwise it grows larger and larger. - sample = (timestamp, value) - traces = item.data(MeasurementDataModel.tracesRole) - traces[unit].append(sample) + if not math.isinf(value) and not math.isnan(value): + sample = (timestamp, value) + traces = item.data(MeasurementDataModel.tracesRole) + traces[unit].append(sample) class MultimeterDelegate(QtGui.QStyledItemDelegate): '''Delegate to show the data items from a MeasurementDataModel.'''