def inplace_swap_row_csc(X, m, n):
 for t in [m, n]:
  if isinstance(t, np.ndarray):
   raise TypeError('m and n should be valid integers')
 if (m < 0):
  m += X.shape[0]
 if (n < 0):
  n += X.shape[0]
 m_mask = (X.indices == m)
 X.indices[(X.indices == n)] = m
 X.indices[m_mask] = n

def inplace_swap_row_csc ( X , m , n ) : for t in [ m , n ] : if isinstance ( t , np . ndarray ) : raise TypeError ( 'm and n should be valid integers' ) if ( m < 0 ) : m += X . shape [ 0 ] if ( n < 0 ) : n += X . shape [ 0 ] m_mask = ( X . indices == m ) X . indices [ ( X . indices == n ) ] = m X . indices [ m_mask ] = n
swaps two rows of a csc matrix in-place .