title: How to resolve "only integer scalar arrays can be converted to a scalar index"
body: <p>I get a weird error with following codes:</p>
  
  <pre><code>import numpy as np
  w=np.random.rand(100,10)
  x=np.random.rand(200,100)
  y= np.random.rand(200,10)
  
  def compute( x, y):
      numpy_x = np.array(x) 
      numpy_y = np.array(y)
  
      zeross = np.zeros(np.shape(x)[0])
      oness = np.ones(np.shape(x)[0])
  
      result= np.zeros((np.shape(x)[0],np.shape(y)[1]))
      for i in range(np.shape(x)[1]):
          for j in range(np.shape(y)[1]):
              result[i,j] = w[i,j]+np.max(zeross, np.subtract(oness,w[:,j].dot(np.transpose(numpy_x)))).dot(numpy_x[:,i]*(numpy_y[:,j]*-1))
  
      return result
  
  print(compute(x,y))
  </code></pre>
  
  <p>Here <code>x</code> is a <code>100 by 100</code> matrix, <code>y</code> is a <code>100 by 5</code> matrix <code>w</code> is a <code>100 by 5</code> matrix
  The error that I'm getting is :</p>
  
  <blockquote>
    <p>Test Failed: only integer scalar arrays can be converted to a scalar index</p>
  </blockquote>
  
  <p>The compiler seems to indicate error is in library?</p>
  
  <pre><code>     37     return result
       38 
  ---&gt; 39 print(compute(x,y))
  
  2 frames
  &lt;ipython-input-36-8b5bccb531cc&gt; in compute(x, y)
       33     for i in range(np.shape(x)[1]):
       34         for j in range(np.shape(y)[1]):
  ---&gt; 35             result[i,j] = w[i,j]+np.max(zeross, np.subtract(oness,w[:,j].dot(np.transpose(numpy_x)))).dot(numpy_x[:,i]*(numpy_y[:,j]*-1))
       36 
       37     return result
  
  /usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py in amax(a, axis, out, keepdims, initial)
     2503     """
     2504     return _wrapreduction(a, np.maximum, 'max', axis, None, out, keepdims=keepdims,
  -&gt; 2505                           initial=initial)
     2506 
     2507 
  
  /usr/local/lib/python3.6/dist-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
       84                 return reduction(axis=axis, out=out, **passkwargs)
       85 
  ---&gt; 86     return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
       87 
       88 
  </code></pre>
  
  <p>Please help</p>