<p dir="auto">The QR decomposition works properly when used alone. However, after I plot with a <code class="notranslate">.:</code> linestyle using <code class="notranslate">pyplot</code>, the result of QR decomposition becomes <code class="notranslate">nan</code>. This bug happens under the following condition.</p>
<ul dir="auto">
<li>The matrix shape is larger than 9x8. A 8x7 matrix works properly on my computer.</li>
<li>Plot with <code class="notranslate">.:</code> or <code class="notranslate">.--</code> linestyle. The linestyle <code class="notranslate">.-</code> will not cause a problem.</li>
<li>Windows platform. There is no such bug on MacOS.</li>
</ul>
<h3 dir="auto">Reproducing code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt


def testQR(A, bug):
    if bug:
        plt.plot([0, 1], [0, 1], &quot;.:&quot;)
    else:
        plt.plot([0, 1], [0, 1], &quot;.-&quot;)

    Q, _ = np.linalg.qr(A)
    print(&quot;==========================&quot;)
    print(&quot;Matrix shape:        {}x{}&quot;.format(A.shape[0], A.shape[1]))
    print(&quot;Linestyle of pyplot: {}&quot;.format(&quot;.:&quot; if bug else &quot;.-&quot;))
    print(&quot;First row of Q:      {}&quot;.format(Q[0]))


M_large = np.eye(9, 8)
M_small = np.eye(8, 7)

testQR(M_large, bug=True)
testQR(M_large, bug=False)
testQR(M_small, bug=True)
testQR(M_small, bug=False)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>


<span class="pl-k">def</span> <span class="pl-en">testQR</span>(<span class="pl-v">A</span>, <span class="pl-s1">bug</span>):
    <span class="pl-k">if</span> <span class="pl-s1">bug</span>:
        <span class="pl-s1">plt</span>.<span class="pl-en">plot</span>([<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], <span class="pl-s">".:"</span>)
    <span class="pl-k">else</span>:
        <span class="pl-s1">plt</span>.<span class="pl-en">plot</span>([<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], [<span class="pl-c1">0</span>, <span class="pl-c1">1</span>], <span class="pl-s">".-"</span>)

    <span class="pl-v">Q</span>, <span class="pl-s1">_</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">linalg</span>.<span class="pl-en">qr</span>(<span class="pl-v">A</span>)
    <span class="pl-en">print</span>(<span class="pl-s">"=========================="</span>)
    <span class="pl-en">print</span>(<span class="pl-s">"Matrix shape:        {}x{}"</span>.<span class="pl-en">format</span>(<span class="pl-v">A</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">0</span>], <span class="pl-v">A</span>.<span class="pl-s1">shape</span>[<span class="pl-c1">1</span>]))
    <span class="pl-en">print</span>(<span class="pl-s">"Linestyle of pyplot: {}"</span>.<span class="pl-en">format</span>(<span class="pl-s">".:"</span> <span class="pl-k">if</span> <span class="pl-s1">bug</span> <span class="pl-k">else</span> <span class="pl-s">".-"</span>))
    <span class="pl-en">print</span>(<span class="pl-s">"First row of Q:      {}"</span>.<span class="pl-en">format</span>(<span class="pl-v">Q</span>[<span class="pl-c1">0</span>]))


<span class="pl-v">M_large</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">eye</span>(<span class="pl-c1">9</span>, <span class="pl-c1">8</span>)
<span class="pl-v">M_small</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">eye</span>(<span class="pl-c1">8</span>, <span class="pl-c1">7</span>)

<span class="pl-en">testQR</span>(<span class="pl-v">M_large</span>, <span class="pl-s1">bug</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-en">testQR</span>(<span class="pl-v">M_large</span>, <span class="pl-s1">bug</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)
<span class="pl-en">testQR</span>(<span class="pl-v">M_small</span>, <span class="pl-s1">bug</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-en">testQR</span>(<span class="pl-v">M_small</span>, <span class="pl-s1">bug</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)</pre></div>
<p dir="auto">The result of the code above on my computer is</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="==========================
Matrix shape:        9x8
Linestyle of pyplot: .:
First row of Q:      [nan nan nan nan nan nan nan nan]
==========================
Matrix shape:        9x8
Linestyle of pyplot: .-
First row of Q:      [1. 0. 0. 0. 0. 0. 0. 0.]
==========================
Matrix shape:        8x7
Linestyle of pyplot: .:
First row of Q:      [1. 0. 0. 0. 0. 0. 0.]
==========================
Matrix shape:        8x7
Linestyle of pyplot: .-
First row of Q:      [1. 0. 0. 0. 0. 0. 0.]"><pre class="notranslate"><code class="notranslate">==========================
Matrix shape:        9x8
Linestyle of pyplot: .:
First row of Q:      [nan nan nan nan nan nan nan nan]
==========================
Matrix shape:        9x8
Linestyle of pyplot: .-
First row of Q:      [1. 0. 0. 0. 0. 0. 0. 0.]
==========================
Matrix shape:        8x7
Linestyle of pyplot: .:
First row of Q:      [1. 0. 0. 0. 0. 0. 0.]
==========================
Matrix shape:        8x7
Linestyle of pyplot: .-
First row of Q:      [1. 0. 0. 0. 0. 0. 0.]
</code></pre></div>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">numpy version:      1.18.1<br>
matplotlib version: 3.1.2<br>
python version:      3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]</p>
<p dir="auto">Tests are failing:<br>
FAILED ....\lib\tests\test_regression.py::TestRegression::test_polyfit_build - numpy.linalg.LinAlgError: SVD did not...<br>
FAILED ....\linalg\tests\test_regression.py::TestRegression::test_eig_build - numpy.linalg.LinAlgError: Eigenvalues ...<br>
FAILED ....\ma\tests\test_extras.py::TestPolynomial::test_polyfit - numpy.linalg.LinAlgError: SVD did not converge i...</p>
<p dir="auto">with exceptions:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="err = 'invalid value', flag = 8
    def _raise_linalgerror_lstsq(err, flag):
&gt;       raise LinAlgError(&quot;SVD did not converge in Linear Least Squares&quot;)
E       numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares
err        = 'invalid value'
flag       = 8"><pre class="notranslate"><code class="notranslate">err = 'invalid value', flag = 8
    def _raise_linalgerror_lstsq(err, flag):
&gt;       raise LinAlgError("SVD did not converge in Linear Least Squares")
E       numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares
err        = 'invalid value'
flag       = 8
</code></pre></div>
<p dir="auto">and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="err = 'invalid value', flag = 8
    def _raise_linalgerror_eigenvalues_nonconvergence(err, flag):
&gt;       raise LinAlgError(&quot;Eigenvalues did not converge&quot;)
E       numpy.linalg.LinAlgError: Eigenvalues did not converge
err        = 'invalid value'
flag       = 8"><pre class="notranslate"><code class="notranslate">err = 'invalid value', flag = 8
    def _raise_linalgerror_eigenvalues_nonconvergence(err, flag):
&gt;       raise LinAlgError("Eigenvalues did not converge")
E       numpy.linalg.LinAlgError: Eigenvalues did not converge
err        = 'invalid value'
flag       = 8
</code></pre></div>
<p dir="auto">Steps taken:</p>
<ul dir="auto">
<li>Create a VM</li>
<li>Install latest Windows 10 and update to the latest version 2004 (10.0.19041)</li>
<li>Install Python 3.8.3</li>
<li><code class="notranslate">pip install pytest</code></li>
<li><code class="notranslate">pip install numpy</code></li>
<li><code class="notranslate">pip install hypothesis</code></li>
<li>run tests in the package</li>
</ul>
<p dir="auto">Same happens issue happens when running on tests in the repository.</p>
<p dir="auto">Version 1.19.0 of numpy</p>
<p dir="auto">Am I missing any dependencies? Or is it just Windows going bonkers?</p>