tequila-basic 1.9.9__py3-none-any.whl → 1.9.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. tequila/__init__.py +29 -14
  2. tequila/apps/__init__.py +14 -5
  3. tequila/apps/_unary_state_prep_impl.py +145 -112
  4. tequila/apps/adapt/__init__.py +9 -1
  5. tequila/apps/adapt/adapt.py +154 -113
  6. tequila/apps/krylov/__init__.py +1 -1
  7. tequila/apps/krylov/krylov.py +23 -21
  8. tequila/apps/robustness/helpers.py +10 -6
  9. tequila/apps/robustness/interval.py +238 -156
  10. tequila/apps/unary_state_prep.py +29 -23
  11. tequila/autograd_imports.py +8 -5
  12. tequila/circuit/__init__.py +2 -1
  13. tequila/circuit/_gates_impl.py +135 -67
  14. tequila/circuit/circuit.py +163 -79
  15. tequila/circuit/compiler.py +114 -105
  16. tequila/circuit/gates.py +288 -120
  17. tequila/circuit/gradient.py +35 -23
  18. tequila/circuit/noise.py +83 -74
  19. tequila/circuit/postselection.py +120 -0
  20. tequila/circuit/pyzx.py +10 -6
  21. tequila/circuit/qasm.py +201 -83
  22. tequila/circuit/qpic.py +63 -61
  23. tequila/grouping/binary_rep.py +148 -146
  24. tequila/grouping/binary_utils.py +84 -75
  25. tequila/grouping/compile_groups.py +334 -230
  26. tequila/grouping/ev_utils.py +77 -41
  27. tequila/grouping/fermionic_functions.py +383 -308
  28. tequila/grouping/fermionic_methods.py +170 -123
  29. tequila/grouping/overlapping_methods.py +69 -52
  30. tequila/hamiltonian/paulis.py +12 -13
  31. tequila/hamiltonian/paulistring.py +1 -1
  32. tequila/hamiltonian/qubit_hamiltonian.py +45 -35
  33. tequila/ml/__init__.py +1 -0
  34. tequila/ml/interface_torch.py +19 -16
  35. tequila/ml/ml_api.py +11 -10
  36. tequila/ml/utils_ml.py +12 -11
  37. tequila/objective/__init__.py +8 -3
  38. tequila/objective/braket.py +55 -47
  39. tequila/objective/objective.py +87 -55
  40. tequila/objective/qtensor.py +36 -27
  41. tequila/optimizers/__init__.py +31 -23
  42. tequila/optimizers/_containers.py +11 -7
  43. tequila/optimizers/optimizer_base.py +111 -83
  44. tequila/optimizers/optimizer_gd.py +258 -231
  45. tequila/optimizers/optimizer_gpyopt.py +56 -42
  46. tequila/optimizers/optimizer_scipy.py +157 -112
  47. tequila/quantumchemistry/__init__.py +66 -38
  48. tequila/quantumchemistry/chemistry_tools.py +393 -209
  49. tequila/quantumchemistry/encodings.py +121 -13
  50. tequila/quantumchemistry/madness_interface.py +170 -96
  51. tequila/quantumchemistry/orbital_optimizer.py +86 -41
  52. tequila/quantumchemistry/psi4_interface.py +166 -97
  53. tequila/quantumchemistry/pyscf_interface.py +70 -23
  54. tequila/quantumchemistry/qc_base.py +866 -414
  55. tequila/simulators/__init__.py +0 -3
  56. tequila/simulators/simulator_api.py +247 -105
  57. tequila/simulators/simulator_aqt.py +102 -0
  58. tequila/simulators/simulator_base.py +147 -53
  59. tequila/simulators/simulator_cirq.py +58 -42
  60. tequila/simulators/simulator_cudaq.py +600 -0
  61. tequila/simulators/simulator_ddsim.py +390 -0
  62. tequila/simulators/simulator_mqp.py +30 -0
  63. tequila/simulators/simulator_pyquil.py +190 -171
  64. tequila/simulators/simulator_qibo.py +95 -87
  65. tequila/simulators/simulator_qiskit.py +119 -107
  66. tequila/simulators/simulator_qlm.py +52 -26
  67. tequila/simulators/simulator_qulacs.py +74 -52
  68. tequila/simulators/simulator_spex.py +95 -60
  69. tequila/simulators/simulator_symbolic.py +6 -5
  70. tequila/simulators/test_spex_simulator.py +8 -11
  71. tequila/tools/convenience.py +4 -4
  72. tequila/tools/qng.py +72 -64
  73. tequila/tools/random_generators.py +38 -34
  74. tequila/utils/bitstrings.py +7 -7
  75. tequila/utils/exceptions.py +19 -5
  76. tequila/utils/joined_transformation.py +8 -10
  77. tequila/utils/keymap.py +0 -5
  78. tequila/utils/misc.py +6 -4
  79. tequila/version.py +1 -1
  80. tequila/wavefunction/qubit_wavefunction.py +47 -28
  81. {tequila_basic-1.9.9.dist-info → tequila_basic-1.9.10.dist-info}/METADATA +13 -16
  82. tequila_basic-1.9.10.dist-info/RECORD +93 -0
  83. {tequila_basic-1.9.9.dist-info → tequila_basic-1.9.10.dist-info}/WHEEL +1 -1
  84. tequila_basic-1.9.9.dist-info/RECORD +0 -88
  85. {tequila_basic-1.9.9.dist-info → tequila_basic-1.9.10.dist-info}/licenses/LICENSE +0 -0
  86. {tequila_basic-1.9.9.dist-info → tequila_basic-1.9.10.dist-info}/top_level.txt +0 -0
@@ -1,8 +1,14 @@
1
1
  from tequila import TequilaException
2
2
  from tequila.circuit.circuit import QCircuit
3
- from tequila.circuit.gates import Rx, Ry, H, X, Rz, ExpPauli, CNOT, Phase, T, Z
4
- from tequila.circuit._gates_impl import RotationGateImpl, PhaseGateImpl, QGateImpl, \
5
- ExponentialPauliGateImpl, TrotterizedGateImpl, PowerGateImpl
3
+ from tequila.circuit.gates import Rx, Ry, H, X, Rz, ExpPauli, CNOT, Phase, T, Z, GlobalPhase
4
+ from tequila.circuit._gates_impl import (
5
+ RotationGateImpl,
6
+ PhaseGateImpl,
7
+ QGateImpl,
8
+ ExponentialPauliGateImpl,
9
+ TrotterizedGateImpl,
10
+ PowerGateImpl,
11
+ )
6
12
  from tequila.utils import to_float
7
13
  from tequila.objective.objective import Variable, FixedVariable
8
14
  from tequila.objective.objective import Objective
@@ -10,7 +16,8 @@ from tequila.objective.objective import ExpectationValueImpl
10
16
  import numpy
11
17
  from numpy import pi as pi
12
18
 
13
- import copy, typing
19
+ import copy
20
+ import typing
14
21
 
15
22
 
16
23
  class TequilaCompilerException(TequilaException):
@@ -42,13 +49,13 @@ class CircuitCompiler:
42
49
  c = cls()
43
50
  for k in c.__dict__.keys():
44
51
  try:
45
- c.__dict__[k]=True
46
- except:
52
+ c.__dict__[k] = True
53
+ except Exception:
47
54
  pass
48
- for k,v in kwargs.items():
55
+ for k, v in kwargs.items():
49
56
  if k in c.__dict__:
50
- c.__dict__[k]=v
51
- c.gradient_mode=False
57
+ c.__dict__[k] = v
58
+ c.gradient_mode = False
52
59
 
53
60
  if not c.multicontrol:
54
61
  c.cc_max = False
@@ -60,42 +67,42 @@ class CircuitCompiler:
60
67
  # but not for standard gates like ry
61
68
  # set exceptions in kwargs
62
69
  c = cls.all_flags_true()
63
- c.gradient_mode=False
64
- c.y_gate=False
65
- c.ry_gate=False
70
+ c.gradient_mode = False
71
+ c.y_gate = False
72
+ c.ry_gate = False
66
73
 
67
- for k,v in kwargs.items():
74
+ for k, v in kwargs.items():
68
75
  if k in c.__dict__:
69
- c.__dict__[k]=v
76
+ c.__dict__[k] = v
70
77
 
71
78
  if not c.multicontrol:
72
79
  c.cc_max = False
73
80
  return c
74
81
 
75
- def __init__(self,
76
- multitarget=False,
77
- multicontrol=False,
78
- trotterized=False,
79
- generalized_rotation=False,
80
- exponential_pauli=False,
81
- controlled_exponential_pauli=False,
82
- hadamard_power=False,
83
- controlled_power=False,
84
- power=False,
85
- toffoli=False,
86
- controlled_phase=False,
87
- phase=False,
88
- phase_to_z=False,
89
- controlled_rotation=False,
90
- swap=False,
91
- cc_max=False,
92
- gradient_mode=False,
93
- ry_gate=False,
94
- y_gate=False,
95
- ch_gate=False,
96
- hadamard=False
97
- ):
98
-
82
+ def __init__(
83
+ self,
84
+ multitarget=False,
85
+ multicontrol=False,
86
+ trotterized=False,
87
+ generalized_rotation=False,
88
+ exponential_pauli=False,
89
+ controlled_exponential_pauli=False,
90
+ hadamard_power=False,
91
+ controlled_power=False,
92
+ power=False,
93
+ toffoli=False,
94
+ controlled_phase=False,
95
+ phase=False,
96
+ phase_to_z=False,
97
+ controlled_rotation=False,
98
+ swap=False,
99
+ cc_max=False,
100
+ gradient_mode=False,
101
+ ry_gate=False,
102
+ y_gate=False,
103
+ ch_gate=False,
104
+ hadamard=False,
105
+ ):
99
106
  """
100
107
  all parameters are booleans.
101
108
  Parameters
@@ -161,9 +168,9 @@ class CircuitCompiler:
161
168
  self.y_gate = y_gate
162
169
  self.ch_gate = ch_gate
163
170
 
164
- def __call__(self, objective: typing.Union[Objective, QCircuit, ExpectationValueImpl], variables=None, *args,
165
- **kwargs):
166
-
171
+ def __call__(
172
+ self, objective: typing.Union[Objective, QCircuit, ExpectationValueImpl], variables=None, *args, **kwargs
173
+ ):
167
174
  """
168
175
  Perform compilation
169
176
  Parameters
@@ -206,8 +213,8 @@ class CircuitCompiler:
206
213
  the objective, compiled
207
214
  """
208
215
 
209
- argsets=objective.argsets
210
- compiled_sets=[]
216
+ argsets = objective.argsets
217
+ compiled_sets = []
211
218
  for argset in argsets:
212
219
  compiled_args = []
213
220
  already_processed = {}
@@ -223,9 +230,8 @@ class CircuitCompiler:
223
230
  # nothing to process for non-expectation-value types, but acts as sanity check
224
231
  compiled_args.append(self.compile_objective_argument(arg, *args, **kwargs))
225
232
  compiled_sets.append(compiled_args)
226
- if isinstance(objective,Objective):
227
- return type(objective)(args=compiled_sets[0],transformation=objective.transformation)
228
-
233
+ if isinstance(objective, Objective):
234
+ return type(objective)(args=compiled_sets[0], transformation=objective.transformation)
229
235
 
230
236
  def compile_objective_argument(self, arg, *args, **kwargs):
231
237
  """
@@ -243,11 +249,8 @@ class CircuitCompiler:
243
249
  the arg, compiled
244
250
  """
245
251
 
246
-
247
252
  if isinstance(arg, ExpectationValueImpl) or (hasattr(arg, "U") and hasattr(arg, "H")):
248
- return ExpectationValueImpl(H=arg.H,
249
- U=self.compile_circuit(abstract_circuit=arg.U, *args,
250
- **kwargs))
253
+ return ExpectationValueImpl(H=arg.H, U=self.compile_circuit(abstract_circuit=arg.U, *args, **kwargs))
251
254
  elif hasattr(arg, "abstract_expectationvalue"):
252
255
  E = arg.abstract_expectationvalue
253
256
  E._U = self.compile_circuit(abstract_circuit=E.U, *args, **kwargs)
@@ -256,7 +259,8 @@ class CircuitCompiler:
256
259
  return arg
257
260
  else:
258
261
  raise TequilaCompilerException(
259
- "Unknown argument type for objectives: {arg} or type {type}".format(arg=arg, type=type(arg)))
262
+ "Unknown argument type for objectives: {arg} or type {type}".format(arg=arg, type=type(arg))
263
+ )
260
264
 
261
265
  def compile_circuit(self, abstract_circuit: QCircuit, variables=None, *args, **kwargs) -> QCircuit:
262
266
  """
@@ -293,7 +297,6 @@ class CircuitCompiler:
293
297
  compiled_gates = []
294
298
 
295
299
  for idx, gate in gatelist:
296
-
297
300
  cg = gate
298
301
  controlled = gate.is_controlled()
299
302
 
@@ -307,7 +310,6 @@ class CircuitCompiler:
307
310
  if g.is_controlled():
308
311
  controlled = True
309
312
 
310
-
311
313
  # order matters
312
314
  # first the real multi-target gates
313
315
  if controlled or self.trotterized:
@@ -374,17 +376,17 @@ def compiler(f):
374
376
  result += f(gate=g, **kwargs)
375
377
  return result
376
378
 
377
- elif hasattr(gate, 'U'):
379
+ elif hasattr(gate, "U"):
378
380
  cU = QCircuit()
379
381
  for g in gate.U.gates:
380
382
  cU += f(gate=g, **kwargs)
381
383
  return type(gate)(U=cU, H=gate.H)
382
- elif hasattr(gate, 'transformations'):
383
- outer=[]
384
+ elif hasattr(gate, "transformations"):
385
+ outer = []
384
386
  for args in gate.argsets:
385
387
  compiled = []
386
388
  for E in args:
387
- if hasattr(E, 'name'):
389
+ if hasattr(E, "name"):
388
390
  compiled.append(E)
389
391
  else:
390
392
  cU = QCircuit()
@@ -418,16 +420,16 @@ def change_basis(target, axis=None, name=None, daggered=False):
418
420
 
419
421
  """
420
422
  if axis is None and name is None:
421
- raise TequilaException('axis or name must be given.')
423
+ raise TequilaException("axis or name must be given.")
422
424
 
423
425
  if name:
424
426
  name = name.lower()
425
- if name in ['h', 'hadamard'] and daggered:
427
+ if name in ["h", "hadamard"] and daggered:
426
428
  return Ry(angle=numpy.pi / 4, target=target)
427
- elif name in ['h', 'hadamard']:
429
+ elif name in ["h", "hadamard"]:
428
430
  return Ry(angle=-numpy.pi / 4, target=target)
429
431
  else:
430
- name_to_axis = {'rx': 0, 'ry': 1, 'rz': 2}
432
+ name_to_axis = {"rx": 0, "ry": 1, "rz": 2}
431
433
  axis = name_to_axis.get(name, name)
432
434
 
433
435
  if isinstance(axis, str):
@@ -444,6 +446,7 @@ def change_basis(target, axis=None, name=None, daggered=False):
444
446
  else:
445
447
  return QCircuit()
446
448
 
449
+
447
450
  @compiler
448
451
  def compile_multitarget(gate, *args, **kwargs) -> QCircuit:
449
452
  """
@@ -515,7 +518,7 @@ def compile_controlled_rotation(gate: RotationGateImpl) -> QCircuit:
515
518
 
516
519
  result = QCircuit()
517
520
  result += change_basis(target=target, axis=gate._axis)
518
- coeff = - 1 / pow(2, k)
521
+ coeff = -1 / pow(2, k)
519
522
  for i, ci in enumerate(cind):
520
523
  coeff *= -1
521
524
 
@@ -549,7 +552,7 @@ def compile_to_single_control(gate) -> QCircuit:
549
552
  return QCircuit.wrap_gate(gate)
550
553
  name = gate.name
551
554
  back = QCircuit()
552
- if name in ['X', 'x', 'Y', 'y', 'Z', 'z', 'H', 'h']:
555
+ if name in ["X", "x", "Y", "y", "Z", "z", "H", "h"]:
553
556
  if isinstance(gate, PowerGateImpl):
554
557
  power = gate.parameter
555
558
  else:
@@ -565,7 +568,7 @@ def compile_to_single_control(gate) -> QCircuit:
565
568
  back += compile_to_single_control(gate=partial)
566
569
  else:
567
570
  print(gate)
568
- raise TequilaException('frankly, what the fuck is this gate?')
571
+ raise TequilaException("frankly, what the fuck is this gate?")
569
572
  return back
570
573
 
571
574
 
@@ -583,7 +586,7 @@ def compile_toffoli(gate) -> QCircuit:
583
586
  A QCircuit; the result of compilation.
584
587
  """
585
588
 
586
- if gate.name.lower != 'x':
589
+ if gate.name.lower != "x":
587
590
  return QCircuit.wrap_gate(gate)
588
591
  control = gate.control
589
592
  c1 = control[1]
@@ -606,7 +609,7 @@ def compile_toffoli(gate) -> QCircuit:
606
609
  result += T(c1).dagger()
607
610
  result += CNOT(c0, c1)
608
611
 
609
- return (result)
612
+ return result
610
613
 
611
614
 
612
615
  @compiler
@@ -650,17 +653,16 @@ def compile_power_base(gate):
650
653
  return QCircuit.wrap_gate(gate)
651
654
 
652
655
  power = gate.power
653
- if gate.name.lower() in ['h', 'hadamard']:
654
- ### off by global phase of Exp[ pi power /2]
656
+ if gate.name.lower() in ["h", "hadamard"]:
655
657
  theta = power * numpy.pi
656
658
 
657
659
  result = QCircuit()
658
660
  result += Ry(angle=-numpy.pi / 4, target=gate.target)
659
661
  result += Rz(angle=theta, target=gate.target)
660
662
  result += Ry(angle=numpy.pi / 4, target=gate.target)
661
- elif gate.name == 'X':
662
- ### off by global phase of Exp[ pi power /2]
663
- '''
663
+ result += GlobalPhase(angle=theta * pi / 2)
664
+ elif gate.name == "X":
665
+ """
664
666
  if we wanted to do it formally we would use the following
665
667
  a=-numpy.pi/2
666
668
  b=numpy.pi/2
@@ -670,23 +672,24 @@ def compile_power_base(gate):
670
672
  result+= Rz(angle=b,target=gate.target)
671
673
  result+= Ry(angle=theta,target=gate.target)
672
674
  result+= Rz(angle=a,target=gate.target)
673
- '''
675
+ """
674
676
  result = Rx(angle=power * numpy.pi, target=gate.target)
675
- elif gate.name == 'Y':
676
- ### off by global phase of Exp[ pi power /2]
677
+ result += GlobalPhase(angle=power * numpy.pi / 2)
678
+ elif gate.name == "Y":
677
679
  theta = power * numpy.pi
678
680
 
679
681
  result = QCircuit()
680
682
  result += Ry(angle=theta, target=gate.target)
681
- elif gate.name == 'Z':
682
- ### off by global phase of Exp[ pi power /2]
683
+ result += GlobalPhase(angle=theta / 2)
684
+ elif gate.name == "Z":
683
685
  a = 0
684
686
  b = power * numpy.pi
685
687
  theta = 0
686
688
  result = QCircuit()
687
689
  result += Rz(angle=b, target=gate.target)
690
+ result += GlobalPhase(angle=b / 2)
688
691
  else:
689
- raise TequilaException('passed a gate with name ' + gate.name + ', which cannot be handled!')
692
+ raise TequilaException("passed a gate with name " + gate.name + ", which cannot be handled!")
690
693
  return result
691
694
 
692
695
 
@@ -737,9 +740,8 @@ def compile_phase(gate) -> QCircuit:
737
740
  if not isinstance(gate, PhaseGateImpl):
738
741
  return QCircuit.wrap_gate(gate)
739
742
  phase = gate.parameter
740
- result = QCircuit()
741
743
  if len(gate.control) == 0:
742
- return Rz(angle=phase, target=gate.target)
744
+ return Rz(angle=phase, target=gate.target) + GlobalPhase(angle=phase / 2)
743
745
 
744
746
  result = compile_controlled_phase(gate)
745
747
  result = compile_phase(result)
@@ -814,14 +816,18 @@ def compile_swap(gate) -> QCircuit:
814
816
  if power is None or power in [1, 1.0]:
815
817
  pass
816
818
  else:
817
- raise TequilaCompilerException("Parametrized SWAPs should be decomposed on top level! Something went wrong")
819
+ raise TequilaCompilerException(
820
+ "Parametrized SWAPs should be decomposed on top level! Something went wrong"
821
+ )
818
822
 
819
823
  c = []
820
824
  if gate.control is not None:
821
825
  c = gate.control
822
- return X(target=gate.target[0], control=[gate.target[1]]) \
823
- + X(target=gate.target[1], control=[gate.target[0]] + list(c), power=power) \
824
- + X(target=gate.target[0], control=[gate.target[1]])
826
+ return (
827
+ X(target=gate.target[0], control=[gate.target[1]])
828
+ + X(target=gate.target[1], control=[gate.target[0]] + list(c), power=power)
829
+ + X(target=gate.target[0], control=[gate.target[1]])
830
+ )
825
831
 
826
832
  else:
827
833
  return QCircuit.wrap_gate(gate)
@@ -839,7 +845,6 @@ def compile_exponential_pauli_gate(gate) -> QCircuit:
839
845
  """
840
846
 
841
847
  if hasattr(gate, "paulistring"):
842
-
843
848
  angle = gate.paulistring.coeff * gate.parameter
844
849
 
845
850
  circuit = QCircuit()
@@ -890,8 +895,7 @@ def compile_exponential_pauli_gate(gate) -> QCircuit:
890
895
 
891
896
 
892
897
  def do_compile_trotterized_gate(generator, steps, factor, randomize, control):
893
-
894
- assert (generator.is_hermitian())
898
+ assert generator.is_hermitian()
895
899
  circuit = QCircuit()
896
900
  factor = factor / steps
897
901
  for index in range(steps):
@@ -922,15 +926,16 @@ def compile_generalized_rotation_gate(gate, compile_exponential_pauli: bool = Fa
922
926
  -------
923
927
 
924
928
  """
925
- if gate.generator is None or gate.name.lower() in ['phase', 'rx', 'ry', 'rz']:
929
+ if gate.generator is None or gate.name.lower() in ["phase", "globalphase", "rx", "ry", "rz"]:
926
930
  return QCircuit.wrap_gate(gate)
927
931
  if not hasattr(gate, "eigenvalues_magnitude"):
928
932
  return QCircuit.wrap_gate(gate)
929
933
 
930
934
  steps = 1 if not hasattr(gate, "steps") else gate.steps
931
935
 
932
- return do_compile_trotterized_gate(generator=gate.generator, steps=steps, randomize=False,
933
- factor=gate.parameter, control=gate.control)
936
+ return do_compile_trotterized_gate(
937
+ generator=gate.generator, steps=steps, randomize=False, factor=gate.parameter, control=gate.control
938
+ )
934
939
 
935
940
 
936
941
  @compiler
@@ -948,10 +953,12 @@ def compile_trotterized_gate(gate, compile_exponential_pauli: bool = False):
948
953
  if not hasattr(gate, "steps") or hasattr(gate, "eigenvalues_magnitude"):
949
954
  return QCircuit.wrap_gate(gate)
950
955
 
951
- randomize=False
956
+ randomize = False
952
957
  if hasattr(gate, "randomize"):
953
- randomize=gate.randomize
954
- result = do_compile_trotterized_gate(generator=gate.generator, steps=gate.steps, factor=gate.parameter, randomize=randomize, control=gate.control)
958
+ randomize = gate.randomize
959
+ result = do_compile_trotterized_gate(
960
+ generator=gate.generator, steps=gate.steps, factor=gate.parameter, randomize=randomize, control=gate.control
961
+ )
955
962
 
956
963
  if compile_exponential_pauli:
957
964
  return compile_exponential_pauli_gate(result)
@@ -976,12 +983,12 @@ def compile_ry(gate: RotationGateImpl, controlled_rotation: bool = False) -> QCi
976
983
  QCircuit, the result of compilation.
977
984
  """
978
985
  if gate.name.lower() == "ry":
979
-
980
986
  if not (gate.is_controlled() and controlled_rotation):
981
-
982
- return Rz(target=gate.target, control=None, angle=-numpy.pi / 2) \
983
- + Rx(target=gate.target, control=gate.control, angle=gate.parameter) \
984
- + Rz(target=gate.target, control=None, angle=numpy.pi / 2)
987
+ return (
988
+ Rz(target=gate.target, control=None, angle=-numpy.pi / 2)
989
+ + Rx(target=gate.target, control=gate.control, angle=gate.parameter)
990
+ + Rz(target=gate.target, control=None, angle=numpy.pi / 2)
991
+ )
985
992
 
986
993
  return QCircuit.wrap_gate(gate)
987
994
 
@@ -1000,10 +1007,11 @@ def compile_y(gate) -> QCircuit:
1000
1007
  QCircuit, the result of compilation.
1001
1008
  """
1002
1009
  if gate.name.lower() == "y":
1003
-
1004
- return Rz(target=gate.target, control=None, angle=-numpy.pi / 2) \
1005
- + X(target=gate.target, control=gate.control, power=gate.power if gate.is_parametrized() else None) \
1006
- + Rz(target=gate.target, control=None, angle=numpy.pi / 2)
1010
+ return (
1011
+ Rz(target=gate.target, control=None, angle=-numpy.pi / 2)
1012
+ + X(target=gate.target, control=gate.control, power=gate.power if gate.is_parameterized() else None)
1013
+ + Rz(target=gate.target, control=None, angle=numpy.pi / 2)
1014
+ )
1007
1015
 
1008
1016
  else:
1009
1017
  return QCircuit.wrap_gate(gate)
@@ -1024,9 +1032,10 @@ def compile_ch(gate: QGateImpl) -> QCircuit:
1024
1032
  QCircuit, the result of compilation.
1025
1033
  """
1026
1034
  if gate.name.lower() == "h" and gate.is_controlled():
1027
-
1028
- return Ry(target=gate.target, control=None, angle=-numpy.pi / 4) \
1029
- + Z(target=gate.target, control=gate.control, power=gate.power if gate.is_parametrized() else None) \
1030
- + Ry(target=gate.target, control=None, angle=numpy.pi / 4)
1035
+ return (
1036
+ Ry(target=gate.target, control=None, angle=-numpy.pi / 4)
1037
+ + Z(target=gate.target, control=gate.control, power=gate.power if gate.is_parameterized() else None)
1038
+ + Ry(target=gate.target, control=None, angle=numpy.pi / 4)
1039
+ )
1031
1040
  else:
1032
1041
  return QCircuit.wrap_gate(gate)