Skip to content

Commit

Permalink
chore: add test of plotting gates
Browse files Browse the repository at this point in the history
  • Loading branch information
chensgit169 committed Dec 23, 2023
1 parent 8004e6b commit a2e8644
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions tests/quafu/instruction/gates_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import unittest

from numpy import pi
import matplotlib.pyplot as plt

import quafu.elements as qe
import quafu.elements.element_gates as qeg
from quafu import QuantumCircuit


class TestGate(unittest.TestCase):
Expand Down Expand Up @@ -65,16 +67,11 @@ def test_instances(self):
self.assertIn(gate.name.lower(), gate_classes)
return all_gates

# TODO: test plots
# for gate in all_gates:
# print(gate.name)
# qc = QuantumCircuit(4)
# qc.add_gate(gate)
# qc.measure()
# qc.plot_circuit(title=gate.__class__.__name__)
# plt.savefig('./icons/%s.png' % gate.name, dpi=400, transparent=True)
# plt.close()


if __name__ == '__main__':
unittest.main()
def test_plots(self):
all_gates = self.test_instances()
for gate in all_gates:
qc = QuantumCircuit(4)
qc.add_gate(gate)
qc.measure()
qc.plot_circuit(title=gate.__class__.__name__)
plt.close()

0 comments on commit a2e8644

Please sign in to comment.