<p dir="auto">Is this behavior of <code class="notranslate">np.double</code> desired?  I'm wondering about the middle case which I would have expected to be <code class="notranslate">array([3.])</code> instead of <code class="notranslate">3.0</code>.  I assume there is nothing special about <code class="notranslate">double</code> or <code class="notranslate">3</code> and that this is probably not a real issue, so it can be closed soon.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; np.double(np.asarray(3))
3.0
&gt;&gt;&gt; np.double(np.asarray([3]))
3.0
&gt;&gt;&gt; np.double(np.asarray([3, 4]))
array([ 3.,  4.])"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; np.double(np.asarray(3))
3.0
&gt;&gt;&gt; np.double(np.asarray([3]))
3.0
&gt;&gt;&gt; np.double(np.asarray([3, 4]))
array([ 3.,  4.])
</code></pre></div>
<p dir="auto">Hi all, I'm reporting a problem when using <code class="notranslate">np.float64</code> as a constructor.</p>
<p dir="auto">For any <code class="notranslate">a = np.array([[scalar]])</code> assuming <code class="notranslate">type(scalar) in (int, float)</code>, this raises <code class="notranslate">AssertionError</code>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="assert np.float64(a).shape is a.shape"><pre class="notranslate"><span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">float64</span>(<span class="pl-s1">a</span>).<span class="pl-s1">shape</span> <span class="pl-c1">is</span> <span class="pl-s1">a</span>.<span class="pl-s1">shape</span></pre></div>
<p dir="auto">The shape after casting to <code class="notranslate">np.float64</code> is <code class="notranslate">()</code> instead of the expected <code class="notranslate">(1,1)</code>. We can see what's going on more clearly when only this last assertion fails:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="scalar = 0.0 # example
a = np.array([[scalar]])
assert type(a) is np.ndarray
assert type(np.float64(a)) is np.ndarray #AssertionError"><pre class="notranslate"><span class="pl-s1">scalar</span> <span class="pl-c1">=</span> <span class="pl-c1">0.0</span> <span class="pl-c"># example</span>
<span class="pl-s1">a</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([[<span class="pl-s1">scalar</span>]])
<span class="pl-k">assert</span> <span class="pl-en">type</span>(<span class="pl-s1">a</span>) <span class="pl-c1">is</span> <span class="pl-s1">np</span>.<span class="pl-s1">ndarray</span>
<span class="pl-k">assert</span> <span class="pl-en">type</span>(<span class="pl-s1">np</span>.<span class="pl-en">float64</span>(<span class="pl-s1">a</span>)) <span class="pl-c1">is</span> <span class="pl-s1">np</span>.<span class="pl-s1">ndarray</span> <span class="pl-c">#AssertionError</span></pre></div>
<p dir="auto">The problem is that <code class="notranslate">np.float64(a) is np.float64(scalar)</code>. Contrary to expectations, <code class="notranslate">np.float64(a) is not np.float64([[scalar]])</code></p>
<p dir="auto">This happens with <code class="notranslate">v1.14.2</code> as well as <code class="notranslate">master</code>. I've tested with python <code class="notranslate">3.6.4</code>/<code class="notranslate">2.7.11</code> on <code class="notranslate">ubuntu 16.04</code>/<code class="notranslate">Mac OS 10.12.3</code>.</p>