[Numpy-discussion] Requesting Code Review of nanmedian ENH

alex argriffi at ncsu.edu
Sun Feb 16 13:11:12 EST 2014

On Sun, Feb 16, 2014 at 1:01 PM, David Freese <dfreese at stanford.edu> wrote:
> the 0s put into the array copy "arr" are not used in computation.  The
> _replace_nan call is used primarily to generate a mask of the NaNs and make
> sure it passes the mutation test.  I updated the unit tests to reflect
> negative values, which works.  (and the documentation should be cleaned up
> now)
> https://github.com/dfreese/numpy/compare/master...feature;nanmedian

It doesn't deal with numpy.matrix in the same way as numpy.nanmean.  For example

>>> import numpy as np
>>> m = np.matrix([[np.nan, np.nan, 1]])
>>> np.isscalar(np.nanmean(m))
>>> np.isscalar(np.nanmedian(m))

Some of the nanfunctions.py code has comments regarding carefulness in
dealing with subclasses of numpy.ndarray (like numpy.matrix), and some
of the nanfunctions tests include tests for this kind of behavior.

More information about the NumPy-Discussion mailing list