<p dir="auto">The <a href="https://docs.scipy.org/doc/numpy-1.15.1/reference/ufuncs.html" rel="nofollow">ufunc reference</a> contains the following notes about <code class="notranslate">out</code> and <code class="notranslate">where</code> usage:</p>
<blockquote>
<p dir="auto">If ‘out’ is None (the default), a uninitialized return array is created. The output array is then filled with the results of the ufunc in the places that the broadcast ‘where’ is True. If ‘where’ is the scalar True (the default), then this corresponds to the entire output being filled. <strong>Note that outputs not explicitly filled are left with their uninitialized values.</strong></p>
</blockquote>
<p dir="auto">and</p>
<blockquote>
<p dir="auto">Note that if an uninitialized return array is created, values of False will leave those values uninitialized.</p>
</blockquote>
<p dir="auto">I understand why the API is like this, and that there are legitimate use cases that prevent unnecessary initialization. But it would be nice to also have this warning on the specific functions, like <a href="https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.divide.html" rel="nofollow">np.divide</a> etc. - especially because this is a construct where an innocent looking statement may result in non-deterministic behavior.</p>
<p dir="auto">Thanks!</p>
<p dir="auto">The numpy documentation on the use of the argument 'where' in <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.divide.html" rel="nofollow">numpy.divide</a> says:</p>
<blockquote>
<p dir="auto"><strong>where : <em>array_like, optional</em></strong><br>
Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.</p>
</blockquote>
<p dir="auto">I am wondering what value is used for the positions in the array where the condition in the argument 'where' evaluates to False. It does not set it to np.nan, nor takes the value from x1 / from x2, it seems to assign a random value. Sometimes it takes the value 0, which could make sense, but it is not very convenient to get a value that is not the same across the array, or not the same between two runs of the script.</p>
<p dir="auto">Obviously, it is possible for the user to assign values in the output array subsequently using Boolean indexing. So, I am wondering if this is the expected behaviour? If so, so be it and I will just assign values subsequently.</p>
<p dir="auto">Thank you.</p>
<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
arr = np.ones((10,), dtype=int)
x1 = arr * 2
x2 = arr * 3
d = np.divide(x1, x2, where=(arr != 1))
print(d)"><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-s1">arr</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>((<span class="pl-c1">10</span>,), <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">int</span>)
<span class="pl-s1">x1</span> <span class="pl-c1">=</span> <span class="pl-s1">arr</span> <span class="pl-c1">*</span> <span class="pl-c1">2</span>
<span class="pl-s1">x2</span> <span class="pl-c1">=</span> <span class="pl-s1">arr</span> <span class="pl-c1">*</span> <span class="pl-c1">3</span>
<span class="pl-s1">d</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">divide</span>(<span class="pl-s1">x1</span>, <span class="pl-s1">x2</span>, <span class="pl-s1">where</span><span class="pl-c1">=</span>(<span class="pl-s1">arr</span> <span class="pl-c1">!=</span> <span class="pl-c1">1</span>))
<span class="pl-en">print</span>(<span class="pl-s1">d</span>)</pre></div>
<h3 dir="auto">Numpy/Python version information:</h3>

<p dir="auto"><code class="notranslate">('1.15.0', '2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]')</code></p>