<p dir="auto">On numpy current master (<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/numpy/numpy/commit/da6e4c71aa229b8bdb18d643456cda4594e6384a/hovercard" href="https://github.com/numpy/numpy/commit/da6e4c71aa229b8bdb18d643456cda4594e6384a"><tt>da6e4c7</tt></a>), np.matmul is apparently not using BLAS:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; x = np.random.rand(5, 512, 512)
&gt;&gt;&gt; %timeit np.matmul(x, x)
1 loops, best of 3: 526 ms per loop
&gt;&gt;&gt; def xmul(a, b):
...     out = np.empty_like(a)
...     for j in range(a.shape[0]):
...         out[j] = np.dot(a[j], b[j])
...     return out
&gt;&gt;&gt; %timeit xmul(x, x)
10 loops, best of 3: 28 ms per loop"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; x = np.random.rand(5, 512, 512)
&gt;&gt;&gt; %timeit np.matmul(x, x)
1 loops, best of 3: 526 ms per loop
&gt;&gt;&gt; def xmul(a, b):
...     out = np.empty_like(a)
...     for j in range(a.shape[0]):
...         out[j] = np.dot(a[j], b[j])
...     return out
&gt;&gt;&gt; %timeit xmul(x, x)
10 loops, best of 3: 28 ms per loop
</code></pre></div>
<p dir="auto">Of course, it's a preliminary feature, but probably best to have an issue for this.</p>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/numpy/ticket/1071" rel="nofollow">http://projects.scipy.org/numpy/ticket/1071</a> on 2009-03-30 by trac user Electrion, assigned to unknown.</em></p>
<p dir="auto">Hello,</p>
<p dir="auto">I recently noticed that loadtxt() fails when I try to load a file that contains no value on the last column when it is TAB delimited.</p>
<p dir="auto">For example :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="s = StringIO('#X\tY\tC\n1.\t1.\t1.\n2.\t2.\t\n')
loadtxt(s)"><pre class="notranslate"><code class="notranslate">s = StringIO('#X\tY\tC\n1.\t1.\t1.\n2.\t2.\t\n')
loadtxt(s)
</code></pre></div>
<p dir="auto">will fail with Exception:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ValueError: setting an array element with a sequence."><pre class="notranslate"><code class="notranslate">ValueError: setting an array element with a sequence.
</code></pre></div>
<p dir="auto">The use of dtypes or converters (like {2: lambda s: float(s or 'Nan')} ) doesn't help.</p>
<p dir="auto">After investigation, I noticed that the loadtxt function strip all lines before splitting and then remove the '\t\n'.</p>
<p dir="auto">If think the 'split_line' subfunction in numpy.io.loadtxt</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    def split_line(line):
        &quot;&quot;&quot;Chop off comments, strip, and split at delimiter.&quot;&quot;&quot;
        line = line.split(comments)[0].strip()
[...]"><pre class="notranslate"><code class="notranslate">    def split_line(line):
        """Chop off comments, strip, and split at delimiter."""
        line = line.split(comments)[0].strip()
[...]
</code></pre></div>
<p dir="auto">should be replaced by</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    def split_line(line):
        &quot;&quot;&quot;Chop off comments, strip, and split at delimiter.&quot;&quot;&quot;
        line = line.split(comments)[0].strip('\r\n')
[...]"><pre class="notranslate"><code class="notranslate">    def split_line(line):
        """Chop off comments, strip, and split at delimiter."""
        line = line.split(comments)[0].strip('\r\n')
[...]
</code></pre></div>
<p dir="auto">to remove any new line character but not the delimiter.</p>