title: initialize numpy array or arrays with particular shape
body: <p>I have a Python function that, given a scalar or vector <code>a</code>, does some sort of symmetry expansion, e.g.,</p>
  <pre class="lang-py prettyprint-override"><code>import numpy
  
  
  def expand(a):
      zero = numpy.zeros_like(a)
      return numpy.array([
          [zero, a, a],
          [a, zero, a],
          [a, a, zero],
          #
          [zero, -a, -a],
          [-a, zero, -a],
          [-a, -a, zero],
      ])
  </code></pre>
  <p>In this example, the resulting array will have shape <code>(6, 3, a.shape)</code>. Eventually I'll need shape <code>(6, a.shape, 3)</code> or <code>(3, a.shape, 6)</code> and contiguity, so I'll <code>numpy.moveaxis()</code> around. Even <code>(3, 6, a.shape)</code> would be an improvement. I can get this with</p>
  <pre class="lang-py prettyprint-override"><code>import numpy
  
  
  def expand(a):
      zero = numpy.zeros_like(a)
      return numpy.array([
          [zero, a, a, zero, -a, -a],
          [a, zero, a, -a, zero, -a],
          [a, a, zero, -a, -a, zero]
      ])
  </code></pre>
  <p>but this isn't as readable as the first version, especially if the transformation is more complex. (There always 3 columns.)</p>
  <p>Is there a way to initialize <code>out</code> to have the right shape straight away? (Note that <code>reshape()</code>ing won't do it, the data would be in wrong order.)</p>