efficient numpy array creation
<p>Given <code>x</code>, I want to produce <code>x, log(x)</code> as a numpy array whereby <code>x</code> has shape <code>s</code>, the result has shape <code>(*s, 2)</code>.  What's the neatest way to do this?  <code>x</code> may just be a float, in which case I want a result with shape <code>(2,)</code>.</p>

<p>An ugly way to do this is:</p>

<pre><code>import numpy as np

x = np.asarray(x)
result = np.empty((*x.shape, 2))
result[..., 0] = x
result[..., 1] = np.log(x)
</code></pre>