title: Assigning complex values to numpy arrays?
body: <p>This gives the expected result</p>
  
  <pre><code>x = random.rand(1) + random.rand(1)*1j
  print x.dtype
  print x, x.real, x.imag
  </code></pre>
  
  <p>and this works</p>
  
  <pre><code>C = zeros((2,2),dtype=complex)
  C[0,0] = 1+1j
  print C
  </code></pre>
  
  <p>but if we change it to</p>
  
  <pre><code>C[0,0] = 1+1j + x
  </code></pre>
  
  <p>I get "TypeError: can't convert complex to float".</p>
  
  <p>If we now omit the explicit <code>dtype = complex</code>, I get "ValueError: setting an array element with a sequence".</p>
  
  <p>Can someone explain what's going on, and how to do this without errors? I'm lost.</p>