From 0f149f38c2707c0877c19c5be09349344cbd3379 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Sun, 14 Oct 2018 18:49:03 +0200 Subject: [PATCH] No warning for arrays with zeros in logscale NumPy evaluates log10(0) to -inf, so there is no reason to show the user a RuntimeWarning. Before, if visualizing data arrays containing zeros in logscale, a RuntimeWarning was shown. --- pyqtgraph/graphicsItems/PlotDataItem.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index 6797af64..d8a7aed5 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -514,11 +514,13 @@ class PlotDataItem(GraphicsObject): # Ignore the first bin for fft data if we have a logx scale if self.opts['logMode'][0]: x=x[1:] - y=y[1:] - if self.opts['logMode'][0]: - x = np.log10(x) - if self.opts['logMode'][1]: - y = np.log10(y) + y=y[1:] + + with np.errstate(divide='ignore'): + if self.opts['logMode'][0]: + x = np.log10(x) + if self.opts['logMode'][1]: + y = np.log10(y) ds = self.opts['downsample'] if not isinstance(ds, int):