(x)
return m
Equivalent of np.mean that supports sparse or dense matrices.
Equivalent of np.mean that supports sparse or dense matrices.
Equivalent of np . mean that supports sparse or dense matrices .
def mean(x):
    """ Equivalent of np.mean that supports sparse or dense matrices. """
    m = (np.sum(x.data) / np.prod(x.shape)
         if sp.issparse(x) else
         np.mean(x))
    if np.isnan(m):
        warnings.warn('mean() resulted in nan. If input can contain nan values,'
                      ' perhaps you meant nanmean?', stacklevel=2)
    return m
def mean ( x ) : m = ( np . sum ( x . data ) / np . prod ( x . shape ) if sp . issparse ( x ) else np . mean ( x ) ) if np . isnan ( m ) : warnings . warn ( 'mean() resulted in nan. If input can contain nan values,' ' perhaps you meant nanmean?' , stacklevel = 2 ) return m