[Numpy-discussion] Clarifications in numpy.ma module

Maniteja Nandana maniteja.modesty067 at gmail.com
Tue Dec 30 06:10:01 EST 2014


Guys,
sorry for the incomplete message,
*_DomainedBinaryOperation *for divide remainder

Related to issue 5354, where the docstring for  _*MaskedBinaryOperation *says
that invalid values are pre-masked*, but for **_DomainedBinaryOperation *where
the invalid values are masked in result, even if they are not masked in the
input.

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 *mod, **remainder and % *use.

5. The *mean* function doesn't take care of the edge case where array is
empty.

>>>np.mean(np.array([]))
/home/maniteja/FOSS/numpy/numpy/core/_methods.py:59: RuntimeWarning: Mean
of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)
/home/maniteja/FOSS/numpy/numpy/core/_methods.py:71: RuntimeWarning:
invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
nan

>>> np.ma.mean(np.ma.array([]))
/home/maniteja/FOSS/numpy/numpy/core/_methods.py:69: RuntimeWarning:
invalid value encountered in true_divide
  ret, rcount, out=ret, casting='unsafe', subok=False)
masked_array(data = nan,
             mask = False,
       fill_value = 1e+20)

Thanks ,
Maniteja.



On Tue, Dec 30, 2014 at 4:19 PM, Maniteja Nandana <
maniteja.modesty067 at gmail.com> wrote:

> Hi all,
>
> I have recently been trying out various functions in masked array module
> of numpy. I have got confused at a places in the *core.py *of *ma *module.
>
> 1. In the *masked_equal *method, the docstring doesn't suggest that the *fill_value
> *gets updated by the *value *parameter of the function, but this line (
> https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L1978 ) sets
> the *fill_value* as *value. *
>
> 2. The outputs of following functions - *any *(
> https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4327) - *all*
>  (https://github.com/numpy/numpy/blob/master/numpy/ma/core.py#L4280)
> are similar, they return *np.ma.masked *if all the elements have masks in
> the array, else return *True*.
>
> 3.  _*MaskedBinaryOperation : *Used for multiply, add, subtract
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141230/4ab7eacb/attachment.html>


More information about the NumPy-Discussion mailing list