More int float issues fixed.

pull/544/head
Holger Müller 2022-09-13 18:46:02 +02:00
rodzic 05f7b9bbf0
commit 2f69f5c154
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 2FDB49E81EAE6622
3 zmienionych plików z 25 dodań i 19 usunięć

Wyświetl plik

@ -46,15 +46,15 @@ class PermeabilityChart(FrequencyChart):
self.minDisplayValue = -100
def logarithmicYAllowed(self) -> bool:
return True;
return True
def copy(self):
new_chart: PermeabilityChart = super().copy()
return new_chart
return super().copy()
def drawChart(self, qp: QtGui.QPainter):
qp.setPen(QtGui.QPen(Chart.color.text))
qp.drawText(self.leftMargin + 5, 15, self.name + " (\N{MICRO SIGN}\N{OHM SIGN} / Hz)")
qp.drawText(self.leftMargin + 5, 15, self.name +
" (\N{MICRO SIGN}\N{OHM SIGN} / Hz)")
qp.drawText(10, 15, "R")
qp.drawText(self.leftMargin + self.dim.width + 10, 15, "X")
qp.setPen(QtGui.QPen(Chart.color.foreground))
@ -281,11 +281,11 @@ class PermeabilityChart(FrequencyChart):
span = math.log(self.max) - math.log(min_val)
else:
return -1
return self.topMargin + round(
(math.log(self.max) - math.log(im)) /
return int(
self.topMargin + (math.log(self.max) - math.log(im)) /
span * self.dim.height)
return self.topMargin + round(
(self.max - im) / self.span * self.dim.height)
return int(self.topMargin + (self.max - im) /
self.span * self.dim.height)
def getReYPosition(self, d: Datapoint) -> int:
re = d.impedance().real
@ -296,11 +296,11 @@ class PermeabilityChart(FrequencyChart):
span = math.log(self.max) - math.log(min_val)
else:
return -1
return self.topMargin + round(
(math.log(self.max) - math.log(re)) /
return int(
self.topMargin + (math.log(self.max) - math.log(re)) /
span * self.dim.height)
return self.topMargin + round(
(self.max - re) / self.span * self.dim.height)
return int(
self.topMargin + (self.max - re) / self.span * self.dim.height)
def valueAtPosition(self, y) -> List[float]:
absy = y - self.topMargin

Wyświetl plik

@ -368,13 +368,13 @@ class RealImaginaryChart(FrequencyChart):
def getImYPosition(self, d: Datapoint) -> int:
im = self.impedance(d).imag
return (self.topMargin + int(self.max_imag - im) // self.span_imag
* self.dim.height)
return int(self.topMargin + (self.max_imag - im) / self.span_imag
* self.dim.height)
def getReYPosition(self, d: Datapoint) -> int:
re = self.impedance(d).real
return (self.topMargin + int(self.max_real - re) // self.span_real
* self.dim.height if math.isfinite(re) else self.topMargin)
return int(self.topMargin + (self.max_real - re) / self.span_real
* self.dim.height if math.isfinite(re) else self.topMargin)
def valueAtPosition(self, y) -> List[float]:
absy = y - self.topMargin

Wyświetl plik

@ -107,13 +107,19 @@ class SParameterChart(FrequencyChart):
self.drawMarkers(qp, y_function=self.getImYPosition)
def getYPosition(self, d: Datapoint) -> int:
return self.topMargin + (self.maxValue - d.re) // self.span * self.dim.height
return int(
self.topMargin + (self.maxValue - d.re) / self.span *
self.dim.height)
def getReYPosition(self, d: Datapoint) -> int:
return self.topMargin + (self.maxValue - d.re) // self.span * self.dim.height
return int(
self.topMargin + (self.maxValue - d.re) / self.span *
self.dim.height)
def getImYPosition(self, d: Datapoint) -> int:
return self.topMargin + (self.maxValue - d.im) // self.span * self.dim.height
return int(
self.topMargin + (self.maxValue - d.im) / self.span *
self.dim.height)
def valueAtPosition(self, y) -> List[float]:
absy = y - self.topMargin