#NEWLINE# def test_generate_equivalent_ids_1( ) : #NEWLINE# #INDENT# ( x , y , z , h ) = create_gate_sequence ( ) #NEWLINE# assert ( generate_equivalent_ids ( ( x , ) ) == { ( x , ) } ) #NEWLINE# assert ( generate_equivalent_ids ( ( x , x ) ) == { ( x , x ) } ) #NEWLINE# assert ( generate_equivalent_ids ( ( x , y ) ) == { ( x , y ) , ( y , x ) } ) #NEWLINE# gate_seq = ( x , y , z ) #NEWLINE# gate_ids = set ( [ ( x , y , z ) , ( y , z , x ) , ( z , x , y ) , ( z , y , x ) , ( y , x , z ) , ( x , z , y ) ] ) #NEWLINE# assert ( generate_equivalent_ids ( gate_seq ) == gate_ids ) #NEWLINE# gate_ids = set ( [ Mul ( x , y , z ) , Mul ( y , z , x ) , Mul ( z , x , y ) , Mul ( z , y , x ) , Mul ( y , x , z ) , Mul ( x , z , y ) ] ) #NEWLINE# assert ( generate_equivalent_ids ( gate_seq , return_as_muls = True ) == gate_ids ) #NEWLINE# gate_seq = ( x , y , z , h ) #NEWLINE# gate_ids = set ( [ ( x , y , z , h ) , ( y , z , h , x ) , ( h , x , y , z ) , ( h , z , y , x ) , ( z , y , x , h ) , ( y , x , h , z ) , ( z , h , x , y ) , ( x , h , z , y ) ] ) #NEWLINE# assert ( generate_equivalent_ids ( gate_seq ) == gate_ids ) #NEWLINE# gate_seq = ( x , y , x , y ) #NEWLINE# gate_ids = { ( x , y , x , y ) , ( y , x , y , x ) } #NEWLINE# assert ( generate_equivalent_ids ( gate_seq ) == gate_ids ) #NEWLINE# cgate_y = CGate ( ( 1 , ) , y ) #NEWLINE# gate_seq = ( y , cgate_y , y , cgate_y ) #NEWLINE# gate_ids = { ( y , cgate_y , y , cgate_y ) , ( cgate_y , y , cgate_y , y ) } #NEWLINE# assert ( generate_equivalent_ids ( gate_seq ) == gate_ids ) #NEWLINE# cnot = CNOT ( 1 , 0 ) #NEWLINE# cgate_z = CGate ( ( 0 , ) , Z ( 1 ) ) #NEWLINE# gate_seq = ( cnot , h , cgate_z , h ) #NEWLINE# gate_ids = set ( [ ( cnot , h , cgate_z , h ) , ( h , cgate_z , h , cnot ) , ( h , cnot , h , cgate_z ) , ( cgate_z , cgate_y , cnot , h ) ] ) #NEWLINE# assert ( generate_equivalent_ids ( gate_seq ) == gate_ids )