qiskit 1.0.2__cp38-abi3-macosx_11_0_arm64.whl → 1.1.0rc1__cp38-abi3-macosx_11_0_arm64.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.
- qiskit/VERSION.txt +1 -1
- qiskit/__init__.py +27 -16
- qiskit/_accelerate.abi3.so +0 -0
- qiskit/_numpy_compat.py +73 -0
- qiskit/assembler/disassemble.py +5 -6
- qiskit/circuit/__init__.py +1131 -169
- qiskit/circuit/_classical_resource_map.py +7 -6
- qiskit/circuit/_utils.py +18 -8
- qiskit/circuit/annotated_operation.py +21 -0
- qiskit/circuit/barrier.py +10 -13
- qiskit/circuit/bit.py +0 -1
- qiskit/circuit/classical/__init__.py +2 -2
- qiskit/circuit/classical/expr/__init__.py +39 -5
- qiskit/circuit/classical/expr/constructors.py +84 -1
- qiskit/circuit/classical/expr/expr.py +83 -13
- qiskit/circuit/classical/expr/visitors.py +83 -0
- qiskit/circuit/commutation_checker.py +86 -51
- qiskit/circuit/controlflow/_builder_utils.py +9 -1
- qiskit/circuit/controlflow/break_loop.py +8 -22
- qiskit/circuit/controlflow/builder.py +116 -1
- qiskit/circuit/controlflow/continue_loop.py +8 -22
- qiskit/circuit/controlflow/control_flow.py +47 -8
- qiskit/circuit/controlflow/for_loop.py +8 -23
- qiskit/circuit/controlflow/if_else.py +13 -27
- qiskit/circuit/controlflow/switch_case.py +14 -21
- qiskit/circuit/controlflow/while_loop.py +9 -23
- qiskit/circuit/controlledgate.py +2 -2
- qiskit/circuit/delay.py +7 -5
- qiskit/circuit/gate.py +20 -7
- qiskit/circuit/instruction.py +31 -30
- qiskit/circuit/instructionset.py +9 -22
- qiskit/circuit/library/__init__.py +8 -2
- qiskit/circuit/library/arithmetic/integer_comparator.py +2 -2
- qiskit/circuit/library/arithmetic/quadratic_form.py +3 -2
- qiskit/circuit/library/blueprintcircuit.py +29 -7
- qiskit/circuit/library/data_preparation/state_preparation.py +6 -5
- qiskit/circuit/library/generalized_gates/diagonal.py +5 -4
- qiskit/circuit/library/generalized_gates/isometry.py +51 -254
- qiskit/circuit/library/generalized_gates/pauli.py +2 -2
- qiskit/circuit/library/generalized_gates/permutation.py +4 -1
- qiskit/circuit/library/generalized_gates/rv.py +15 -11
- qiskit/circuit/library/generalized_gates/uc.py +2 -98
- qiskit/circuit/library/generalized_gates/unitary.py +9 -4
- qiskit/circuit/library/hamiltonian_gate.py +11 -5
- qiskit/circuit/library/n_local/efficient_su2.py +5 -5
- qiskit/circuit/library/n_local/n_local.py +100 -49
- qiskit/circuit/library/n_local/two_local.py +3 -59
- qiskit/circuit/library/overlap.py +3 -3
- qiskit/circuit/library/phase_oracle.py +1 -1
- qiskit/circuit/library/quantum_volume.py +39 -38
- qiskit/circuit/library/standard_gates/equivalence_library.py +50 -0
- qiskit/circuit/library/standard_gates/global_phase.py +4 -2
- qiskit/circuit/library/standard_gates/i.py +1 -2
- qiskit/circuit/library/standard_gates/iswap.py +1 -2
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +11 -5
- qiskit/circuit/library/standard_gates/p.py +31 -15
- qiskit/circuit/library/standard_gates/r.py +4 -3
- qiskit/circuit/library/standard_gates/rx.py +7 -4
- qiskit/circuit/library/standard_gates/rxx.py +4 -3
- qiskit/circuit/library/standard_gates/ry.py +7 -4
- qiskit/circuit/library/standard_gates/ryy.py +4 -3
- qiskit/circuit/library/standard_gates/rz.py +7 -4
- qiskit/circuit/library/standard_gates/rzx.py +4 -3
- qiskit/circuit/library/standard_gates/rzz.py +4 -3
- qiskit/circuit/library/standard_gates/s.py +4 -8
- qiskit/circuit/library/standard_gates/t.py +2 -4
- qiskit/circuit/library/standard_gates/u.py +16 -11
- qiskit/circuit/library/standard_gates/u1.py +6 -2
- qiskit/circuit/library/standard_gates/u2.py +4 -2
- qiskit/circuit/library/standard_gates/u3.py +9 -5
- qiskit/circuit/library/standard_gates/x.py +22 -11
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +4 -3
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +7 -5
- qiskit/circuit/library/standard_gates/z.py +1 -2
- qiskit/circuit/measure.py +4 -1
- qiskit/circuit/operation.py +13 -8
- qiskit/circuit/parameter.py +11 -6
- qiskit/circuit/quantumcircuit.py +864 -128
- qiskit/circuit/quantumcircuitdata.py +2 -2
- qiskit/circuit/reset.py +5 -2
- qiskit/circuit/store.py +95 -0
- qiskit/compiler/assembler.py +22 -22
- qiskit/compiler/transpiler.py +63 -112
- qiskit/converters/circuit_to_dag.py +7 -0
- qiskit/converters/circuit_to_dagdependency_v2.py +47 -0
- qiskit/converters/circuit_to_gate.py +2 -0
- qiskit/converters/circuit_to_instruction.py +22 -0
- qiskit/converters/dag_to_circuit.py +4 -0
- qiskit/converters/dag_to_dagdependency_v2.py +44 -0
- qiskit/dagcircuit/collect_blocks.py +15 -10
- qiskit/dagcircuit/dagcircuit.py +434 -124
- qiskit/dagcircuit/dagdependency.py +19 -12
- qiskit/dagcircuit/dagdependency_v2.py +641 -0
- qiskit/dagcircuit/dagdepnode.py +19 -16
- qiskit/dagcircuit/dagnode.py +14 -4
- qiskit/primitives/__init__.py +12 -8
- qiskit/primitives/backend_estimator.py +3 -5
- qiskit/primitives/backend_estimator_v2.py +410 -0
- qiskit/primitives/backend_sampler_v2.py +287 -0
- qiskit/primitives/base/base_estimator.py +4 -9
- qiskit/primitives/base/base_sampler.py +2 -2
- qiskit/primitives/containers/__init__.py +5 -4
- qiskit/primitives/containers/bit_array.py +292 -2
- qiskit/primitives/containers/data_bin.py +123 -50
- qiskit/primitives/containers/estimator_pub.py +10 -3
- qiskit/primitives/containers/observables_array.py +2 -2
- qiskit/primitives/containers/pub_result.py +1 -1
- qiskit/primitives/containers/sampler_pub.py +19 -3
- qiskit/primitives/containers/sampler_pub_result.py +74 -0
- qiskit/primitives/containers/shape.py +1 -1
- qiskit/primitives/statevector_estimator.py +4 -4
- qiskit/primitives/statevector_sampler.py +7 -12
- qiskit/providers/__init__.py +17 -18
- qiskit/providers/backend.py +2 -2
- qiskit/providers/backend_compat.py +8 -10
- qiskit/providers/basic_provider/basic_provider_tools.py +67 -31
- qiskit/providers/basic_provider/basic_simulator.py +81 -21
- qiskit/providers/fake_provider/fake_1q.py +1 -1
- qiskit/providers/fake_provider/fake_backend.py +3 -408
- qiskit/providers/fake_provider/generic_backend_v2.py +26 -14
- qiskit/providers/provider.py +16 -0
- qiskit/pulse/builder.py +4 -1
- qiskit/pulse/parameter_manager.py +60 -4
- qiskit/pulse/schedule.py +29 -13
- qiskit/pulse/utils.py +61 -20
- qiskit/qasm2/__init__.py +1 -5
- qiskit/qasm2/parse.py +1 -4
- qiskit/qasm3/__init__.py +42 -5
- qiskit/qasm3/ast.py +19 -0
- qiskit/qasm3/exporter.py +178 -106
- qiskit/qasm3/printer.py +27 -5
- qiskit/qpy/__init__.py +247 -13
- qiskit/qpy/binary_io/circuits.py +216 -47
- qiskit/qpy/binary_io/schedules.py +42 -36
- qiskit/qpy/binary_io/value.py +201 -22
- qiskit/qpy/common.py +1 -1
- qiskit/qpy/exceptions.py +20 -0
- qiskit/qpy/formats.py +29 -0
- qiskit/qpy/type_keys.py +21 -0
- qiskit/quantum_info/analysis/distance.py +3 -3
- qiskit/quantum_info/analysis/make_observable.py +2 -1
- qiskit/quantum_info/analysis/z2_symmetries.py +2 -1
- qiskit/quantum_info/operators/channel/chi.py +9 -8
- qiskit/quantum_info/operators/channel/choi.py +10 -9
- qiskit/quantum_info/operators/channel/kraus.py +2 -1
- qiskit/quantum_info/operators/channel/ptm.py +10 -9
- qiskit/quantum_info/operators/channel/quantum_channel.py +2 -1
- qiskit/quantum_info/operators/channel/stinespring.py +2 -1
- qiskit/quantum_info/operators/channel/superop.py +12 -11
- qiskit/quantum_info/operators/channel/transformations.py +12 -11
- qiskit/quantum_info/operators/dihedral/dihedral.py +5 -4
- qiskit/quantum_info/operators/operator.py +43 -30
- qiskit/quantum_info/operators/scalar_op.py +10 -9
- qiskit/quantum_info/operators/symplectic/base_pauli.py +70 -59
- qiskit/quantum_info/operators/symplectic/clifford.py +36 -9
- qiskit/quantum_info/operators/symplectic/pauli.py +48 -4
- qiskit/quantum_info/operators/symplectic/pauli_list.py +36 -14
- qiskit/quantum_info/operators/symplectic/random.py +3 -2
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +54 -33
- qiskit/quantum_info/states/densitymatrix.py +13 -13
- qiskit/quantum_info/states/stabilizerstate.py +3 -3
- qiskit/quantum_info/states/statevector.py +14 -13
- qiskit/quantum_info/states/utils.py +5 -3
- qiskit/result/mitigation/correlated_readout_mitigator.py +3 -2
- qiskit/result/mitigation/local_readout_mitigator.py +2 -1
- qiskit/result/mitigation/utils.py +3 -2
- qiskit/synthesis/__init__.py +2 -0
- qiskit/synthesis/discrete_basis/commutator_decompose.py +2 -2
- qiskit/synthesis/evolution/lie_trotter.py +7 -14
- qiskit/synthesis/evolution/qdrift.py +3 -4
- qiskit/synthesis/linear/cnot_synth.py +1 -3
- qiskit/synthesis/linear/linear_circuits_utils.py +1 -1
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +4 -18
- qiskit/synthesis/permutation/__init__.py +1 -0
- qiskit/synthesis/permutation/permutation_reverse_lnn.py +90 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +2 -6
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +165 -954
- qiskit/synthesis/two_qubit/xx_decompose/circuits.py +13 -12
- qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +7 -1
- qiskit/synthesis/unitary/aqc/__init__.py +1 -1
- qiskit/synthesis/unitary/aqc/cnot_structures.py +2 -1
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +2 -1
- qiskit/synthesis/unitary/qsd.py +3 -2
- qiskit/transpiler/__init__.py +7 -3
- qiskit/transpiler/layout.py +140 -61
- qiskit/transpiler/passes/__init__.py +6 -0
- qiskit/transpiler/passes/basis/basis_translator.py +7 -2
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +1 -1
- qiskit/transpiler/passes/calibration/rzx_builder.py +2 -1
- qiskit/transpiler/passes/layout/apply_layout.py +8 -3
- qiskit/transpiler/passes/layout/sabre_layout.py +15 -3
- qiskit/transpiler/passes/layout/set_layout.py +1 -1
- qiskit/transpiler/passes/optimization/__init__.py +2 -0
- qiskit/transpiler/passes/optimization/commutation_analysis.py +2 -2
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +1 -1
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +1 -1
- qiskit/transpiler/passes/optimization/cx_cancellation.py +10 -0
- qiskit/transpiler/passes/optimization/elide_permutations.py +114 -0
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +9 -3
- qiskit/transpiler/passes/optimization/optimize_annotated.py +248 -12
- qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +1 -3
- qiskit/transpiler/passes/routing/__init__.py +1 -0
- qiskit/transpiler/passes/routing/basic_swap.py +13 -2
- qiskit/transpiler/passes/routing/lookahead_swap.py +7 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +10 -6
- qiskit/transpiler/passes/routing/star_prerouting.py +417 -0
- qiskit/transpiler/passes/routing/stochastic_swap.py +24 -8
- qiskit/transpiler/passes/scheduling/__init__.py +1 -1
- qiskit/transpiler/passes/scheduling/alap.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +9 -6
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +8 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +13 -4
- qiskit/transpiler/passes/scheduling/asap.py +1 -2
- qiskit/transpiler/passes/scheduling/base_scheduler.py +21 -2
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +26 -4
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +24 -2
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +28 -4
- qiskit/transpiler/passes/synthesis/aqc_plugin.py +2 -2
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +120 -13
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +162 -55
- qiskit/transpiler/passes/utils/gates_basis.py +3 -3
- qiskit/transpiler/passmanager.py +44 -1
- qiskit/transpiler/preset_passmanagers/__init__.py +3 -3
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +34 -16
- qiskit/transpiler/preset_passmanagers/common.py +4 -6
- qiskit/transpiler/preset_passmanagers/plugin.py +9 -1
- qiskit/utils/optionals.py +6 -2
- qiskit/visualization/array.py +1 -1
- qiskit/visualization/bloch.py +2 -3
- qiskit/visualization/circuit/matplotlib.py +44 -14
- qiskit/visualization/circuit/text.py +38 -18
- qiskit/visualization/counts_visualization.py +3 -6
- qiskit/visualization/dag_visualization.py +6 -7
- qiskit/visualization/pulse_v2/interface.py +8 -3
- qiskit/visualization/state_visualization.py +3 -2
- qiskit/visualization/timeline/interface.py +18 -8
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/METADATA +12 -8
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/RECORD +245 -235
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/WHEEL +1 -1
- qiskit/_qasm2.abi3.so +0 -0
- qiskit/_qasm3.abi3.so +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/entry_points.txt +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0rc1.dist-info}/top_level.txt +0 -0
@@ -107,7 +107,7 @@ class XGate(SingletonGate):
|
|
107
107
|
num_ctrl_qubits: number of control qubits.
|
108
108
|
label: An optional label for the gate [Default: ``None``]
|
109
109
|
ctrl_state: control state expressed as integer,
|
110
|
-
string (e.g
|
110
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
111
111
|
annotated: indicates whether the controlled gate can be implemented
|
112
112
|
as an annotated gate.
|
113
113
|
|
@@ -250,7 +250,7 @@ class CXGate(SingletonControlledGate):
|
|
250
250
|
num_ctrl_qubits: number of control qubits.
|
251
251
|
label: An optional label for the gate [Default: ``None``]
|
252
252
|
ctrl_state: control state expressed as integer,
|
253
|
-
string (e.g
|
253
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
254
254
|
annotated: indicates whether the controlled gate can be implemented
|
255
255
|
as an annotated gate.
|
256
256
|
|
@@ -444,7 +444,7 @@ class CCXGate(SingletonControlledGate):
|
|
444
444
|
num_ctrl_qubits: number of control qubits.
|
445
445
|
label: An optional label for the gate [Default: ``None``]
|
446
446
|
ctrl_state: control state expressed as integer,
|
447
|
-
string (e.g
|
447
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
448
448
|
annotated: indicates whether the controlled gate can be implemented
|
449
449
|
as an annotated gate.
|
450
450
|
|
@@ -585,7 +585,7 @@ class C3SXGate(SingletonControlledGate):
|
|
585
585
|
Args:
|
586
586
|
label: An optional label for the gate [Default: ``None``]
|
587
587
|
ctrl_state: control state expressed as integer,
|
588
|
-
string (e.g
|
588
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
589
589
|
"""
|
590
590
|
from .sx import SXGate
|
591
591
|
|
@@ -785,7 +785,7 @@ class C3XGate(SingletonControlledGate):
|
|
785
785
|
num_ctrl_qubits: number of control qubits.
|
786
786
|
label: An optional label for the gate [Default: ``None``]
|
787
787
|
ctrl_state: control state expressed as integer,
|
788
|
-
string (e.g
|
788
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
789
789
|
annotated: indicates whether the controlled gate can be implemented
|
790
790
|
as an annotated gate.
|
791
791
|
|
@@ -1029,7 +1029,7 @@ class C4XGate(SingletonControlledGate):
|
|
1029
1029
|
num_ctrl_qubits: number of control qubits.
|
1030
1030
|
label: An optional label for the gate [Default: ``None``]
|
1031
1031
|
ctrl_state: control state expressed as integer,
|
1032
|
-
string (e.g
|
1032
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
1033
1033
|
annotated: indicates whether the controlled gate can be implemented
|
1034
1034
|
as an annotated gate.
|
1035
1035
|
|
@@ -1095,7 +1095,7 @@ class MCXGate(ControlledGate):
|
|
1095
1095
|
explicit CX, CCX, C3X or C4X instance or a generic MCX gate.
|
1096
1096
|
"""
|
1097
1097
|
# The CXGate and CCXGate will be implemented for all modes of the MCX, and
|
1098
|
-
# the C3XGate and C4XGate
|
1098
|
+
# the C3XGate and C4XGate are handled in the gate definition.
|
1099
1099
|
explicit: dict[int, Type[ControlledGate]] = {1: CXGate, 2: CCXGate}
|
1100
1100
|
gate_class = explicit.get(num_ctrl_qubits, None)
|
1101
1101
|
if gate_class is not None:
|
@@ -1166,14 +1166,25 @@ class MCXGate(ControlledGate):
|
|
1166
1166
|
raise AttributeError(f"Unsupported mode ({mode}) specified!")
|
1167
1167
|
|
1168
1168
|
def _define(self):
|
1169
|
-
"""
|
1169
|
+
"""This definition is based on MCPhaseGate implementation."""
|
1170
1170
|
# pylint: disable=cyclic-import
|
1171
1171
|
from qiskit.circuit.quantumcircuit import QuantumCircuit
|
1172
1172
|
|
1173
1173
|
q = QuantumRegister(self.num_qubits, name="q")
|
1174
1174
|
qc = QuantumCircuit(q)
|
1175
|
-
|
1176
|
-
|
1175
|
+
if self.num_qubits == 4:
|
1176
|
+
qc._append(C3XGate(), q[:], [])
|
1177
|
+
self.definition = qc
|
1178
|
+
elif self.num_qubits == 5:
|
1179
|
+
qc._append(C4XGate(), q[:], [])
|
1180
|
+
self.definition = qc
|
1181
|
+
else:
|
1182
|
+
q_controls = list(range(self.num_ctrl_qubits))
|
1183
|
+
q_target = self.num_ctrl_qubits
|
1184
|
+
qc.h(q_target)
|
1185
|
+
qc.mcp(numpy.pi, q_controls, q_target)
|
1186
|
+
qc.h(q_target)
|
1187
|
+
self.definition = qc
|
1177
1188
|
|
1178
1189
|
@property
|
1179
1190
|
def num_ancilla_qubits(self):
|
@@ -1193,7 +1204,7 @@ class MCXGate(ControlledGate):
|
|
1193
1204
|
num_ctrl_qubits: number of control qubits.
|
1194
1205
|
label: An optional label for the gate [Default: ``None``]
|
1195
1206
|
ctrl_state: control state expressed as integer,
|
1196
|
-
string (e.g
|
1207
|
+
string (e.g. ``'110'``), or ``None``. If ``None``, use all 1s.
|
1197
1208
|
annotated: indicates whether the controlled gate can be implemented
|
1198
1209
|
as an annotated gate.
|
1199
1210
|
|
@@ -169,8 +169,10 @@ class XXMinusYYGate(Gate):
|
|
169
169
|
theta, beta = self.params
|
170
170
|
return XXMinusYYGate(-theta, beta)
|
171
171
|
|
172
|
-
def __array__(self, dtype=
|
172
|
+
def __array__(self, dtype=None, copy=None):
|
173
173
|
"""Gate matrix."""
|
174
|
+
if copy is False:
|
175
|
+
raise ValueError("unable to avoid copy while creating an array as requested")
|
174
176
|
theta, beta = self.params
|
175
177
|
cos = math.cos(theta / 2)
|
176
178
|
sin = math.sin(theta / 2)
|
@@ -184,8 +186,7 @@ class XXMinusYYGate(Gate):
|
|
184
186
|
dtype=dtype,
|
185
187
|
)
|
186
188
|
|
187
|
-
def power(self, exponent: float):
|
188
|
-
"""Raise gate to a power."""
|
189
|
+
def power(self, exponent: float, annotated: bool = False):
|
189
190
|
theta, beta = self.params
|
190
191
|
return XXMinusYYGate(exponent * theta, beta)
|
191
192
|
|
@@ -15,6 +15,9 @@ import math
|
|
15
15
|
from cmath import exp
|
16
16
|
from math import pi
|
17
17
|
from typing import Optional
|
18
|
+
|
19
|
+
import numpy
|
20
|
+
|
18
21
|
from qiskit.circuit.gate import Gate
|
19
22
|
from qiskit.circuit.quantumregister import QuantumRegister
|
20
23
|
from qiskit.circuit.parameterexpression import ParameterValueType
|
@@ -167,10 +170,10 @@ class XXPlusYYGate(Gate):
|
|
167
170
|
"""
|
168
171
|
return XXPlusYYGate(-self.params[0], self.params[1])
|
169
172
|
|
170
|
-
def __array__(self, dtype=
|
173
|
+
def __array__(self, dtype=None, copy=None):
|
171
174
|
"""Return a numpy.array for the XX+YY gate."""
|
172
|
-
|
173
|
-
|
175
|
+
if copy is False:
|
176
|
+
raise ValueError("unable to avoid copy while creating an array as requested")
|
174
177
|
half_theta = float(self.params[0]) / 2
|
175
178
|
beta = float(self.params[1])
|
176
179
|
cos = math.cos(half_theta)
|
@@ -185,8 +188,7 @@ class XXPlusYYGate(Gate):
|
|
185
188
|
dtype=dtype,
|
186
189
|
)
|
187
190
|
|
188
|
-
def power(self, exponent: float):
|
189
|
-
"""Raise gate to a power."""
|
191
|
+
def power(self, exponent: float, annotated: bool = False):
|
190
192
|
theta, beta = self.params
|
191
193
|
return XXPlusYYGate(exponent * theta, beta)
|
192
194
|
|
@@ -140,8 +140,7 @@ class ZGate(SingletonGate):
|
|
140
140
|
"""
|
141
141
|
return ZGate() # self-inverse
|
142
142
|
|
143
|
-
def power(self, exponent: float):
|
144
|
-
"""Raise gate to a power."""
|
143
|
+
def power(self, exponent: float, annotated: bool = False):
|
145
144
|
return PhaseGate(numpy.pi * exponent)
|
146
145
|
|
147
146
|
def __eq__(self, other):
|
qiskit/circuit/measure.py
CHANGED
@@ -22,7 +22,10 @@ class Measure(SingletonInstruction):
|
|
22
22
|
"""Quantum measurement in the computational basis."""
|
23
23
|
|
24
24
|
def __init__(self, label=None, *, duration=None, unit="dt"):
|
25
|
-
"""
|
25
|
+
"""
|
26
|
+
Args:
|
27
|
+
label: optional string label for this instruction.
|
28
|
+
"""
|
26
29
|
super().__init__("measure", 1, 1, [], label=label, duration=duration, unit=unit)
|
27
30
|
|
28
31
|
_singleton_lookup_key = stdlib_singleton_key()
|
qiskit/circuit/operation.py
CHANGED
@@ -16,17 +16,22 @@ from abc import ABC, abstractmethod
|
|
16
16
|
|
17
17
|
|
18
18
|
class Operation(ABC):
|
19
|
-
"""Quantum
|
20
|
-
|
21
|
-
|
22
|
-
:class
|
23
|
-
|
24
|
-
|
25
|
-
:class:`~qiskit.circuit.
|
19
|
+
"""Quantum operation interface.
|
20
|
+
|
21
|
+
The minimal interface that any object must fulfil in order to be added to a
|
22
|
+
:class:`.QuantumCircuit`.
|
23
|
+
|
24
|
+
Concrete instances of this interface include :class:`~qiskit.circuit.Gate`,
|
25
|
+
:class:`~qiskit.circuit.Reset`, :class:`~qiskit.circuit.Barrier`,
|
26
|
+
:class:`~qiskit.circuit.Measure`, and operators such as :class:`~qiskit.quantum_info.Clifford`.
|
27
|
+
|
28
|
+
The main purpose is to add allow abstract mathematical objects to be added directly onto
|
29
|
+
abstract circuits, and for the exact syntheses of these to be determined later, during
|
30
|
+
compilation.
|
26
31
|
|
27
32
|
Example:
|
28
33
|
|
29
|
-
Add a Clifford and a Toffoli gate to a QuantumCircuit
|
34
|
+
Add a Clifford and a Toffoli gate to a :class:`QuantumCircuit`.
|
30
35
|
|
31
36
|
.. plot::
|
32
37
|
:include-source:
|
qiskit/circuit/parameter.py
CHANGED
@@ -25,10 +25,16 @@ from .parameterexpression import ParameterExpression
|
|
25
25
|
|
26
26
|
|
27
27
|
class Parameter(ParameterExpression):
|
28
|
-
"""
|
28
|
+
"""A compile-time symbolic parameter.
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
The value of a :class:`Parameter` must be entirely determined before a circuit begins execution.
|
31
|
+
Typically this will mean that you should supply values for all :class:`Parameter`\\ s in a
|
32
|
+
circuit using :meth:`.QuantumCircuit.assign_parameters`, though certain hardware vendors may
|
33
|
+
allow you to give them a circuit in terms of these parameters, provided you also pass the values
|
34
|
+
separately.
|
35
|
+
|
36
|
+
This is the atom of :class:`.ParameterExpression`, and is itself an expression. The numeric
|
37
|
+
value of a parameter need not be fixed while the circuit is being defined.
|
32
38
|
|
33
39
|
Examples:
|
34
40
|
|
@@ -62,11 +68,10 @@ class Parameter(ParameterExpression):
|
|
62
68
|
def __init__(
|
63
69
|
self, name: str, *, uuid: UUID | None = None
|
64
70
|
): # pylint: disable=super-init-not-called
|
65
|
-
"""
|
66
|
-
|
71
|
+
"""
|
67
72
|
Args:
|
68
73
|
name: name of the ``Parameter``, used for visual representation. This can
|
69
|
-
be any
|
74
|
+
be any Unicode string, e.g. "ϕ".
|
70
75
|
uuid: For advanced usage only. Override the UUID of this parameter, in order to make it
|
71
76
|
compare equal to some other parameter object. By default, two parameters with the
|
72
77
|
same name do not compare equal to help catch shadowing bugs when two circuits
|