def safe_sqr(X, copy=True):
 X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], ensure_2d=False)
 if issparse(X):
  if copy:
   X = X.copy()
  X.data **= 2
 elif copy:
  X = (X ** 2)
 else:
  X **= 2
 return X

def safe_sqr ( X , copy = True ) : X = check_array ( X , accept_sparse = [ 'csr' , 'csc' , 'coo' ] , ensure_2d = False ) if issparse ( X ) : if copy : X = X . copy ( ) X . data **= 2 elif copy : X = ( X ** 2 ) else : X **= 2 return X
element wise squaring of array-likes and sparse matrices .