econml/utilities.py
def reshape(X, shape):
    """Return a new array that is a reshaped version of an input array.

    The output will be sparse iff the input is.

    Parameters
    ----------
    X : array_like
        The array to reshape

    shape : tuple of ints
        The desired shape of the output array

    Returns
    -------
    ndarray or SparseArray
        The reshaped output array
    """
    if scipy.sparse.issparse(X):
        # scipy sparse arrays don't support reshaping (even for 2D they throw not implemented errors),
        # so convert to pydata sparse first
        X = sp.COO.from_scipy_sparse(X)
        if len(shape) == 2:
            # in the 2D case, we can convert back to scipy sparse; in other cases we can't
            return X.reshape(shape).to_scipy_sparse()
    return X.reshape(shape)
Return a new array that is a reshaped version of an input array.

    The output will be sparse iff the input is.

    Parameters
    ----------
    X : array_like
        The array to reshape

    shape : tuple of ints
        The desired shape of the output array

    Returns
    -------
    ndarray or SparseArray
        The reshaped output array
    
Return a new array that is a reshaped version of an input array.
The output will be sparse iff the input is.

Parameters

X : array_like
The array to reshape

shape : tuple of ints
The desired shape of the output array

Returns

ndarray or SparseArray
The reshaped output array
Return a new array that is a reshaped version of an input array . The output will be sparse iff the input is . Parameters X : array_like The array to reshape shape : tuple of ints The desired shape of the output array Returns ndarray or SparseArray The reshaped output array
def reshape(X, shape):
    if scipy.sparse.issparse(X):
        X = sp.COO.from_scipy_sparse(X)
        if len(shape) == 2:
            return X.reshape(shape).to_scipy_sparse()
    return X.reshape(shape)
def reshape ( X , shape ) : if scipy . sparse . issparse ( X ) : X = sp . COO . from_scipy_sparse ( X ) if len ( shape ) == 2 : return X . reshape ( shape ) . to_scipy_sparse ( ) return X . reshape ( shape )
Return a new array that is a reshaped version of an input array.
Return a new array that is a reshaped version of an input array .
"""Return a new array that is a reshaped version of an input array.

    The output will be sparse iff the input is.

    Parameters
    ----------
    X : array_like
        The array to reshape

    shape : tuple of ints
        The desired shape of the output array

    Returns
    -------
    ndarray or SparseArray
        The reshaped output array
    """ # scipy sparse arrays don't support reshaping (even for 2D they throw not implemented errors), # so convert to pydata sparse first # in the 2D case, we can convert back to scipy sparse; in other cases we can't
X
shape