def _flip_vectors(jn_matrix, m_matrix):
 m_matrix_trans = m_matrix.transpose()
 jn_matrix_trans = jn_matrix.transpose()
 new_matrix = zeros(jn_matrix_trans.shape, float)
 for (i, m_vector) in enumerate(m_matrix_trans):
  jn_vector = jn_matrix_trans[i]
  disT = list((m_vector - jn_vector))
  disT = sum(map(abs, disT))
  jn_flip = (jn_vector * [(-1)])
  disF = list((m_vector - jn_flip))
  disF = sum(map(abs, disF))
  if (disT > disF):
   new_matrix[i] = jn_flip
  else:
   new_matrix[i] = jn_vector
 return new_matrix.transpose()

def _flip_vectors ( jn_matrix , m_matrix ) : m_matrix_trans = m_matrix . transpose ( ) jn_matrix_trans = jn_matrix . transpose ( ) new_matrix = zeros ( jn_matrix_trans . shape , float ) for ( i , m_vector ) in enumerate ( m_matrix_trans ) : jn_vector = jn_matrix_trans [ i ] disT = list ( ( m_vector - jn_vector ) ) disT = sum ( map ( abs , disT ) ) jn_flip = ( jn_vector * [ ( - 1 ) ] ) disF = list ( ( m_vector - jn_flip ) ) disF = sum ( map ( abs , disF ) ) if ( disT > disF ) : new_matrix [ i ] = jn_flip else : new_matrix [ i ] = jn_vector return new_matrix . transpose ( )
transforms pca vectors so that signs are correct .