Repository: pyqtgraph/pyqtgraph

Issue:
Numpy FutureWarning when setting bins in ImageItem.getHistogram()
If I set the `bins` parameter of the `ImageItem.getHistogram()` method to a Numpy array, I get the following Future warning...

```
/Users/kenter/prog/py/pyqtgraph/pyqtgraph/graphicsItems/ImageItem.py:493: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if bins == 'auto':
```

The solution seems to me to replace `if bins == 'auto'` with `if bins is 'auto'`. 

I didn't make a pull request since it's only one line, but if you like I can make a PR. Just let me know.

I use Numpy 1.15.4 and PyQtGraph 0.10.


Discussion:
While `is` can work for string comparison it can't be relied upon (for example: https://stackoverflow.com/a/1504742/1639671)

I would just add an `isinstance(bins, str)` to avoid a numpy array getting compared to 'auto'. That or `not isinstance(bins, np.ndarray)`, but there are so many kinds of sequences (like pandas series) that might not enjoy being compared to a string, it makes more sense to just require it be a str or str subclass to use the auto option.
I thought that it could be relied on because Python maintains a collection of string constants. But I realize now that you can also get to the same result by constructing strings. Obvious in retrospect. Thanks.
@j9ac9k: again, sorry for not responding earlier but PR 921 doesn't remove the warning. Somehow the Numpy comparison is still used, even if the string is on the left hand side. Can we reopen the issue?

To reproduce the problem type the following on the IPython or Python command prompt.

```
In [1]: import numpy as np

In [2]: np.__version__
Out[2]: '1.15.4'

In [3]: bins = np.arange(5)

In [4]: "auto" == bins
/Users/kenter/miniconda3/bin/ipython:1: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  #!/Users/kenter/miniconda3/bin/python
Out[4]: False
```
I don't know what the most elegant fix is. Perhaps something like:

```
if type(bins) == str and bins == "auto":
    ....
```

This is cumbersome though.


Re-opened, thanks for following up
Thank you, I have no idea why I was sure to have it fixed and tested in that PR, when it obviously is not. I also have no idea what the design decision behind this for Python itself is (i.e. why `str.__eq__` is `NotImplemented`, when Python obviously has some type of string equality checking built in) - so I asked why this is and how to bypass it on stackoverflow: https://stackoverflow.com/questions/57549477/how-to-call-the-default-string-equality-function-in-python
Okay, the stackoverflow answer is very reasonable: `str.__eq__(np.ndarray)` is `NotImplemented`, while e.g. `str.__eq__(str)` is. Therefore probably the concept by @titusjan would be the one to use...
Agreed, though using isinstance() is preferable to explicitly checking the type. `if isinstance(bins, str) and bins == 'auto':`.

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py
--- a/pyqtgraph/graphicsItems/ImageItem.py
+++ b/pyqtgraph/graphicsItems/ImageItem.py
@@ -488,7 +488,7 @@ def getHistogram(self, bins='auto', step='auto', perChannel=False, targetImageSi
             step = (step, step)
         stepData = self.image[::step[0], ::step[1]]
 
-        if 'auto' == bins:
+        if isinstance(bins, str) and bins == 'auto':
             mn = np.nanmin(stepData)
             mx = np.nanmax(stepData)
             if mx == mn:


Test patch: