def test_circuit_get_fun_loc_vals(self):
        circ = Circuit(self.TOFFOLI)
        circ.blocks = [
            Block(self.TOFFOLI, (1, 2, 3)),
            Block(self.TOFFOLI, (0, 1, 2))
        ]
        fun_loc_vals = circ.get_fun_loc_vals()

        self.assertTrue(isinstance(fun_loc_vals, tuple))
        self.assertEqual(len(fun_loc_vals), 2)

        fun_vals = fun_loc_vals[0]
        loc_vals = fun_loc_vals[1]

        self.assertTrue(isinstance(fun_vals, list))
        self.assertTrue(isinstance(loc_vals, list))

        self.assertEqual(len(fun_vals), 2)
        self.assertEqual(len(loc_vals), 2)

        toffoli_vals = pauli_expansion(unitary_log_no_i(self.TOFFOLI))
        self.assertTrue(np.array_equal(fun_vals[0], toffoli_vals))
        self.assertTrue(np.array_equal(fun_vals[1], toffoli_vals))

        self.assertTrue(np.array_equal(loc_vals[0], (1, 2, 3)))
        self.assertTrue(np.array_equal(loc_vals[1], (0, 1, 2)))
    def test_get_unitary_from_pauli_coefs_1 ( self ):
        sigma = get_norder_paulis( 1 )

        for U in sigma:
            pauli_coefs = pauli_expansion( unitary_log_no_i( U ) )
            reU = get_unitary_from_pauli_coefs( pauli_coefs )
            self.assertTrue( hilbert_schmidt_distance( U, reU ) <= 1e-16 )
            self.assertTrue( np.allclose( U.conj().T @ U, np.identity( len( U ) ),
                                          rtol = 0, atol = 1e-16 )
                             and
                             np.allclose( U @ U.conj().T, np.identity( len( U ) ),
                                          rtol = 0, atol = 1e-16 ) )
    def test_unitary_log_no_i_valid_4(self):
        sigma = get_norder_paulis(4)

        for U in sigma:
            H = unitary_log_no_i(U)
            self.assertTrue(np.allclose(H, H.conj().T, rtol=0, atol=1e-15))
            reU = la.expm(1j * H)
            self.assertTrue(hilbert_schmidt_distance(U, reU) <= 1e-16)
            self.assertTrue(
                np.allclose(
                    U.conj().T @ U, np.identity(len(U)), rtol=0, atol=1e-16)
                and np.allclose(
                    U @ U.conj().T, np.identity(len(U)), rtol=0, atol=1e-16))
    def test_block_get_fun_vals ( self ):
        toffoli_vals = pauli_expansion( unitary_log_no_i( self.TOFFOLI ) )

        block = Block( self.TOFFOLI, (0, 1, 2) )
        self.assertTrue( np.array_equal( block.get_fun_vals(), toffoli_vals ) )