title: numpy.where produces inconsistent results
body: <p>I have a piece of code where I need to look for an index of a value in a numpy array.
  For this task, I use numpy.where.
  The problem is that numpy.where produces a wrong result, i.e. returns an empty array, in situations where I am certain that the searched value is in the array.
  To make things worse, I tested that the element is really in the array with a for loop, and in case it is found, also look for it with numpy.where.
  Oddly enough, then it finds a result, while literally a line later, it doesnt.</p>
  
  <p>Here is how the code looks like:</p>
  
  <pre><code># progenitors, descendants and progenitor_outputnrs are 2D-arrays that are filled from reading in files.
  # outputnrs is a 1d-array.
  
  ozi = 0
  for i in range(descendants[ozi].shape[0]):
      if descendants[ozi][i] &gt; 0:
  
          if progenitors[ozi][i] &lt; 0:
              oind = outputnrs[0] - progenitor_outputnrs[ozi][i] - 1
              print "looking for prog", progenitors[ozi][i], "with outputnr", progenitor_outputnrs[ozi][i], "in", outputnrs[oind]
  
              for p in progenitors[oind]:
                  if p == -progenitors[ozi][i]:
  # the following line works...
                      print "found", p, np.where(progenitors[oind]==-progenitors[ozi][i])[0][0]
  # the following line doesn't!
              iind = np.where(progenitors[oind]==-progenitors[ozi][i])[0][0]
  </code></pre>
  
  <p>I get the output:</p>
  
  <pre><code>looking for prog -76 with outputnr 65 in 66
  found 76 79
  looking for prog -2781 with outputnr 65 in 66
  found 2781 161
  looking for prog -3797 with outputnr 63 in 64
  found 3797 163
  looking for prog -3046 with outputnr 65 in 66
  found 3046 163
  looking for prog -6488 with outputnr 65 in 66
  found 6488 306
  Traceback (most recent call last):
    File "script.py", line 1243, in &lt;module&gt;
      main()
    File "script.py", line 974, in main
      iind = np.where(progenitors[oind]==-progenitors[out][i])[0][0]
  IndexError: index 0 is out of bounds for axis 0 with size 0
  </code></pre>
  
  <p>I use python 2.7.12 and numpy 1.14.2.</p>
  
  <p>Does anyone have an idea why this is happening?</p>