title: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() python
body: <p>I was asked to make the figure of the image bellow, using a grid (100,100) with the np.meshgrid and np.angle() and my only problem is that when i want to make the final boolean grid, python says: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().</p>
  
  <pre><code>from PIL import Image
  import numpy as np
  
  XX = np.arange(0,101)
  YY = np.arange(0,101) 
  x, y = np.meshgrid(XX, YY)
  
  x = x-50
  y = y-50
  
  z = x+ y*-1j
  
  print z    
  
  a = np.angle(z,deg=True)
  
  grid = (a&gt;=0 and a&lt;20) or (a&gt;=40 and a&lt;60) or (a&gt;=80 and a&lt;100) or (a&gt;=120 and a&lt;140) or++ (a&lt;=-20 and a&gt;-40) or (a&lt;=-60 and a&gt;-80) or (a&lt;=-100 and a&gt;-120) or (a&lt;=-140 and a&gt;-160)
  
  
  grid = grid.astype('uint8') * 255
  new_img = Image.fromarray(grid ,'L') 
  new_img.save("grid .bmp")
  </code></pre>