def safe_sqr(X, copy=True):
    X = check_array(X, accept_sparse=['csr', 'csc', 'coo'])
    if issparse(X):
        if copy:
            X = X.copy()
        X.data **= 2
    else:
        if copy:
            X = X ** 2
        else:
            X **= 2
    return X
Element wise squaring of array-likes and sparse matrices.
dataset/ETHPy150Open trevorstephens/gplearn/gplearn/skutils/__init__.py/safe_sqr