From 4a592ef10e9cad8fe469d3d5b8a29d9b0ad88a37 Mon Sep 17 00:00:00 2001 From: 2xB <31772910+2xB@users.noreply.github.com> Date: Mon, 17 Jun 2019 19:10:32 +0200 Subject: [PATCH] Prevent element-wise string comparison Issue #835 shows that comparing `bins`, which may be a numpy array, with a string `'auto'` leads to element-wise comparison, because the `==` operator for numpy arrays is used. With this commit, potential array and string are switched, so the `==` operator for strings is used, which does no element-wise comparison. --- pyqtgraph/graphicsItems/ImageItem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py index 65e87eec..1758bb4d 100644 --- a/pyqtgraph/graphicsItems/ImageItem.py +++ b/pyqtgraph/graphicsItems/ImageItem.py @@ -488,7 +488,7 @@ class ImageItem(GraphicsObject): step = (step, step) stepData = self.image[::step[0], ::step[1]] - if bins == 'auto': + if 'auto' == bins: mn = np.nanmin(stepData) mx = np.nanmax(stepData) if mx == mn: