-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python3.10: numpy update and explicit int() #207
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,25 +58,31 @@ def setBorders(self, start, end): | |
def setScale(self, scale): | ||
self.scale = scale | ||
|
||
@pyqtSlot(float, result=float) | ||
@pyqtSlot(float, result=int) | ||
def toScreen(self, x): | ||
if self.scale is fscales.Logarithmic: | ||
if self.coord_clipped_min == self.coord_clipped_max: | ||
return self.startBorder + 0. * x # keep x type (this can produce a RunTimeWarning if x contains inf) | ||
return int(self.startBorder + 0. * x) # keep x type (this can produce a RunTimeWarning if x contains inf) | ||
|
||
x = (x < 1e-20) * 1e-20 + (x >= 1e-20) * x | ||
return (np.log10(x / self.coord_clipped_min)) * (self.length - self.startBorder - self.endBorder) / self.coord_ratio_log + self.startBorder | ||
return int((np.log10(x / self.coord_clipped_min)) | ||
* (self.length - self.startBorder - self.endBorder) | ||
/ self.coord_ratio_log | ||
+ self.startBorder) | ||
else: | ||
if self.coord_max == self.coord_min: | ||
return self.startBorder + 0. * x # keep x type (this can produce a RunTimeWarning if x contains inf) | ||
return int(self.startBorder + 0. * x) # keep x type (this can produce a RunTimeWarning if x contains inf) | ||
|
||
trans_x = self.scale.transform(x) | ||
trans_min = self.scale.transform(self.coord_min) | ||
trans_max = self.scale.transform(self.coord_max) | ||
|
||
return (trans_x - trans_min) * (self.length - self.startBorder - self.endBorder) / (trans_max - trans_min) + self.startBorder | ||
return int((trans_x - trans_min) | ||
* (self.length - self.startBorder - self.endBorder) | ||
/ (trans_max - trans_min) | ||
+ self.startBorder) | ||
|
||
@pyqtSlot(float, result=float) | ||
@pyqtSlot(int, result=float) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I think this one is not correct. The coordinates on the plot area are usually floats, they do not round nicely to integers. |
||
def toPlot(self, x): | ||
if self.length == self.startBorder + self.endBorder: | ||
return self.coord_min + 0. * x # keep x type (this can produce a RunTimeWarning if x contains inf) | ||
|
@@ -88,4 +94,4 @@ def toPlot(self, x): | |
trans_max = self.scale.transform(self.coord_max) | ||
|
||
trans_x = (x - self.startBorder) * (trans_max - trans_min) / (self.length - self.startBorder - self.endBorder) + trans_min | ||
return self.scale.inverse(trans_x) | ||
return self.scale.inverse(trans_x) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,14 +53,14 @@ def include_dirs(self, dirs): | |
"sounddevice==0.4.2", | ||
"rtmixer==0.1.3", | ||
"docutils==0.17.1", | ||
"numpy==1.21.1", | ||
"numpy>=1.21.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we pin to the precise version that's needed ? In the future I might move to a different build tool that supports locking the whole dependency tree, but in the meantime I prefer to have pinned versions to avoid unexpected build failures when a package gets silently upgraded to a newer version. |
||
"PyQt5==5.15.4", | ||
"appdirs==1.4.4", | ||
"pyrr==0.10.3", | ||
] | ||
|
||
# Cython and numpy are needed when running setup.py, to build extensions | ||
setup_requires=["numpy==1.21.1", "Cython==0.29.24"] | ||
setup_requires=["numpy>=1.21.1", "Cython==0.29.24"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above, thanks ! |
||
|
||
with open(join(dirname(__file__), 'README.rst')) as f: | ||
long_description = f.read() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's possible, I think this method should keep returning floats. It might sound strange that screen coordinates would not be integers, but with display scaling this might not be that unusual