dynamic range limiting in PlotDataItem#1140
Conversation
|
Hi @NilsNemitz thanks for the PR! A quick question, is def setLimitDynamicRange(self, limit):
if self.opts['limitDynamicRange'] == limit:
return
self.opts['limitDynamicRange'] = limit
self.xDisp = self.yDisp = None
self.updateItems()If so, can you replace the Also, can you add a docstring on that method? Thanks for the PR! |
|
Hi @j9ac9k !
Extended testing code: |
|
my activity here is indeed feast or famine with nothing in between, I know that's totally not fair to contributors like yourself, and for that I apologize... just not sure what else I can do on a volunteer effort. Anyway, back to the PR! Looks like the CI system doesn't like your changes for the python2 builds: https://dev.azure.com/pyqtgraph/pyqtgraph/_build/results?buildId=647 |
|
Your work is very appreciated! I did not expect to get such a quick reply. |
| at any time. | ||
| dynamicRangeLimit (float or None) Limit off-screen positions of data points at large | ||
| magnification to avoids display errors. Disabled if None. | ||
| =============== ============================================================= |
There was a problem hiding this comment.
Looks like you need to indent this line over another 4 spaces (as well as the next couple of lines)
| limit (float or None) Maximum allowed vertical distance of plotted points in units of viewport height. | ||
| 'None' disables the check for a minimal increase in performance. Default is 1E+06. | ||
| """ | ||
| if self.opts['dynamicRangeLimit'] is limit: |
There was a problem hiding this comment.
should this be checking if None?
There was a problem hiding this comment.
maybe it should be if self.opts['dynamicRangeLimit'] is None or limit == self.opts['dynamicRangeLimit']?
| if data_range is not None: | ||
| view_height = view_range.height() | ||
| lim = self.opts['dynamicRangeLimit'] | ||
| # print('data:', data_range.height(), ' view:', view_height, ' limit:', lim ) |
There was a problem hiding this comment.
remove commented out print statements.
|
|
||
| def dataRect(self): | ||
| """ | ||
| Returns a bounding rectangle (as QRectF) for the full set of data |
There was a problem hiding this comment.
If this function can return None, that should be indicated in the docstring (as well as a description of why that might be the case)
|
Thanks for the update! Azure Pipelines isn't the most UI friendly interface, I think if you click on the "bash exited with code 1" it takes you to the portion... I made some inline comments, I could be off-base on some of them, if so, let me know. |
|
Thank you for the helpful comments @j9ac9k ! One additional change: I have moved the limiting code after downsampling (instead of before). Two observations: |
| return self._dataRect | ||
| if self.xData is None or self.yData is None: | ||
| return None | ||
| ymin = np.nanmin(self.yData) |
There was a problem hiding this comment.
we should catch the runtime warning being emitted here as we account for the nan case just below.
This can be done with the following code
import warnings
...
with warnings.catch_warnings():
warnings.simplefilter("ignore")
np.nanmin(self.yData)|
Hi @NilsNemitz sorry it's taken way too long for me to follow up. I changed the base of where this PR should be pointed at, resolved a merge conflict, and added one more comment... enough time has passed by I would understand if you don't want to implement that last suggestion, and I don't mind implementing it myself. Thanks again for this PR! |
|
Dear @j9ac9k , I tried my previous test cases; The changes still seem to fix the issue of disappearing plots. I tested with all-NaN x-data, y-data, and both. No problem was observed. I still got an "all-NaN" warning from the code in PlotCurveItem.py. Since there is only a single line with a np.nanmin / np.nanmax call, I suppressed the warning there, too. Now the code is silent for an all-NaN (curve) plot. I suspect that scatter plots will still throw a warning, but I did not want to touch more files than necessary for now. Let me know if you have more suggestions. Any idea why the "pre_build build_docs" test is failing? |
|
Hey @NilsNemitz thanks for following up; again apologize for the long time that elapsed. Regarding the docs the error message is this: I'm not that familiar w/ sphinx, but I can try and debug this for you as I have my local machine setup to build documentation and it's much easier to debug locally than on the CI level. I'll hop onto your branch, and see if I can figure out the necessary modification to the docstring to make sphinx happy. |
|
@j9ac9k: Let's see if this change fixes it, otherwise it would be great if you could have a look. Thank you for your time! |
|
LGTM, thanks for the PR @NilsNemitz merging! |
Workaround for issue #31
PlotCurveItem disappears with large ViewBox scale factor
(Code editor ate trailing whitespace, sorry.)
Test code: