<p dir="auto">In Sagemath we encounter in our <a href="https://trac.sagemath.org/ticket/22799" rel="nofollow">ticket #22799</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="RuntimeWarning: invalid value encountered in multiply"><pre class="notranslate"><code class="notranslate">RuntimeWarning: invalid value encountered in multiply
</code></pre></div>
<p dir="auto">while multiplying a <code class="notranslate">numpy.float32</code> number with a non-numpy data; i.e. numpy ought to fail to do this multiplication silently, and indeed it does if one builds with gcc, or if instead of <code class="notranslate">np.float32</code> it is <code class="notranslate">np.float</code> or <code class="notranslate">np.float128</code>.</p>
<p dir="auto">More precisely, one gets the warning from the Python call</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="type(numpy.float32('1.5')).__mul__(numpy.float32('1.5'), x)"><pre class="notranslate"><code class="notranslate">type(numpy.float32('1.5')).__mul__(numpy.float32('1.5'), x)
</code></pre></div>
<p dir="auto">where <code class="notranslate">x</code> is a Sagemath univariate polynomial with coefficients in Sagemath's <code class="notranslate">RealField</code> type. (and only this particular type of data triggers this).<br>
That is, potentially, such meaningless warnings can be emitted outside of Sagemath; we can reproduce it on OSX 11.12 with its stock cc (some derivative of clang 3.8), as well as on Linux with clang 4.0 and on FreeBSD 11.0 with clang 4.0 or clang 3.7.</p>
<p dir="auto">Potentially we should be able to produce a way to reproduce this outside of Sagemath, although we'd need some tips where in numpy code this <code class="notranslate">__mul__</code> is actually implemented, to see what functions are applied to x...</p>
<p dir="auto">We see this on numpy 1.11 and on 1.12, too.</p>
<p dir="auto">numpy 1.13.1 dump fails to close the file that it opens (as a unit test in our code reported). The code appears to be as follows, which is clearly not closing the file it might open:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def dump(a, F):
    if not hasattr(F, 'readline'):
        F = open(F, 'w')
    return pickle.dump(a, F)"><pre class="notranslate"><code class="notranslate">def dump(a, F):
    if not hasattr(F, 'readline'):
        F = open(F, 'w')
    return pickle.dump(a, F)
</code></pre></div>