Esempio n. 1
0
def test_relative_parity():
    for perm,parity in cases:
        #check lists of integers
        assert_equal(relative_parity(perm,perm), 0) 
        assert_equal(relative_parity(perm,list(range(len(perm)))), parity)
        
        #check lists of strings        
        L1 = list(map(str,perm))
        L2 = list(map(str,list(range(len(perm)))))
        assert_equal(relative_parity(L1,L1), 0)
        assert_equal(relative_parity(L1,L2), parity)
Esempio n. 2
0
def test_relative_parity():
    for perm, parity in cases:
        # check lists of integers
        assert_equal(relative_parity(perm, perm), 0)
        assert_equal(relative_parity(perm, range(len(perm))), parity)

        # check lists of strings
        L1 = map(str, perm)
        L2 = map(str, range(len(perm)))
        assert_equal(relative_parity(L1, L1), 0)
        assert_equal(relative_parity(L1, L2), parity)
Esempio n. 3
0
    def test_parity(self):
        """
        test parity with random data
        """
        for n_col in range(1,7):
            for n_row in range(1,50):
                A = arange(n_col*n_row)
                random.shuffle(A)
                A = A.reshape((n_row,n_col))

                s_parity = simplex_array_parity(A)

                for n,row in enumerate(A):
                    assert_equal(s_parity[n],relative_parity(row,sorted(row)))