title: ValueError: can only convert an array of size 1 to a Python scalar for Numpy Select
body: <p><code>newX</code> and <code>breaks</code> are numpy ndarray of shape (24000L,) and (7L,) respectively. newX is within range of (0,9). <code>yvals</code> is a lookup table based on breaks segmented into 10000 (nsegs) samples called <code>xvals</code>(not used here). </p>
  
  <pre><code>deltaX=(breaks[-1]-breaks[0])/nsegs
  xvals=[x+i*deltaX for i in range(nsegs+1)]
  </code></pre>
  
  <p>Both breaks and yvals are monotonically increasing. Basically, I want yvals[0] to be returned when newX value is less than the breaks[0], and yvals[-1] when newX value is higher than breaks[-1]. For other values I want it to generate an index for yvals corresponding to a point closest to xval (an example is shown below)
  When I do the following:</p>
  
  <pre><code>condlist=[newX&lt;=breaks[0] , newX &lt; breaks[-1] , newX &gt;= breaks[-1]]
  choicelist=[yvals[0] , yvals[((newX-breaks[0]))/deltax.astype(int).item()] , yvals[-1]]
  ans = np.select(condlist,choicelist)
  </code></pre>
  
  <p>I get the error in the choicelist line - </p>
  
  <blockquote>
    <p>ValueError: can only convert an array of size 1 to a Python scalar</p>
  </blockquote>
  
  <p>How can I fix this?</p>