code: def as_spinor_array(a):
      
      a = np.atleast_1d(a)
      assert a.dtype == np.dtype(np.quaternion)
      # I'm not sure why it has to be so complicated, but all of these steps
      # appear to be necessary in this case.
      return a.view(np.float).reshape(a.shape + (4,))[..., [0, 3, 2, 1]].ravel().view(np.complex).reshape(a.shape + (2,))
docs: View a quaternion array as spinors in two-complex representation
  
      This function is relatively slow and scales poorly, because memory
      copying is apparently involved -- I think it's due to the
      "advanced indexing" required to swap the columns.