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.
This commit is contained in:
2xB 2019-06-17 19:10:32 +02:00 committed by GitHub
parent 7b47337eaf
commit 4a592ef10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: