def __init__(self, stats, config, parent=None, *args): """ datain: a list where each item is a row """ QtCore.QAbstractTableModel.__init__(self, parent, *args) self.stats = stats self.dataLookup = { (QtCore.Qt.DisplayRole, 0): lambda row: str(roundToNDigits(self.stats[row].currentValue, 3)), (QtCore.Qt.DisplayRole, 1): lambda row: str( roundToStdDev(self.stats[row].mean, self.stats[row].stderr)), (QtCore.Qt.DisplayRole, 2): lambda row: str(roundToNDigits(self.stats[row].stderr, 2)), (QtCore.Qt.DisplayRole, 3): lambda row: self.names[row] if self.names and len(self.names) > row else None, (QtCore.Qt.FontRole, 0): lambda row: self.dataFont(row), (QtCore.Qt.FontRole, 1): lambda row: self.dataFont(row), (QtCore.Qt.FontRole, 2): lambda row: self.dataFont(row) #(QtCore.Qt.SizeHintRole,0): lambda row: } self.names = None self.config = config self.settings = config.get("AverageViewTableModel", Settings())
def onMouseMoved(self, pos): """Execute when mouse is moved. If mouse is over plot, show cursor coordinates on coordinateLabel.""" if self._graphicsView.sceneBoundingRect().contains(pos): if self.timeAxis: try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() y = self.mousePoint.y() if not logY else pow( 10, self.mousePoint.y()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1] - vR[1][0] if not logY else pow( 10, vR[1][1]) - pow( 10, vR[1][0]) #Calculate x and y display ranges precy = int(math.ceil(math.log10(abs(y / deltaY))) + 3) if y != 0 and deltaY > 0 else 1 roundedy = roundToNDigits(y, precy) try: currentDateTime = datetime.fromtimestamp( self.mousePoint.x()) self.coordinateLabel.setText( self.template.format(str(currentDateTime), repr(roundedy))) except OSError: pass # datetime concersion at mouse point failed except ValueError: pass else: try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() logX = self._graphicsView.ctrl.logXCheck.isChecked() y = self.mousePoint.y() if not logY else pow( 10, self.mousePoint.y()) x = self.mousePoint.x() if not logX else pow( 10, self.mousePoint.x()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1] - vR[1][0] if not logY else pow( 10, vR[1][1]) - pow( 10, vR[1][0]) #Calculate x and y display ranges deltaX = vR[0][1] - vR[0][0] if not logX else pow( 10, vR[0][1]) - pow(10, vR[0][0]) precx = int(math.ceil(math.log10(abs(x / deltaX))) + 3) if x != 0 and deltaX > 0 else 1 precy = int(math.ceil(math.log10(abs(y / deltaY))) + 3) if y != 0 and deltaY > 0 else 1 roundedx, roundedy = roundToNDigits(x, precx), roundToNDigits( y, precy) self.coordinateLabel.setText( self.template.format(repr(roundedx), repr(roundedy))) except numpy.linalg.linalg.LinAlgError: pass
def update(self): """"update the output """ self.countLabel.setText(str(self.stat.count)) mean, stderr = self.stat.mean, self.stat.stderr self.averageLabel.setText(str(roundToStdDev(mean, stderr))) self.stddevLabel.setText(str(roundToNDigits(stderr, 2)))
def update(self): """"update the output """ self.countLabel.setText( str(self.stat.count) ) mean, stderr = self.stat.mean, self.stat.stderr self.averageLabel.setText( str(roundToStdDev(mean, stderr)) ) self.stddevLabel.setText( str(roundToNDigits(stderr, 2)) )
def __init__(self, stats, config, parent=None, *args): """ datain: a list where each item is a row """ QtCore.QAbstractTableModel.__init__(self, parent, *args) self.stats = stats self.dataLookup = { (QtCore.Qt.DisplayRole, 0): lambda row: str(roundToNDigits(self.stats[row].currentValue, 3)), (QtCore.Qt.DisplayRole, 1): lambda row: str(roundToStdDev(self.stats[row].mean, self.stats[row].stderr)), (QtCore.Qt.DisplayRole, 2): lambda row: str(roundToNDigits(self.stats[row].stderr, 2)), (QtCore.Qt.DisplayRole, 3): lambda row: self.names[row] if self.names and len(self.names)>row else None, (QtCore.Qt.FontRole, 0): lambda row: self.dataFont(row), (QtCore.Qt.FontRole, 1): lambda row: self.dataFont(row), (QtCore.Qt.FontRole, 2): lambda row: self.dataFont(row) #(QtCore.Qt.SizeHintRole,0): lambda row: } self.names = None self.config = config self.settings = config.get("AverageViewTableModel", Settings())
def relConfidenceValue(self, row): if self.fitfunction.parametersConfidence and len( self.fitfunction.parametersConfidence ) > row and self.fitfunction.parameters[ row] and self.fitfunction.parametersConfidence[row]: return "{0}%".format( roundToNDigits( 100 * self.fitfunction.parametersConfidence[row] / abs(self.fitfunction.parameters[row]), 2)) return None
def onMouseMoved(self, pos): """Execute when mouse is moved. If mouse is over plot, show cursor coordinates on coordinateLabel.""" if self._graphicsView.sceneBoundingRect().contains(pos): if self.timeAxis: try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() y = self.mousePoint.y() if not logY else pow(10, self.mousePoint.y()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1]-vR[1][0] if not logY else pow(10, vR[1][1])-pow(10, vR[1][0]) #Calculate x and y display ranges precy = int( math.ceil( math.log10(abs(y/deltaY)) ) + 3 ) if y!=0 and deltaY>0 else 1 roundedy = roundToNDigits(y, precy ) try: currentDateTime = datetime.fromtimestamp(self.mousePoint.x()) self.coordinateLabel.setText( self.template.format( str(currentDateTime), repr(roundedy) )) except OSError: pass # datetime concersion at mouse point failed except ValueError: pass else: try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() logX = self._graphicsView.ctrl.logXCheck.isChecked() y = self.mousePoint.y() if not logY else pow(10, self.mousePoint.y()) x = self.mousePoint.x() if not logX else pow(10, self.mousePoint.x()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1]-vR[1][0] if not logY else pow(10, vR[1][1])-pow(10, vR[1][0]) #Calculate x and y display ranges deltaX = vR[0][1]-vR[0][0] if not logX else pow(10, vR[0][1])-pow(10, vR[0][0]) precx = int( math.ceil( math.log10(abs(x/deltaX)) ) + 3 ) if x!=0 and deltaX>0 else 1 precy = int( math.ceil( math.log10(abs(y/deltaY)) ) + 3 ) if y!=0 and deltaY>0 else 1 roundedx, roundedy = roundToNDigits( x, precx), roundToNDigits(y, precy ) self.coordinateLabel.setText( self.template.format( repr(roundedx), repr(roundedy) )) except numpy.linalg.linalg.LinAlgError: pass
def onMouseMoved(self, pos): """Execute when mouse is moved. If mouse is over plot, show cursor coordinates on coordinateLabel.""" if self._graphicsView.sceneBoundingRect().contains(pos): try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() y = self.mousePoint.y() if not logY else pow(10, self.mousePoint.y()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1]-vR[1][0] if not logY else pow(10, vR[1][1])-pow(10, vR[1][0]) #Calculate x and y display ranges precy = int( math.ceil( math.log10(abs(y/deltaY)) ) + 3 ) if y!=0 and deltaY>0 else 1 roundedy = roundToNDigits(y, precy ) currentDateTime = datetime.fromtimestamp(self.mousePoint.x()) self.coordinateLabel.setText( self.template.format( str(currentDateTime), repr(roundedy) )) except (ValueError, OSError): pass
def onMouseMoved(self, pos): """Execute when mouse is moved. If mouse is over plot, show cursor coordinates on coordinateLabel.""" if self._graphicsView.sceneBoundingRect().contains(pos): try: self.mousePoint = self._graphicsView.vb.mapSceneToView(pos) logY = self._graphicsView.ctrl.logYCheck.isChecked() y = self.mousePoint.y() if not logY else pow( 10, self.mousePoint.y()) vR = self._graphicsView.vb.viewRange() deltaY = vR[1][1] - vR[1][0] if not logY else pow( 10, vR[1][1]) - pow( 10, vR[1][0]) #Calculate x and y display ranges precy = int(math.ceil(math.log10(abs(y / deltaY))) + 3) if y != 0 and deltaY > 0 else 1 roundedy = roundToNDigits(y, precy) currentDateTime = datetime.fromtimestamp(self.mousePoint.x()) self.coordinateLabel.setText( self.template.format(str(currentDateTime), repr(roundedy))) except (ValueError, OSError): pass
def confidenceValue(self, row): if len(self.fitfunction.parametersConfidence ) > row and self.fitfunction.parametersConfidence[row]: return str( roundToNDigits(self.fitfunction.parametersConfidence[row], 2)) return None