(x, copy=True)
return x
Equivalent of np.nan_to_num that supports sparse and dense matrices.
Equivalent of np.nan_to_num that supports sparse and dense matrices.
Equivalent of np . nan_to_num that supports sparse and dense matrices .
def nan_to_num(x, copy=True):
    """ Equivalent of np.nan_to_num that supports sparse and dense matrices. """
    if not sp.issparse(x):
        return np.nan_to_num(x, copy=copy)

    if copy:
        x = x.copy()
    np.nan_to_num(x.data, copy=False)
    _eliminate_zeros(x)
    return x
def nan_to_num ( x , copy = True ) : if not sp . issparse ( x ) : return np . nan_to_num ( x , copy = copy ) if copy : x = x . copy ( ) np . nan_to_num ( x . data , copy = False ) _eliminate_zeros ( x ) return x