econml/utilities.py
def _apply(op, *XS):
    """
    Apply a function to a sequence of sparse or dense array arguments.

    If any array is sparse then all arrays are converted to COO before the function is applied;
    if all of the arrays are scipy sparse arrays, and if the result is 2D,
    the returned value will be a scipy sparse array as well
    """
    all_scipy_sparse = all(scipy.sparse.issparse(X) for X in XS)
    if any(issparse(X) for X in XS):
        XS = tuple(tocoo(X) for X in XS)
    result = op(*XS)
    if all_scipy_sparse and len(shape(result)) == 2:
        # both inputs were scipy and we can safely convert back to scipy because it's 2D
        return result.to_scipy_sparse()
    return result

    Apply a function to a sequence of sparse or dense array arguments.

    If any array is sparse then all arrays are converted to COO before the function is applied;
    if all of the arrays are scipy sparse arrays, and if the result is 2D,
    the returned value will be a scipy sparse array as well
    
Apply a function to a sequence of sparse or dense array arguments.
If any array is sparse then all arrays are converted to COO before the function is applied;
if all of the arrays are scipy sparse arrays, and if the result is 2D,
the returned value will be a scipy sparse array as well
Apply a function to a sequence of sparse or dense array arguments . If any array is sparse then all arrays are converted to COO before the function is applied ; if all of the arrays are scipy sparse arrays and if the result is 2D the returned value will be a scipy sparse array as well
def _apply(op, *XS):
    all_scipy_sparse = all(scipy.sparse.issparse(X) for X in XS)
    if any(issparse(X) for X in XS):
        XS = tuple(tocoo(X) for X in XS)
    result = op(*XS)
    if all_scipy_sparse and len(shape(result)) == 2:
        return result.to_scipy_sparse()
    return result
def _apply ( op , * XS ) : all_scipy_sparse = all ( scipy . sparse . issparse ( X ) for X in XS ) if any ( issparse ( X ) for X in XS ) : XS = tuple ( tocoo ( X ) for X in XS ) result = op ( * XS ) if all_scipy_sparse and len ( shape ( result ) ) == 2 : return result . to_scipy_sparse ( ) return result
Apply a function to a sequence of sparse or dense array arguments.
Apply a function to a sequence of sparse or dense array arguments .
"""
    Apply a function to a sequence of sparse or dense array arguments.

    If any array is sparse then all arrays are converted to COO before the function is applied;
    if all of the arrays are scipy sparse arrays, and if the result is 2D,
    the returned value will be a scipy sparse array as well
    """ # both inputs were scipy and we can safely convert back to scipy because it's 2D
op