qiskit 1.4.2__cp39-abi3-macosx_11_0_arm64.whl → 2.0.0__cp39-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.
Files changed (459) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +3 -9
  3. qiskit/_accelerate.abi3.so +0 -0
  4. qiskit/circuit/__init__.py +35 -10
  5. qiskit/circuit/{add_control.py → _add_control.py} +32 -12
  6. qiskit/circuit/_classical_resource_map.py +5 -3
  7. qiskit/circuit/barrier.py +3 -7
  8. qiskit/circuit/classical/expr/__init__.py +31 -3
  9. qiskit/circuit/classical/expr/constructors.py +236 -28
  10. qiskit/circuit/classical/expr/expr.py +104 -3
  11. qiskit/circuit/classical/expr/visitors.py +75 -0
  12. qiskit/circuit/classical/types/__init__.py +12 -8
  13. qiskit/circuit/classical/types/ordering.py +14 -7
  14. qiskit/circuit/classical/types/types.py +36 -0
  15. qiskit/circuit/commutation_checker.py +34 -7
  16. qiskit/circuit/controlflow/__init__.py +32 -1
  17. qiskit/circuit/controlflow/_builder_utils.py +9 -5
  18. qiskit/circuit/controlflow/box.py +163 -0
  19. qiskit/circuit/controlflow/break_loop.py +1 -1
  20. qiskit/circuit/controlflow/builder.py +139 -39
  21. qiskit/circuit/controlflow/continue_loop.py +1 -3
  22. qiskit/circuit/controlflow/control_flow.py +10 -0
  23. qiskit/circuit/controlflow/for_loop.py +2 -1
  24. qiskit/circuit/controlflow/if_else.py +3 -16
  25. qiskit/circuit/controlflow/switch_case.py +2 -8
  26. qiskit/circuit/controlflow/while_loop.py +2 -7
  27. qiskit/circuit/controlledgate.py +2 -4
  28. qiskit/circuit/delay.py +40 -11
  29. qiskit/circuit/duration.py +0 -15
  30. qiskit/circuit/gate.py +2 -4
  31. qiskit/circuit/instruction.py +2 -141
  32. qiskit/circuit/instructionset.py +7 -54
  33. qiskit/circuit/library/__init__.py +469 -154
  34. qiskit/circuit/library/arithmetic/__init__.py +16 -10
  35. qiskit/circuit/library/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
  36. qiskit/circuit/library/arithmetic/adders/draper_qft_adder.py +2 -2
  37. qiskit/circuit/library/arithmetic/adders/vbe_ripple_carry_adder.py +1 -1
  38. qiskit/circuit/library/arithmetic/exact_reciprocal.py +64 -21
  39. qiskit/circuit/library/arithmetic/integer_comparator.py +37 -80
  40. qiskit/circuit/library/arithmetic/linear_amplitude_function.py +169 -2
  41. qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +59 -5
  42. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +154 -6
  43. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +114 -4
  44. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +191 -15
  45. qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +93 -39
  46. qiskit/circuit/library/arithmetic/quadratic_form.py +168 -2
  47. qiskit/circuit/library/arithmetic/weighted_adder.py +73 -1
  48. qiskit/circuit/library/bit_flip_oracle.py +130 -0
  49. qiskit/circuit/library/blueprintcircuit.py +52 -16
  50. qiskit/circuit/library/data_preparation/initializer.py +1 -1
  51. qiskit/circuit/library/data_preparation/pauli_feature_map.py +4 -4
  52. qiskit/circuit/library/data_preparation/state_preparation.py +1 -1
  53. qiskit/circuit/library/generalized_gates/gms.py +1 -1
  54. qiskit/circuit/library/generalized_gates/isometry.py +1 -1
  55. qiskit/circuit/library/generalized_gates/pauli.py +1 -2
  56. qiskit/circuit/library/generalized_gates/uc.py +97 -7
  57. qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +1 -1
  58. qiskit/circuit/library/generalized_gates/unitary.py +4 -2
  59. qiskit/circuit/library/graph_state.py +1 -0
  60. qiskit/circuit/library/hamiltonian_gate.py +1 -1
  61. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +1 -1
  62. qiskit/circuit/library/n_local/n_local.py +1 -1
  63. qiskit/circuit/library/n_local/qaoa_ansatz.py +1 -1
  64. qiskit/circuit/library/overlap.py +2 -2
  65. qiskit/circuit/library/pauli_evolution.py +39 -24
  66. qiskit/circuit/library/phase_oracle.py +130 -51
  67. qiskit/circuit/library/standard_gates/__init__.py +0 -1
  68. qiskit/circuit/library/standard_gates/dcx.py +3 -4
  69. qiskit/circuit/library/standard_gates/ecr.py +3 -4
  70. qiskit/circuit/library/standard_gates/global_phase.py +5 -6
  71. qiskit/circuit/library/standard_gates/h.py +4 -9
  72. qiskit/circuit/library/standard_gates/i.py +2 -2
  73. qiskit/circuit/library/standard_gates/iswap.py +3 -4
  74. qiskit/circuit/library/standard_gates/p.py +15 -34
  75. qiskit/circuit/library/standard_gates/r.py +7 -10
  76. qiskit/circuit/library/standard_gates/rx.py +5 -15
  77. qiskit/circuit/library/standard_gates/rxx.py +3 -6
  78. qiskit/circuit/library/standard_gates/ry.py +5 -17
  79. qiskit/circuit/library/standard_gates/ryy.py +3 -6
  80. qiskit/circuit/library/standard_gates/rz.py +5 -17
  81. qiskit/circuit/library/standard_gates/rzx.py +3 -6
  82. qiskit/circuit/library/standard_gates/rzz.py +3 -6
  83. qiskit/circuit/library/standard_gates/s.py +6 -15
  84. qiskit/circuit/library/standard_gates/swap.py +4 -11
  85. qiskit/circuit/library/standard_gates/sx.py +7 -12
  86. qiskit/circuit/library/standard_gates/t.py +6 -7
  87. qiskit/circuit/library/standard_gates/u.py +2 -10
  88. qiskit/circuit/library/standard_gates/u1.py +5 -16
  89. qiskit/circuit/library/standard_gates/u2.py +2 -6
  90. qiskit/circuit/library/standard_gates/u3.py +3 -11
  91. qiskit/circuit/library/standard_gates/x.py +14 -62
  92. qiskit/circuit/library/standard_gates/xx_minus_yy.py +2 -5
  93. qiskit/circuit/library/standard_gates/xx_plus_yy.py +2 -5
  94. qiskit/circuit/library/standard_gates/y.py +4 -9
  95. qiskit/circuit/library/standard_gates/z.py +5 -15
  96. qiskit/circuit/measure.py +11 -2
  97. qiskit/circuit/parameterexpression.py +7 -1
  98. qiskit/circuit/quantumcircuit.py +890 -564
  99. qiskit/circuit/random/utils.py +12 -6
  100. qiskit/circuit/reset.py +5 -2
  101. qiskit/circuit/singleton.py +5 -11
  102. qiskit/circuit/store.py +0 -8
  103. qiskit/compiler/__init__.py +1 -7
  104. qiskit/compiler/transpiler.py +38 -196
  105. qiskit/converters/circuit_to_dag.py +6 -4
  106. qiskit/converters/circuit_to_dagdependency.py +0 -2
  107. qiskit/converters/circuit_to_dagdependency_v2.py +0 -1
  108. qiskit/converters/circuit_to_gate.py +1 -1
  109. qiskit/converters/circuit_to_instruction.py +16 -29
  110. qiskit/converters/dag_to_circuit.py +7 -8
  111. qiskit/converters/dag_to_dagdependency.py +0 -1
  112. qiskit/converters/dag_to_dagdependency_v2.py +0 -1
  113. qiskit/converters/dagdependency_to_circuit.py +0 -6
  114. qiskit/converters/dagdependency_to_dag.py +0 -6
  115. qiskit/dagcircuit/collect_blocks.py +32 -20
  116. qiskit/dagcircuit/dagdependency.py +3 -37
  117. qiskit/dagcircuit/dagdependency_v2.py +5 -82
  118. qiskit/dagcircuit/dagnode.py +14 -2
  119. qiskit/passmanager/__init__.py +24 -6
  120. qiskit/passmanager/passmanager.py +26 -24
  121. qiskit/primitives/__init__.py +44 -35
  122. qiskit/primitives/backend_estimator_v2.py +102 -23
  123. qiskit/primitives/backend_sampler_v2.py +5 -20
  124. qiskit/primitives/base/__init__.py +4 -4
  125. qiskit/primitives/base/base_estimator.py +77 -82
  126. qiskit/primitives/base/base_primitive_job.py +2 -2
  127. qiskit/primitives/base/{base_primitive.py → base_primitive_v1.py} +1 -1
  128. qiskit/primitives/base/{base_result.py → base_result_v1.py} +1 -1
  129. qiskit/primitives/base/base_sampler.py +52 -60
  130. qiskit/primitives/base/{estimator_result.py → estimator_result_v1.py} +2 -2
  131. qiskit/primitives/base/{sampler_result.py → sampler_result_v1.py} +2 -2
  132. qiskit/primitives/base/{validation.py → validation_v1.py} +34 -15
  133. qiskit/primitives/containers/bindings_array.py +3 -1
  134. qiskit/primitives/containers/bit_array.py +23 -0
  135. qiskit/primitives/containers/data_bin.py +3 -1
  136. qiskit/primitives/containers/observables_array.py +19 -2
  137. qiskit/primitives/statevector_sampler.py +6 -8
  138. qiskit/primitives/utils.py +14 -189
  139. qiskit/providers/__init__.py +4 -130
  140. qiskit/providers/backend.py +11 -314
  141. qiskit/providers/basic_provider/__init__.py +3 -1
  142. qiskit/providers/basic_provider/basic_provider.py +29 -9
  143. qiskit/providers/basic_provider/basic_simulator.py +158 -298
  144. qiskit/providers/exceptions.py +0 -33
  145. qiskit/providers/fake_provider/__init__.py +0 -37
  146. qiskit/providers/fake_provider/generic_backend_v2.py +32 -693
  147. qiskit/qasm2/__init__.py +21 -6
  148. qiskit/qasm2/export.py +2 -10
  149. qiskit/qasm2/parse.py +11 -25
  150. qiskit/qasm3/__init__.py +5 -1
  151. qiskit/qasm3/ast.py +44 -0
  152. qiskit/qasm3/exporter.py +65 -27
  153. qiskit/qasm3/printer.py +35 -4
  154. qiskit/qpy/__init__.py +162 -19
  155. qiskit/qpy/binary_io/__init__.py +0 -1
  156. qiskit/qpy/binary_io/circuits.py +98 -130
  157. qiskit/qpy/binary_io/schedules.py +69 -439
  158. qiskit/qpy/binary_io/value.py +154 -31
  159. qiskit/qpy/common.py +10 -7
  160. qiskit/qpy/formats.py +41 -0
  161. qiskit/qpy/interface.py +34 -81
  162. qiskit/qpy/type_keys.py +58 -221
  163. qiskit/quantum_info/analysis/distance.py +3 -1
  164. qiskit/quantum_info/operators/dihedral/dihedral.py +3 -1
  165. qiskit/quantum_info/operators/operator.py +6 -2
  166. qiskit/quantum_info/operators/symplectic/clifford.py +3 -1
  167. qiskit/quantum_info/operators/symplectic/pauli.py +4 -2
  168. qiskit/quantum_info/operators/symplectic/pauli_list.py +17 -5
  169. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +40 -6
  170. qiskit/quantum_info/states/densitymatrix.py +16 -6
  171. qiskit/quantum_info/states/stabilizerstate.py +35 -4
  172. qiskit/quantum_info/states/statevector.py +16 -6
  173. qiskit/result/__init__.py +5 -17
  174. qiskit/result/models.py +18 -11
  175. qiskit/result/result.py +38 -134
  176. qiskit/result/sampled_expval.py +1 -2
  177. qiskit/result/utils.py +3 -4
  178. qiskit/synthesis/__init__.py +21 -1
  179. qiskit/synthesis/arithmetic/__init__.py +3 -1
  180. qiskit/synthesis/arithmetic/adders/cdkm_ripple_carry_adder.py +1 -1
  181. qiskit/synthesis/arithmetic/adders/draper_qft_adder.py +1 -1
  182. qiskit/synthesis/arithmetic/adders/vbe_ripple_carry_adder.py +2 -2
  183. qiskit/{providers/fake_provider/backends_v1/fake_20q → synthesis/arithmetic/comparators}/__init__.py +4 -6
  184. qiskit/synthesis/arithmetic/comparators/compare_2s.py +112 -0
  185. qiskit/synthesis/arithmetic/comparators/compare_greedy.py +66 -0
  186. qiskit/synthesis/arithmetic/multipliers/hrs_cumulative_multiplier.py +1 -1
  187. qiskit/synthesis/arithmetic/multipliers/rg_qft_multiplier.py +1 -1
  188. qiskit/synthesis/arithmetic/weighted_sum.py +155 -0
  189. qiskit/{result/mitigation → synthesis/boolean}/__init__.py +2 -2
  190. qiskit/synthesis/boolean/boolean_expression.py +231 -0
  191. qiskit/synthesis/boolean/boolean_expression_synth.py +124 -0
  192. qiskit/synthesis/boolean/boolean_expression_visitor.py +96 -0
  193. qiskit/synthesis/evolution/lie_trotter.py +10 -7
  194. qiskit/synthesis/evolution/product_formula.py +44 -35
  195. qiskit/synthesis/evolution/qdrift.py +17 -24
  196. qiskit/synthesis/evolution/suzuki_trotter.py +20 -27
  197. qiskit/synthesis/linear/linear_depth_lnn.py +6 -221
  198. qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +4 -205
  199. qiskit/synthesis/multi_controlled/__init__.py +1 -0
  200. qiskit/synthesis/multi_controlled/mcx_synthesis.py +5 -2
  201. qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py +206 -0
  202. qiskit/synthesis/one_qubit/one_qubit_decompose.py +1 -1
  203. qiskit/synthesis/two_qubit/__init__.py +1 -0
  204. qiskit/synthesis/two_qubit/two_qubit_decompose.py +28 -145
  205. qiskit/transpiler/__init__.py +32 -232
  206. qiskit/transpiler/basepasses.py +20 -51
  207. qiskit/transpiler/layout.py +1 -1
  208. qiskit/transpiler/passes/__init__.py +4 -40
  209. qiskit/transpiler/passes/basis/basis_translator.py +5 -4
  210. qiskit/transpiler/passes/basis/decompose.py +1 -15
  211. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -5
  212. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +3 -2
  213. qiskit/transpiler/passes/layout/apply_layout.py +4 -0
  214. qiskit/transpiler/passes/layout/dense_layout.py +2 -39
  215. qiskit/transpiler/passes/layout/full_ancilla_allocation.py +3 -4
  216. qiskit/transpiler/passes/layout/sabre_layout.py +7 -3
  217. qiskit/transpiler/passes/layout/vf2_layout.py +2 -20
  218. qiskit/transpiler/passes/layout/vf2_post_layout.py +60 -125
  219. qiskit/transpiler/passes/layout/vf2_utils.py +2 -26
  220. qiskit/transpiler/passes/optimization/__init__.py +2 -3
  221. qiskit/transpiler/passes/optimization/collect_and_collapse.py +2 -0
  222. qiskit/transpiler/passes/optimization/collect_cliffords.py +5 -0
  223. qiskit/transpiler/passes/optimization/collect_linear_functions.py +5 -0
  224. qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +16 -1
  225. qiskit/transpiler/passes/optimization/commutation_analysis.py +3 -3
  226. qiskit/transpiler/passes/optimization/consolidate_blocks.py +41 -19
  227. qiskit/transpiler/passes/optimization/contract_idle_wires_in_control_flow.py +104 -0
  228. qiskit/transpiler/passes/optimization/light_cone.py +135 -0
  229. qiskit/transpiler/passes/optimization/optimize_1q_commutation.py +0 -1
  230. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +18 -22
  231. qiskit/transpiler/passes/optimization/optimize_annotated.py +3 -2
  232. qiskit/transpiler/passes/optimization/remove_identity_equiv.py +6 -4
  233. qiskit/transpiler/passes/optimization/reset_after_measure_simplification.py +5 -2
  234. qiskit/transpiler/passes/optimization/split_2q_unitaries.py +26 -3
  235. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -0
  236. qiskit/transpiler/passes/routing/__init__.py +0 -1
  237. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -1
  238. qiskit/transpiler/passes/routing/sabre_swap.py +14 -6
  239. qiskit/transpiler/passes/routing/star_prerouting.py +1 -1
  240. qiskit/transpiler/passes/scheduling/__init__.py +1 -7
  241. qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -4
  242. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -9
  243. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +17 -16
  244. qiskit/transpiler/passes/scheduling/padding/base_padding.py +32 -4
  245. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +25 -63
  246. qiskit/transpiler/passes/scheduling/padding/pad_delay.py +12 -4
  247. qiskit/transpiler/passes/scheduling/scheduling/alap.py +5 -39
  248. qiskit/transpiler/passes/scheduling/scheduling/asap.py +4 -35
  249. qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +10 -16
  250. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +134 -62
  251. qiskit/transpiler/passes/synthesis/default_unitary_synth_plugin.py +653 -0
  252. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +176 -601
  253. qiskit/transpiler/passes/synthesis/hls_plugins.py +294 -1
  254. qiskit/transpiler/passes/synthesis/plugin.py +4 -0
  255. qiskit/transpiler/passes/synthesis/solovay_kitaev_synthesis.py +16 -10
  256. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +34 -697
  257. qiskit/transpiler/passes/utils/__init__.py +0 -1
  258. qiskit/transpiler/passes/utils/check_gate_direction.py +13 -5
  259. qiskit/transpiler/passes/utils/control_flow.py +2 -6
  260. qiskit/transpiler/passes/utils/gate_direction.py +7 -0
  261. qiskit/transpiler/passes/utils/remove_final_measurements.py +40 -33
  262. qiskit/transpiler/passmanager.py +13 -0
  263. qiskit/transpiler/passmanager_config.py +5 -81
  264. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +225 -344
  265. qiskit/transpiler/preset_passmanagers/common.py +140 -167
  266. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +107 -322
  267. qiskit/transpiler/preset_passmanagers/level0.py +2 -11
  268. qiskit/transpiler/preset_passmanagers/level1.py +2 -14
  269. qiskit/transpiler/preset_passmanagers/level2.py +2 -12
  270. qiskit/transpiler/preset_passmanagers/level3.py +2 -11
  271. qiskit/transpiler/preset_passmanagers/plugin.py +5 -3
  272. qiskit/transpiler/target.py +78 -524
  273. qiskit/user_config.py +8 -4
  274. qiskit/utils/__init__.py +13 -12
  275. qiskit/utils/deprecation.py +4 -112
  276. qiskit/utils/optionals.py +11 -4
  277. qiskit/utils/parallel.py +214 -87
  278. qiskit/utils/units.py +4 -1
  279. qiskit/visualization/__init__.py +3 -7
  280. qiskit/visualization/array.py +4 -1
  281. qiskit/visualization/bloch.py +1 -1
  282. qiskit/visualization/circuit/_utils.py +19 -19
  283. qiskit/visualization/circuit/circuit_visualization.py +11 -4
  284. qiskit/visualization/circuit/matplotlib.py +13 -23
  285. qiskit/visualization/circuit/text.py +7 -3
  286. qiskit/visualization/counts_visualization.py +4 -0
  287. qiskit/visualization/dag_visualization.py +2 -1
  288. qiskit/visualization/gate_map.py +39 -154
  289. qiskit/visualization/library.py +4 -1
  290. qiskit/visualization/pass_manager_visualization.py +6 -2
  291. qiskit/visualization/state_visualization.py +19 -2
  292. qiskit/visualization/timeline/core.py +19 -13
  293. qiskit/visualization/timeline/interface.py +19 -18
  294. qiskit/visualization/timeline/plotters/matplotlib.py +4 -1
  295. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/METADATA +4 -3
  296. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/RECORD +300 -447
  297. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/WHEEL +2 -1
  298. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/entry_points.txt +8 -2
  299. qiskit/assembler/__init__.py +0 -42
  300. qiskit/assembler/assemble_circuits.py +0 -451
  301. qiskit/assembler/assemble_schedules.py +0 -367
  302. qiskit/assembler/disassemble.py +0 -310
  303. qiskit/assembler/run_config.py +0 -77
  304. qiskit/circuit/bit.py +0 -106
  305. qiskit/circuit/classicalfunction/__init__.py +0 -152
  306. qiskit/circuit/classicalfunction/boolean_expression.py +0 -138
  307. qiskit/circuit/classicalfunction/classical_element.py +0 -54
  308. qiskit/circuit/classicalfunction/classical_function_visitor.py +0 -155
  309. qiskit/circuit/classicalfunction/classicalfunction.py +0 -182
  310. qiskit/circuit/classicalfunction/exceptions.py +0 -41
  311. qiskit/circuit/classicalfunction/types.py +0 -18
  312. qiskit/circuit/classicalfunction/utils.py +0 -91
  313. qiskit/circuit/classicalregister.py +0 -57
  314. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +0 -405
  315. qiskit/circuit/quantumregister.py +0 -75
  316. qiskit/circuit/register.py +0 -246
  317. qiskit/compiler/assembler.py +0 -689
  318. qiskit/compiler/scheduler.py +0 -109
  319. qiskit/compiler/sequencer.py +0 -71
  320. qiskit/primitives/backend_estimator.py +0 -486
  321. qiskit/primitives/backend_sampler.py +0 -222
  322. qiskit/primitives/estimator.py +0 -172
  323. qiskit/primitives/sampler.py +0 -162
  324. qiskit/providers/backend_compat.py +0 -507
  325. qiskit/providers/fake_provider/backends_v1/__init__.py +0 -22
  326. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/__init__.py +0 -18
  327. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/conf_washington.json +0 -1
  328. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/defs_washington.json +0 -1
  329. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/fake_127q_pulse_v1.py +0 -37
  330. qiskit/providers/fake_provider/backends_v1/fake_127q_pulse/props_washington.json +0 -1
  331. qiskit/providers/fake_provider/backends_v1/fake_20q/conf_singapore.json +0 -1
  332. qiskit/providers/fake_provider/backends_v1/fake_20q/fake_20q.py +0 -43
  333. qiskit/providers/fake_provider/backends_v1/fake_20q/props_singapore.json +0 -1
  334. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/__init__.py +0 -18
  335. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/conf_hanoi.json +0 -1
  336. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/defs_hanoi.json +0 -1
  337. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/fake_27q_pulse_v1.py +0 -50
  338. qiskit/providers/fake_provider/backends_v1/fake_27q_pulse/props_hanoi.json +0 -1
  339. qiskit/providers/fake_provider/backends_v1/fake_5q/__init__.py +0 -18
  340. qiskit/providers/fake_provider/backends_v1/fake_5q/conf_yorktown.json +0 -1
  341. qiskit/providers/fake_provider/backends_v1/fake_5q/fake_5q_v1.py +0 -41
  342. qiskit/providers/fake_provider/backends_v1/fake_5q/props_yorktown.json +0 -1
  343. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/__init__.py +0 -18
  344. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/conf_nairobi.json +0 -1
  345. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/defs_nairobi.json +0 -1
  346. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/fake_7q_pulse_v1.py +0 -44
  347. qiskit/providers/fake_provider/backends_v1/fake_7q_pulse/props_nairobi.json +0 -1
  348. qiskit/providers/fake_provider/fake_1q.py +0 -91
  349. qiskit/providers/fake_provider/fake_backend.py +0 -165
  350. qiskit/providers/fake_provider/fake_openpulse_2q.py +0 -391
  351. qiskit/providers/fake_provider/fake_openpulse_3q.py +0 -340
  352. qiskit/providers/fake_provider/fake_pulse_backend.py +0 -49
  353. qiskit/providers/fake_provider/fake_qasm_backend.py +0 -77
  354. qiskit/providers/fake_provider/utils/backend_converter.py +0 -150
  355. qiskit/providers/fake_provider/utils/json_decoder.py +0 -109
  356. qiskit/providers/models/__init__.py +0 -89
  357. qiskit/providers/models/backendconfiguration.py +0 -1040
  358. qiskit/providers/models/backendproperties.py +0 -535
  359. qiskit/providers/models/backendstatus.py +0 -104
  360. qiskit/providers/models/jobstatus.py +0 -77
  361. qiskit/providers/models/pulsedefaults.py +0 -305
  362. qiskit/providers/provider.py +0 -95
  363. qiskit/pulse/__init__.py +0 -158
  364. qiskit/pulse/builder.py +0 -2262
  365. qiskit/pulse/calibration_entries.py +0 -381
  366. qiskit/pulse/channels.py +0 -227
  367. qiskit/pulse/configuration.py +0 -245
  368. qiskit/pulse/exceptions.py +0 -45
  369. qiskit/pulse/filters.py +0 -309
  370. qiskit/pulse/instruction_schedule_map.py +0 -424
  371. qiskit/pulse/instructions/__init__.py +0 -67
  372. qiskit/pulse/instructions/acquire.py +0 -150
  373. qiskit/pulse/instructions/delay.py +0 -71
  374. qiskit/pulse/instructions/directives.py +0 -154
  375. qiskit/pulse/instructions/frequency.py +0 -135
  376. qiskit/pulse/instructions/instruction.py +0 -270
  377. qiskit/pulse/instructions/phase.py +0 -152
  378. qiskit/pulse/instructions/play.py +0 -99
  379. qiskit/pulse/instructions/reference.py +0 -100
  380. qiskit/pulse/instructions/snapshot.py +0 -82
  381. qiskit/pulse/library/__init__.py +0 -97
  382. qiskit/pulse/library/continuous.py +0 -430
  383. qiskit/pulse/library/pulse.py +0 -148
  384. qiskit/pulse/library/samplers/__init__.py +0 -15
  385. qiskit/pulse/library/samplers/decorators.py +0 -295
  386. qiskit/pulse/library/samplers/strategies.py +0 -71
  387. qiskit/pulse/library/symbolic_pulses.py +0 -1989
  388. qiskit/pulse/library/waveform.py +0 -136
  389. qiskit/pulse/macros.py +0 -262
  390. qiskit/pulse/parameter_manager.py +0 -445
  391. qiskit/pulse/parser.py +0 -314
  392. qiskit/pulse/reference_manager.py +0 -58
  393. qiskit/pulse/schedule.py +0 -1854
  394. qiskit/pulse/transforms/__init__.py +0 -106
  395. qiskit/pulse/transforms/alignments.py +0 -406
  396. qiskit/pulse/transforms/base_transforms.py +0 -71
  397. qiskit/pulse/transforms/canonicalization.py +0 -498
  398. qiskit/pulse/transforms/dag.py +0 -122
  399. qiskit/pulse/utils.py +0 -149
  400. qiskit/qobj/__init__.py +0 -75
  401. qiskit/qobj/common.py +0 -81
  402. qiskit/qobj/converters/__init__.py +0 -18
  403. qiskit/qobj/converters/lo_config.py +0 -177
  404. qiskit/qobj/converters/pulse_instruction.py +0 -897
  405. qiskit/qobj/pulse_qobj.py +0 -709
  406. qiskit/qobj/qasm_qobj.py +0 -708
  407. qiskit/qobj/utils.py +0 -46
  408. qiskit/result/mitigation/base_readout_mitigator.py +0 -79
  409. qiskit/result/mitigation/correlated_readout_mitigator.py +0 -277
  410. qiskit/result/mitigation/local_readout_mitigator.py +0 -328
  411. qiskit/result/mitigation/utils.py +0 -217
  412. qiskit/scheduler/__init__.py +0 -40
  413. qiskit/scheduler/config.py +0 -37
  414. qiskit/scheduler/lowering.py +0 -187
  415. qiskit/scheduler/methods/__init__.py +0 -15
  416. qiskit/scheduler/methods/basic.py +0 -140
  417. qiskit/scheduler/schedule_circuit.py +0 -69
  418. qiskit/scheduler/sequence.py +0 -104
  419. qiskit/transpiler/passes/calibration/__init__.py +0 -17
  420. qiskit/transpiler/passes/calibration/base_builder.py +0 -79
  421. qiskit/transpiler/passes/calibration/builders.py +0 -20
  422. qiskit/transpiler/passes/calibration/exceptions.py +0 -22
  423. qiskit/transpiler/passes/calibration/pulse_gate.py +0 -100
  424. qiskit/transpiler/passes/calibration/rx_builder.py +0 -164
  425. qiskit/transpiler/passes/calibration/rzx_builder.py +0 -411
  426. qiskit/transpiler/passes/calibration/rzx_templates.py +0 -58
  427. qiskit/transpiler/passes/optimization/cx_cancellation.py +0 -65
  428. qiskit/transpiler/passes/optimization/echo_rzx_weyl_decomposition.py +0 -162
  429. qiskit/transpiler/passes/optimization/normalize_rx_angle.py +0 -157
  430. qiskit/transpiler/passes/routing/stochastic_swap.py +0 -532
  431. qiskit/transpiler/passes/scheduling/alap.py +0 -153
  432. qiskit/transpiler/passes/scheduling/alignments/align_measures.py +0 -255
  433. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +0 -107
  434. qiskit/transpiler/passes/scheduling/asap.py +0 -175
  435. qiskit/transpiler/passes/scheduling/base_scheduler.py +0 -310
  436. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +0 -313
  437. qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +0 -93
  438. qiskit/utils/deprecate_pulse.py +0 -119
  439. qiskit/utils/multiprocessing.py +0 -56
  440. qiskit/visualization/pulse_v2/__init__.py +0 -21
  441. qiskit/visualization/pulse_v2/core.py +0 -901
  442. qiskit/visualization/pulse_v2/device_info.py +0 -173
  443. qiskit/visualization/pulse_v2/drawings.py +0 -253
  444. qiskit/visualization/pulse_v2/events.py +0 -254
  445. qiskit/visualization/pulse_v2/generators/__init__.py +0 -40
  446. qiskit/visualization/pulse_v2/generators/barrier.py +0 -76
  447. qiskit/visualization/pulse_v2/generators/chart.py +0 -208
  448. qiskit/visualization/pulse_v2/generators/frame.py +0 -436
  449. qiskit/visualization/pulse_v2/generators/snapshot.py +0 -133
  450. qiskit/visualization/pulse_v2/generators/waveform.py +0 -645
  451. qiskit/visualization/pulse_v2/interface.py +0 -459
  452. qiskit/visualization/pulse_v2/layouts.py +0 -387
  453. qiskit/visualization/pulse_v2/plotters/__init__.py +0 -17
  454. qiskit/visualization/pulse_v2/plotters/base_plotter.py +0 -53
  455. qiskit/visualization/pulse_v2/plotters/matplotlib.py +0 -201
  456. qiskit/visualization/pulse_v2/stylesheet.py +0 -312
  457. qiskit/visualization/pulse_v2/types.py +0 -242
  458. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info/licenses}/LICENSE.txt +0 -0
  459. {qiskit-1.4.2.dist-info → qiskit-2.0.0.dist-info}/top_level.txt +0 -0
@@ -1,173 +0,0 @@
1
- # This code is part of Qiskit.
2
- #
3
- # (C) Copyright IBM 2020.
4
- #
5
- # This code is licensed under the Apache License, Version 2.0. You may
6
- # obtain a copy of this license in the LICENSE.txt file in the root directory
7
- # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
- #
9
- # Any modifications or derivative works of this code must retain this
10
- # copyright notice, and modified files need to carry a notice indicating
11
- # that they have been altered from the originals.
12
-
13
- """A collection of backend information formatted to generate drawing data.
14
-
15
- This instance will be provided to generator functions. The module provides an abstract
16
- class :py:class:``DrawerBackendInfo`` with necessary methods to generate drawing objects.
17
-
18
- Because the data structure of backend class may depend on providers, this abstract class
19
- has an abstract factory method `create_from_backend`. Each subclass should provide
20
- the factory method which conforms to the associated provider. By default we provide
21
- :py:class:``OpenPulseBackendInfo`` class that has the factory method taking backends
22
- satisfying OpenPulse specification [1].
23
-
24
- This class can be also initialized without the factory method by manually specifying
25
- required information. This may be convenient for visualizing a pulse program for simulator
26
- backend that only has a device Hamiltonian information. This requires two mapping objects
27
- for channel/qubit and channel/frequency along with the system cycle time.
28
-
29
- If those information are not provided, this class will be initialized with a set of
30
- empty data and the drawer illustrates a pulse program without any specific information.
31
-
32
- Reference:
33
- - [1] Qiskit Backend Specifications for OpenQASM and OpenPulse Experiments,
34
- https://arxiv.org/abs/1809.03452
35
- """
36
-
37
- from abc import ABC, abstractmethod
38
- from collections import defaultdict
39
- from typing import Dict, List, Union, Optional
40
-
41
- from qiskit import pulse
42
- from qiskit.providers import BackendConfigurationError
43
- from qiskit.providers.backend import Backend, BackendV2
44
-
45
-
46
- class DrawerBackendInfo(ABC):
47
- """Backend information to be used for the drawing data generation."""
48
-
49
- def __init__(
50
- self,
51
- name: Optional[str] = None,
52
- dt: Optional[float] = None,
53
- channel_frequency_map: Optional[Dict[pulse.channels.Channel, float]] = None,
54
- qubit_channel_map: Optional[Dict[int, List[pulse.channels.Channel]]] = None,
55
- ):
56
- """Create new backend information.
57
-
58
- Args:
59
- name: Name of the backend.
60
- dt: System cycle time.
61
- channel_frequency_map: Mapping of channel and associated frequency.
62
- qubit_channel_map: Mapping of qubit and associated channels.
63
- """
64
- self.backend_name = name or "no-backend"
65
- self._dt = dt
66
- self._chan_freq_map = channel_frequency_map or {}
67
- self._qubit_channel_map = qubit_channel_map or {}
68
-
69
- @classmethod
70
- @abstractmethod
71
- def create_from_backend(cls, backend: Backend):
72
- """Initialize a class with backend information provided by provider.
73
-
74
- Args:
75
- backend: Backend object.
76
- """
77
- raise NotImplementedError
78
-
79
- @property
80
- def dt(self):
81
- """Return cycle time."""
82
- return self._dt
83
-
84
- def get_qubit_index(self, chan: pulse.channels.Channel) -> Union[int, None]:
85
- """Get associated qubit index of given channel object."""
86
- for qind, chans in self._qubit_channel_map.items():
87
- if chan in chans:
88
- return qind
89
- return chan.index
90
-
91
- def get_channel_frequency(self, chan: pulse.channels.Channel) -> Union[float, None]:
92
- """Get frequency of given channel object."""
93
- return self._chan_freq_map.get(chan, None)
94
-
95
-
96
- class OpenPulseBackendInfo(DrawerBackendInfo):
97
- """Drawing information of backend that conforms to OpenPulse specification."""
98
-
99
- @classmethod
100
- def create_from_backend(cls, backend: Backend):
101
- """Initialize a class with backend information provided by provider.
102
-
103
- Args:
104
- backend: Backend object.
105
-
106
- Returns:
107
- OpenPulseBackendInfo: New configured instance.
108
- """
109
- chan_freqs = {}
110
- qubit_channel_map = defaultdict(list)
111
-
112
- if hasattr(backend, "configuration") and hasattr(backend, "defaults"):
113
- configuration = backend.configuration()
114
- defaults = backend.defaults()
115
-
116
- name = configuration.backend_name
117
- dt = configuration.dt
118
-
119
- # load frequencies
120
- chan_freqs.update(
121
- {
122
- pulse.DriveChannel(qind): freq
123
- for qind, freq in enumerate(defaults.qubit_freq_est)
124
- }
125
- )
126
- chan_freqs.update(
127
- {
128
- pulse.MeasureChannel(qind): freq
129
- for qind, freq in enumerate(defaults.meas_freq_est)
130
- }
131
- )
132
- for qind, u_lo_mappers in enumerate(configuration.u_channel_lo):
133
- temp_val = 0.0 + 0.0j
134
- for u_lo_mapper in u_lo_mappers:
135
- temp_val += defaults.qubit_freq_est[u_lo_mapper.q] * u_lo_mapper.scale
136
- chan_freqs[pulse.ControlChannel(qind)] = temp_val.real
137
-
138
- # load qubit channel mapping
139
- for qind in range(configuration.n_qubits):
140
- qubit_channel_map[qind].append(configuration.drive(qubit=qind))
141
- qubit_channel_map[qind].append(configuration.measure(qubit=qind))
142
- for tind in range(configuration.n_qubits):
143
- try:
144
- qubit_channel_map[qind].extend(configuration.control(qubits=(qind, tind)))
145
- except BackendConfigurationError:
146
- pass
147
- elif isinstance(backend, BackendV2):
148
- # Pure V2 model doesn't contain channel frequency information.
149
- name = backend.name
150
- dt = backend.dt
151
-
152
- # load qubit channel mapping
153
- for qind in range(backend.num_qubits):
154
- # channels are NotImplemented by default so we must catch arbitrary error.
155
- try:
156
- qubit_channel_map[qind].append(backend.drive_channel(qind))
157
- except Exception: # pylint: disable=broad-except
158
- pass
159
- try:
160
- qubit_channel_map[qind].append(backend.measure_channel(qind))
161
- except Exception: # pylint: disable=broad-except
162
- pass
163
- for tind in range(backend.num_qubits):
164
- try:
165
- qubit_channel_map[qind].extend(backend.control_channel(qubits=(qind, tind)))
166
- except Exception: # pylint: disable=broad-except
167
- pass
168
- else:
169
- raise RuntimeError("Backend object not yet supported")
170
-
171
- return OpenPulseBackendInfo(
172
- name=name, dt=dt, channel_frequency_map=chan_freqs, qubit_channel_map=qubit_channel_map
173
- )
@@ -1,253 +0,0 @@
1
- # This code is part of Qiskit.
2
- #
3
- # (C) Copyright IBM 2020.
4
- #
5
- # This code is licensed under the Apache License, Version 2.0. You may
6
- # obtain a copy of this license in the LICENSE.txt file in the root directory
7
- # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
- #
9
- # Any modifications or derivative works of this code must retain this
10
- # copyright notice, and modified files need to carry a notice indicating
11
- # that they have been altered from the originals.
12
-
13
- """
14
- Drawing objects for pulse drawer.
15
-
16
- Drawing objects play two important roles:
17
- - Allowing unittests of visualization module. Usually it is hard for image files to be tested.
18
- - Removing program parser from each plotter interface. We can easily add new plotter.
19
-
20
- This module is based on the structure of matplotlib as it is the primary plotter
21
- of the pulse drawer. However this interface is agnostic to the actual plotter.
22
-
23
- Design concept
24
- ~~~~~~~~~~~~~~
25
- When we think about dynamically updating drawings, it will be most efficient to
26
- update only the changed properties of drawings rather than regenerating entirely from scratch.
27
- Thus the core :py:class:`qiskit.visualization.pulse_v2.core.DrawerCanvas` generates
28
- all possible drawings in the beginning and then the canvas instance manages
29
- visibility of each drawing according to the end-user request.
30
-
31
- Data key
32
- ~~~~~~~~
33
- In the abstract class ``ElementaryData`` common attributes to represent a drawing are
34
- specified. In addition, drawings have the `data_key` property that returns an
35
- unique hash of the object for comparison.
36
- This key is generated from a data type and the location of the drawing in the canvas.
37
- See py:mod:`qiskit.visualization.pulse_v2.types` for detail on the data type.
38
- If a data key cannot distinguish two independent objects, you need to add a new data type.
39
- The data key may be used in the plotter interface to identify the object.
40
-
41
- Drawing objects
42
- ~~~~~~~~~~~~~~~
43
- To support not only `matplotlib` but also multiple plotters, those drawings should be
44
- universal and designed without strong dependency on modules in `matplotlib`.
45
- This means drawings that represent primitive geometries are preferred.
46
- It should be noted that there will be no unittest for each plotter API, which takes
47
- drawings and outputs image data, we should avoid adding a complicated geometry
48
- that has a context of the pulse program.
49
-
50
- For example, a pulse envelope is complex valued number array and may be represented
51
- by two lines with different colors associated with the real and the imaginary component.
52
- We can use two line-type objects rather than defining a new drawing that takes
53
- complex value. As many plotters don't support an API that visualizes complex-valued
54
- data arrays, if we introduced such a drawing and wrote a custom wrapper function
55
- on top of the existing API, it could be difficult to prevent bugs with the CI tools
56
- due to lack of the effective unittest.
57
- """
58
- from __future__ import annotations
59
-
60
- from abc import ABC
61
- from enum import Enum
62
- from typing import Any
63
-
64
- import numpy as np
65
-
66
- from qiskit.pulse.channels import Channel
67
- from qiskit.visualization.pulse_v2 import types
68
- from qiskit.visualization.exceptions import VisualizationError
69
-
70
-
71
- class ElementaryData(ABC):
72
- """Base class of the pulse visualization interface."""
73
-
74
- __hash__ = None
75
-
76
- def __init__(
77
- self,
78
- data_type: str | Enum,
79
- xvals: np.ndarray,
80
- yvals: np.ndarray,
81
- channels: Channel | list[Channel] | None = None,
82
- meta: dict[str, Any] | None = None,
83
- ignore_scaling: bool = False,
84
- styles: dict[str, Any] | None = None,
85
- ):
86
- """Create new drawing.
87
-
88
- Args:
89
- data_type: String representation of this drawing.
90
- xvals: Series of horizontal coordinate that the object is drawn.
91
- yvals: Series of vertical coordinate that the object is drawn.
92
- channels: Pulse channel object bound to this drawing.
93
- meta: Meta data dictionary of the object.
94
- ignore_scaling: Set ``True`` to disable scaling.
95
- styles: Style keyword args of the object. This conforms to `matplotlib`.
96
- """
97
- if channels and isinstance(channels, Channel):
98
- channels = [channels]
99
-
100
- if isinstance(data_type, Enum):
101
- data_type = data_type.value
102
-
103
- self.data_type = str(data_type)
104
- self.xvals = np.array(xvals, dtype=object)
105
- self.yvals = np.array(yvals, dtype=object)
106
- self.channels: list[Channel] = channels or []
107
- self.meta = meta or {}
108
- self.ignore_scaling = ignore_scaling
109
- self.styles = styles or {}
110
-
111
- @property
112
- def data_key(self):
113
- """Return unique hash of this object."""
114
- return str(
115
- hash((self.__class__.__name__, self.data_type, tuple(self.xvals), tuple(self.yvals)))
116
- )
117
-
118
- def __repr__(self):
119
- return f"{self.__class__.__name__}(type={self.data_type}, key={self.data_key})"
120
-
121
- def __eq__(self, other):
122
- return isinstance(other, self.__class__) and self.data_key == other.data_key
123
-
124
-
125
- class LineData(ElementaryData):
126
- """Drawing object to represent object appears as a line.
127
-
128
- This is the counterpart of `matplotlib.pyplot.plot`.
129
- """
130
-
131
- def __init__(
132
- self,
133
- data_type: str | Enum,
134
- xvals: np.ndarray | list[types.Coordinate],
135
- yvals: np.ndarray | list[types.Coordinate],
136
- fill: bool = False,
137
- channels: Channel | list[Channel] | None = None,
138
- meta: dict[str, Any] | None = None,
139
- ignore_scaling: bool = False,
140
- styles: dict[str, Any] | None = None,
141
- ):
142
- """Create new drawing.
143
-
144
- Args:
145
- data_type: String representation of this drawing.
146
- channels: Pulse channel object bound to this drawing.
147
- xvals: Series of horizontal coordinate that the object is drawn.
148
- yvals: Series of vertical coordinate that the object is drawn.
149
- fill: Set ``True`` to fill the area under curve.
150
- meta: Meta data dictionary of the object.
151
- ignore_scaling: Set ``True`` to disable scaling.
152
- styles: Style keyword args of the object. This conforms to `matplotlib`.
153
- """
154
- self.fill = fill
155
-
156
- super().__init__(
157
- data_type=data_type,
158
- xvals=xvals,
159
- yvals=yvals,
160
- channels=channels,
161
- meta=meta,
162
- ignore_scaling=ignore_scaling,
163
- styles=styles,
164
- )
165
-
166
-
167
- class TextData(ElementaryData):
168
- """Drawing object to represent object appears as a text.
169
-
170
- This is the counterpart of `matplotlib.pyplot.text`.
171
- """
172
-
173
- def __init__(
174
- self,
175
- data_type: str | Enum,
176
- xvals: np.ndarray | list[types.Coordinate],
177
- yvals: np.ndarray | list[types.Coordinate],
178
- text: str,
179
- latex: str | None = None,
180
- channels: Channel | list[Channel] | None = None,
181
- meta: dict[str, Any] | None = None,
182
- ignore_scaling: bool = False,
183
- styles: dict[str, Any] | None = None,
184
- ):
185
- """Create new drawing.
186
-
187
- Args:
188
- data_type: String representation of this drawing.
189
- channels: Pulse channel object bound to this drawing.
190
- xvals: Series of horizontal coordinate that the object is drawn.
191
- yvals: Series of vertical coordinate that the object is drawn.
192
- text: String to show in the canvas.
193
- latex: Latex representation of the text (if backend supports latex drawing).
194
- meta: Meta data dictionary of the object.
195
- ignore_scaling: Set ``True`` to disable scaling.
196
- styles: Style keyword args of the object. This conforms to `matplotlib`.
197
- """
198
- self.text = text
199
- self.latex = latex or ""
200
-
201
- super().__init__(
202
- data_type=data_type,
203
- xvals=xvals,
204
- yvals=yvals,
205
- channels=channels,
206
- meta=meta,
207
- ignore_scaling=ignore_scaling,
208
- styles=styles,
209
- )
210
-
211
-
212
- class BoxData(ElementaryData):
213
- """Drawing object that represents box shape.
214
-
215
- This is the counterpart of `matplotlib.patches.Rectangle`.
216
- """
217
-
218
- def __init__(
219
- self,
220
- data_type: str | Enum,
221
- xvals: np.ndarray | list[types.Coordinate],
222
- yvals: np.ndarray | list[types.Coordinate],
223
- channels: Channel | list[Channel] | None = None,
224
- meta: dict[str, Any] | None = None,
225
- ignore_scaling: bool = False,
226
- styles: dict[str, Any] | None = None,
227
- ):
228
- """Create new box.
229
-
230
- Args:
231
- data_type: String representation of this drawing.
232
- xvals: Left and right coordinate that the object is drawn.
233
- yvals: Top and bottom coordinate that the object is drawn.
234
- channels: Pulse channel object bound to this drawing.
235
- meta: Meta data dictionary of the object.
236
- ignore_scaling: Set ``True`` to disable scaling.
237
- styles: Style keyword args of the object. This conforms to `matplotlib`.
238
-
239
- Raises:
240
- VisualizationError: When number of data points are not equals to 2.
241
- """
242
- if len(xvals) != 2 or len(yvals) != 2:
243
- raise VisualizationError("Length of data points are not equals to 2.")
244
-
245
- super().__init__(
246
- data_type=data_type,
247
- xvals=xvals,
248
- yvals=yvals,
249
- channels=channels,
250
- meta=meta,
251
- ignore_scaling=ignore_scaling,
252
- styles=styles,
253
- )
@@ -1,254 +0,0 @@
1
- # This code is part of Qiskit.
2
- #
3
- # (C) Copyright IBM 2020.
4
- #
5
- # This code is licensed under the Apache License, Version 2.0. You may
6
- # obtain a copy of this license in the LICENSE.txt file in the root directory
7
- # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
- #
9
- # Any modifications or derivative works of this code must retain this
10
- # copyright notice, and modified files need to carry a notice indicating
11
- # that they have been altered from the originals.
12
-
13
- r"""
14
- Channel event manager for pulse schedules.
15
-
16
- This module provides a `ChannelEvents` class that manages a series of instructions for a
17
- pulse channel. Channel-wise filtering of the pulse program makes
18
- the arrangement of channels easier in the core drawer function.
19
- The `ChannelEvents` class is expected to be called by other programs (not by end-users).
20
-
21
- The `ChannelEvents` class instance is created with the class method ``load_program``:
22
-
23
- .. code-block:: python
24
-
25
- event = ChannelEvents.load_program(sched, DriveChannel(0))
26
-
27
- The `ChannelEvents` is created for a specific pulse channel and loosely assorts pulse
28
- instructions within the channel with different visualization purposes.
29
-
30
- Phase and frequency related instructions are loosely grouped as frame changes.
31
- The instantaneous value of those operands are combined and provided as ``PhaseFreqTuple``.
32
- Instructions that have finite duration are grouped as waveforms.
33
-
34
- The grouped instructions are returned as an iterator by the corresponding method call:
35
-
36
- .. code-block:: python
37
-
38
- for t0, frame, instruction in event.get_waveforms():
39
- ...
40
-
41
- for t0, frame_change, instructions in event.get_frame_changes():
42
- ...
43
-
44
- The class method ``get_waveforms`` returns the iterator of waveform type instructions with
45
- the ``PhaseFreqTuple`` (frame) at the time when instruction is issued.
46
- This is because a pulse envelope of ``Waveform`` may be modulated with a
47
- phase factor $exp(-i \omega t - \phi)$ with frequency $\omega$ and phase $\phi$ and
48
- appear on the canvas. Thus, it is better to tell users in which phase and frequency
49
- the pulse envelope is modulated from a viewpoint of program debugging.
50
-
51
- On the other hand, the class method ``get_frame_changes`` returns a ``PhaseFreqTuple`` that
52
- represents a total amount of change at that time because it is convenient to know
53
- the operand value itself when we debug a program.
54
-
55
- Because frame change type instructions are usually zero duration, multiple instructions
56
- can be issued at the same time and those operand values should be appropriately
57
- combined. In Qiskit Pulse we have set and shift type instructions for the frame control,
58
- the set type instruction will be converted into the relevant shift amount for visualization.
59
- Note that these instructions are not interchangeable and the order should be kept.
60
- For example:
61
-
62
- .. code-block:: python
63
-
64
- sched1 = Schedule()
65
- sched1 = sched1.insert(0, ShiftPhase(-1.57, DriveChannel(0))
66
- sched1 = sched1.insert(0, SetPhase(3.14, DriveChannel(0))
67
-
68
- sched2 = Schedule()
69
- sched2 = sched2.insert(0, SetPhase(3.14, DriveChannel(0))
70
- sched2 = sched2.insert(0, ShiftPhase(-1.57, DriveChannel(0))
71
-
72
- In this example, ``sched1`` and ``sched2`` will have different frames.
73
- On the drawer canvas, the total frame change amount of +3.14 should be shown for ``sched1``,
74
- while ``sched2`` is +1.57. Since the `SetPhase` and the `ShiftPhase` instruction behave
75
- differently, we cannot simply sum up the operand values in visualization output.
76
-
77
- It should be also noted that zero duration instructions issued at the same time will be
78
- overlapped on the canvas. Thus it is convenient to plot a total frame change amount rather
79
- than plotting each operand value bound to the instruction.
80
- """
81
- from __future__ import annotations
82
- from collections import defaultdict
83
- from collections.abc import Iterator
84
-
85
- from qiskit import pulse, circuit
86
- from qiskit.visualization.pulse_v2.types import PhaseFreqTuple, PulseInstruction
87
-
88
-
89
- class ChannelEvents:
90
- """Channel event manager."""
91
-
92
- _waveform_group = (
93
- pulse.instructions.Play,
94
- pulse.instructions.Delay,
95
- pulse.instructions.Acquire,
96
- )
97
- _frame_group = (
98
- pulse.instructions.SetFrequency,
99
- pulse.instructions.ShiftFrequency,
100
- pulse.instructions.SetPhase,
101
- pulse.instructions.ShiftPhase,
102
- )
103
-
104
- def __init__(
105
- self,
106
- waveforms: dict[int, pulse.Instruction],
107
- frames: dict[int, list[pulse.Instruction]],
108
- channel: pulse.channels.Channel,
109
- ):
110
- """Create new event manager.
111
-
112
- Args:
113
- waveforms: List of waveforms shown in this channel.
114
- frames: List of frame change type instructions shown in this channel.
115
- channel: Channel object associated with this manager.
116
- """
117
- self._waveforms = waveforms
118
- self._frames = frames
119
- self.channel = channel
120
-
121
- # initial frame
122
- self._init_phase = 0.0
123
- self._init_frequency = 0.0
124
-
125
- # time resolution
126
- self._dt = 0.0
127
-
128
- @classmethod
129
- def load_program(cls, program: pulse.Schedule, channel: pulse.channels.Channel):
130
- """Load a pulse program represented by ``Schedule``.
131
-
132
- Args:
133
- program: Target ``Schedule`` to visualize.
134
- channel: The channel managed by this instance.
135
-
136
- Returns:
137
- ChannelEvents: The channel event manager for the specified channel.
138
- """
139
- waveforms = {}
140
- frames = defaultdict(list)
141
-
142
- # parse instructions
143
- for t0, inst in program.filter(channels=[channel]).instructions:
144
- if isinstance(inst, cls._waveform_group):
145
- if inst.duration == 0:
146
- # special case, duration of delay can be zero
147
- continue
148
- waveforms[t0] = inst
149
- elif isinstance(inst, cls._frame_group):
150
- frames[t0].append(inst)
151
-
152
- return ChannelEvents(waveforms, frames, channel)
153
-
154
- def set_config(self, dt: float, init_frequency: float, init_phase: float):
155
- """Setup system status.
156
-
157
- Args:
158
- dt: Time resolution in sec.
159
- init_frequency: Modulation frequency in Hz.
160
- init_phase: Initial phase in rad.
161
- """
162
- self._dt = dt or 1.0
163
- self._init_frequency = init_frequency or 0.0
164
- self._init_phase = init_phase or 0.0
165
-
166
- def get_waveforms(self) -> Iterator[PulseInstruction]:
167
- """Return waveform type instructions with frame."""
168
- sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0], reverse=True)
169
- sorted_waveforms = sorted(self._waveforms.items(), key=lambda x: x[0])
170
-
171
- # bind phase and frequency with instruction
172
- phase = self._init_phase
173
- frequency = self._init_frequency
174
- for t0, inst in sorted_waveforms:
175
- is_opaque = False
176
-
177
- while len(sorted_frame_changes) > 0 and sorted_frame_changes[-1][0] <= t0:
178
- _, frame_changes = sorted_frame_changes.pop()
179
- phase, frequency = ChannelEvents._calculate_current_frame(
180
- frame_changes=frame_changes, phase=phase, frequency=frequency
181
- )
182
-
183
- # Convert parameter expression into float
184
- if isinstance(phase, circuit.ParameterExpression):
185
- phase = float(phase.bind({param: 0 for param in phase.parameters}))
186
- if isinstance(frequency, circuit.ParameterExpression):
187
- frequency = float(frequency.bind({param: 0 for param in frequency.parameters}))
188
-
189
- frame = PhaseFreqTuple(phase, frequency)
190
-
191
- # Check if pulse has unbound parameters
192
- if isinstance(inst, pulse.Play):
193
- is_opaque = inst.pulse.is_parameterized()
194
-
195
- yield PulseInstruction(t0, self._dt, frame, inst, is_opaque)
196
-
197
- def get_frame_changes(self) -> Iterator[PulseInstruction]:
198
- """Return frame change type instructions with total frame change amount."""
199
- # TODO parse parametrized FCs correctly
200
-
201
- sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0])
202
-
203
- phase = self._init_phase
204
- frequency = self._init_frequency
205
- for t0, frame_changes in sorted_frame_changes:
206
- is_opaque = False
207
-
208
- pre_phase = phase
209
- pre_frequency = frequency
210
- phase, frequency = ChannelEvents._calculate_current_frame(
211
- frame_changes=frame_changes, phase=phase, frequency=frequency
212
- )
213
-
214
- # keep parameter expression to check either phase or frequency is parameterized
215
- frame = PhaseFreqTuple(phase - pre_phase, frequency - pre_frequency)
216
-
217
- # remove parameter expressions to find if next frame is parameterized
218
- if isinstance(phase, circuit.ParameterExpression):
219
- phase = float(phase.bind({param: 0 for param in phase.parameters}))
220
- is_opaque = True
221
- if isinstance(frequency, circuit.ParameterExpression):
222
- frequency = float(frequency.bind({param: 0 for param in frequency.parameters}))
223
- is_opaque = True
224
-
225
- yield PulseInstruction(t0, self._dt, frame, frame_changes, is_opaque)
226
-
227
- @classmethod
228
- def _calculate_current_frame(
229
- cls, frame_changes: list[pulse.instructions.Instruction], phase: float, frequency: float
230
- ) -> tuple[float, float]:
231
- """Calculate the current frame from the previous frame.
232
-
233
- If parameter is unbound phase or frequency accumulation with this instruction is skipped.
234
-
235
- Args:
236
- frame_changes: List of frame change instructions at a specific time.
237
- phase: Phase of previous frame.
238
- frequency: Frequency of previous frame.
239
-
240
- Returns:
241
- Phase and frequency of new frame.
242
- """
243
-
244
- for frame_change in frame_changes:
245
- if isinstance(frame_change, pulse.instructions.SetFrequency):
246
- frequency = frame_change.frequency
247
- elif isinstance(frame_change, pulse.instructions.ShiftFrequency):
248
- frequency += frame_change.frequency
249
- elif isinstance(frame_change, pulse.instructions.SetPhase):
250
- phase = frame_change.phase
251
- elif isinstance(frame_change, pulse.instructions.ShiftPhase):
252
- phase += frame_change.phase
253
-
254
- return phase, frequency