Skip to content

Commit 981194d

Browse files
adding matplotlib rendering module
1 parent e393b43 commit 981194d

File tree

6 files changed

+938
-13
lines changed

6 files changed

+938
-13
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ instance/
7070
# Scrapy stuff:
7171
.scrapy
7272

73+
# vscode
74+
.vscode
75+
7376
# Sphinx documentation
7477
doc/_build/
7578

@@ -128,4 +131,4 @@ venv.bak/
128131
dmypy.json
129132

130133
# Pyre type checker
131-
.pyre/
134+
.pyre/

src/qutip_qip/circuit/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .circuit import *
66
from .circuitsimulator import *
7+
from .mat_renderer import *
78
from ..operations import Gate, Measurement
89
from .texrenderer import *
910

src/qutip_qip/circuit/circuit.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def add_gate(
200200
classical_controls=None,
201201
control_value=None,
202202
classical_control_value=None,
203+
style=None,
203204
):
204205
"""
205206
Adds a gate with specified parameters to the circuit.
@@ -245,6 +246,7 @@ def add_gate(
245246
classical_controls=classical_controls,
246247
control_value=control_value,
247248
classical_control_value=classical_control_value,
249+
style=style,
248250
)
249251

250252
if index is None:
@@ -863,7 +865,7 @@ def propagators(self, expand=True, ignore_measurement=False):
863865
ignore_measurement: bool, optional
864866
Whether :class:`.Measurement` operators should be ignored.
865867
If set False, it will raise an error
866-
when the circuit has measurement.
868+
when the circuit hasf measurement.
867869
868870
Returns
869871
-------
@@ -885,16 +887,9 @@ def propagators(self, expand=True, ignore_measurement=False):
885887
)
886888
for gate in gates:
887889
if gate.name == "GLOBALPHASE":
888-
qobj = gate.get_qobj(self.N)
889-
else:
890-
qobj = self._get_gate_unitary(gate)
891-
if expand:
892-
all_targets = gate.get_all_qubits()
893-
qobj = expand_operator(
894-
qobj, dims=self.dims, targets=all_targets
895-
)
896-
U_list.append(qobj)
897-
return U_list
890+
qobj = gate.get_ (self.N)
891+
U_list.append(qobj)
892+
continue
898893

899894
def _get_gate_unitary(self, gate):
900895
if gate.name in self.user_gates:

src/qutip_qip/circuit/color_theme.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'''
2+
Color theme for different gates in the circuit diagram.
3+
'''
4+
5+
default_theme = {
6+
"H": "#6270CE",
7+
"SNOT": "#6270CE",
8+
"X": "#CB4BF9",
9+
"Y": "#CB4BF9",
10+
"Z": "#CB4BF9",
11+
"S": "#254065",
12+
"T": "#254065",
13+
"RX": "#5EBDF8",
14+
"RY": "#5EBDF8",
15+
"RZ": "#5EBDF8",
16+
"CNOT": "#3B3470",
17+
"CPHASE": '#456DB2', # change
18+
"TOFFOLI": "#3B3470", # change
19+
"SWAP": "#3B3470",
20+
"CX": "#9598f5",
21+
"CY": "#9598f5",
22+
"CZ": "#9598f5",
23+
"CS": "#9598f5",
24+
"CT": "#9598f5",
25+
"CRX": "#A66DDF",
26+
"CRY": "#A66DDF",
27+
"CRZ": "#A66DDF",
28+
"BERKELEY": "#7648CB",
29+
"FREDKIN": "#7648CB",
30+
}

0 commit comments

Comments
 (0)