<div dir="ltr"><div>What do you mean that the mean function doesn't take care of the case where the array is empty? In the example you provided, they both end up being NaN, which is exactly correct.<br><br></div>Ben Root<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 30, 2014 at 6:10 AM, Maniteja Nandana <span dir="ltr"><<a href="mailto:maniteja.modesty067@gmail.com" target="_blank">maniteja.modesty067@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Guys,<div>sorry for the incomplete message,</div><div><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:16.8px;white-space:pre-wrap"><b>_DomainedBinaryOperation </b>for divide remainder</span><br></div><div><br></div><div>Related to issue 5354, where the docstring for <span style="font-size:12.8px"> _</span><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:16.8px;white-space:pre-wrap"><b>MaskedBinaryOperation </b>says that invalid values are pre-masked<b>, but for </b></span><b><font face="Consolas, Liberation Mono, Menlo, Courier, monospace" color="#333333"><span style="font-size:12px;line-height:16.8px;white-space:pre-wrap">_DomainedBinaryOperation </span></font></b><font face="Consolas, Liberation Mono, Menlo, Courier, monospace" color="#333333"><span style="font-size:12px;line-height:16.8px;white-space:pre-wrap">where the invalid values are masked in result, even if they are not masked in the input.</span></font><br></div><div><b><font face="Consolas, Liberation Mono, Menlo, Courier, monospace" color="#333333"><span style="font-size:12px;line-height:16.8px;white-space:pre-wrap"><br></span></font></b></div><div>4. Also, I had a doubt regarding the working of a%b and  np.ma.remainder(a,b), whether they are analogous to the way functions like add, divide work. Since, the changes done to the above BinaryOperation classes are visible to a/b, a*b, np.ma.multiply, np.ma.divide, np.ma.remainder, np.ma.mod but not a%b. Please do correct me if I am wrong about <b>mod, </b><b>remainder and % </b>use.<br></div><div><br></div><div>5. The <b>mean</b> function doesn't take care of the edge case where array is empty.<br><br><span style="font-family:trebuchet ms,sans-serif">>>>np.mean(np.array([]))<br>/home/maniteja/FOSS/numpy/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.<br>  warnings.warn("Mean of empty slice.", RuntimeWarning)<br>/home/maniteja/FOSS/numpy/numpy/core/_methods.py:71: RuntimeWarning: invalid value encountered in double_scalars<br>  ret = ret.dtype.type(ret / rcount)<br>nan<br><br>>>> np.ma.mean(np.ma.array([]))<br>/home/maniteja/FOSS/numpy/numpy/core/_methods.py:69: RuntimeWarning: invalid value encountered in true_divide<br>  ret, rcount, out=ret, casting='unsafe', subok=False)<br>masked_array(data = nan,<br>             mask = False,<br>       fill_value = 1e+20)<br></span><br></div><div>Thanks ,<br></div><div>Maniteja.<br></div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 30, 2014 at 4:19 PM, Maniteja Nandana <span dir="ltr"><<a href="mailto:maniteja.modesty067@gmail.com" target="_blank">maniteja.modesty067@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I have recently been trying out various functions in masked array module of numpy. I have got confused at a places in the <b>core.py </b>of <b>ma </b>module.</div><div><br></div><div>1. In the <b>masked_equal </b>method, the docstring doesn't suggest that the <i>fill_value </i>gets updated by the <i>value </i>parameter of the function, but this line (<a href="https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L1978" target="_blank">https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L1978</a> ) sets the <i>fill_value</i> as <i>value. </i></div><div><i><br></i></div><div>2. The outputs of following functions - <b>any </b>(<a href="https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4327" target="_blank">https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4327</a>) - <b>all</b> (<a href="https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4280" target="_blank">https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4280</a>)</div><div>are similar, they return <i>np.ma.masked </i>if all the elements have masks in the array, else return <i>True</i>.</div><div><br></div><div>3.  _<span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre-wrap"><b>MaskedBinaryOperation : </b>Used for multiply, add, subtract</span></div><div><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:16.7999992370605px;white-space:pre-wrap"><br></span></div></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>