[Numpy-discussion] nan functions convert matrix to array

Keith Goodman kwgoodman at gmail.com
Fri Dec 1 16:46:39 EST 2006


The first line of the nan functions (such as nansum, nanmin, nanmax) is

y = array(a)

That leads to matrix in, array out.

Is there some way to make it matrix in, matrix out?

Here, for example, is nansum:

def nansum(a, axis=None):
    """Sum the array over the given axis, treating NaNs as 0.
    """
    y = array(a)
    if not issubclass(y.dtype.type, _nx.integer):
        y[isnan(a)] = 0
    return y.sum(axis)



More information about the NumPy-Discussion mailing list