how to copy numpy array value into higher dimensions
<p>I have a (w,h) np array in 2d. I want to make a 3d dimension that has a value greater than 1 and copy its value over along the 3rd dimensions. I was hoping broadcast would do it but it can't. This is how i'm doing it</p>

<pre><code>arr = np.expand_dims(arr, axis=2)
arr = np.concatenate((arr,arr,arr), axis=2)
</code></pre>

<p>is there a a faster way to do so?</p>

<p>Not sure if I understood correctly, but broadcasting seems working to me in this case:</p>

<pre><code>&gt;&gt;&gt; a = numpy.array([[1,2], [3,4]])
&gt;&gt;&gt; c = numpy.zeros((4, 2, 2))
&gt;&gt;&gt; c[0] = a
&gt;&gt;&gt; c[1:] = a+1
&gt;&gt;&gt; c
array([[[ 1.,  2.],
        [ 3.,  4.]],

       [[ 2.,  3.],
        [ 4.,  5.]],

       [[ 2.,  3.],
        [ 4.,  5.]],

       [[ 2.,  3.],
        [ 4.,  5.]]])
</code></pre>

python numpy