@@ -1415,6 +1415,14 @@ def parse_to_gate(
1415
1415
)
1416
1416
return gate_id
1417
1417
1418
+ if isinstance (gate_id , tuple ):
1419
+ # if given a tuple just unpack it
1420
+ if gate_args :
1421
+ raise ValueError (
1422
+ "You cannot specify ``gate_args`` when supplying a tuple."
1423
+ )
1424
+ gate_id , gate_args = gate_id [0 ], gate_id [1 :]
1425
+
1418
1426
if hasattr (gate_id , "shape" ) and not isinstance (gate_id , str ):
1419
1427
# raw gate (numpy strings have a shape - ignore those)
1420
1428
@@ -1663,8 +1671,7 @@ def __init__(
1663
1671
1664
1672
if self ._ket_site_ind_id == self ._bra_site_ind_id :
1665
1673
raise ValueError (
1666
- "The 'ket' and 'bra' site ind ids clash : "
1667
- "'{}' and '{}" .format (
1674
+ "The 'ket' and 'bra' site ind ids clash : '{}' and '{}" .format (
1668
1675
self ._ket_site_ind_id , self ._bra_site_ind_id
1669
1676
)
1670
1677
)
@@ -1833,7 +1840,7 @@ def from_gates(cls, gates, N=None, progbar=False, **kwargs):
1833
1840
1834
1841
N = 0
1835
1842
for gate in gates :
1836
- gate = parse_to_gate (* gate )
1843
+ gate = parse_to_gate (gate )
1837
1844
if gate .qubits :
1838
1845
N = max (N , max (gate .qubits ) + 1 )
1839
1846
if gate .controls :
@@ -4639,9 +4646,7 @@ def apply_gates(self, gates, progbar=False, **gate_opts):
4639
4646
)
4640
4647
4641
4648
for gate in gates :
4642
- if not isinstance (gate , Gate ):
4643
- gate = parse_to_gate (* gate )
4644
-
4649
+ gate = parse_to_gate (gate )
4645
4650
self ._apply_gate (gate , ** gate_opts )
4646
4651
4647
4652
if progbar and (gate .total_qubit_count >= 2 ):
0 commit comments