<commit_before>import numpy as np
import unittest
import gate

class TestGate(unittest.TestCase):
    def test_paulix_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('0 1; 1 0', np.complex_))

    def test_pauliy_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('0 -1i; 1i 0', np.complex_))

    def test_pauliz_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0; 0 -1', np.complex_))

    def test_swap_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1', np.complex_))

    def test_cnot_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0', np.complex_))

    def test_is_not_unitary(self):
        matrix = np.matrix('1 1; 1 0', np.complex_)
        self.failUnlessRaises(Exception, gate.QuantumGate, matrix)

if __name__ == '__main__':
    unittest.main()<commit_msg>test toffoli gate is unitary<commit_after>import numpy as np
import unittest
import gate

class TestGate(unittest.TestCase):
    def test_paulix_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('0 1; 1 0', np.complex_))

    def test_pauliy_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('0 -1i; 1i 0', np.complex_))

    def test_pauliz_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0; 0 -1', np.complex_))

    def test_swap_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1', np.complex_))

    def test_cnot_is_unitary(self):
        qg = gate.QuantumGate(np.matrix('1 0 0 0; 0 1 0 0; 0 0 0 1; 0 0 1 0', np.complex_))

    def test_toffoli_is_unitary(self):
        toffoli = np.matrix(
            '1 0 0 0 0 0 0 0;'
            '0 1 0 0 0 0 0 0;'
            '0 0 1 0 0 0 0 0;'
            '0 0 0 1 0 0 0 0;'
            '0 0 0 0 1 0 0 0;'
            '0 0 0 0 0 1 0 0;'
            '0 0 0 0 0 0 0 1;'
            '0 0 0 0 0 0 1 0', np.complex_
        )
        qg = gate.QuantumGate(toffoli)

    def test_is_not_unitary(self):
        matrix = np.matrix('1 1; 1 0', np.complex_)
        self.failUnlessRaises(Exception, gate.QuantumGate, matrix)

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.12171507607192254, 'fraction_numerical': 0.07376671277086215, 'mean_word_length': 2.472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1591333', 'n_tokens_mistral': 986, 'n_tokens_neox': 822, 'n_words': 252}