qiskit 1.1.2__cp38-abi3-win32.whl → 1.2.0__cp38-abi3-win32.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 (343) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/__init__.py +27 -24
  3. qiskit/_accelerate.pyd +0 -0
  4. qiskit/_numpy_compat.py +1 -1
  5. qiskit/assembler/assemble_circuits.py +107 -64
  6. qiskit/assembler/assemble_schedules.py +5 -12
  7. qiskit/assembler/disassemble.py +10 -1
  8. qiskit/circuit/__init__.py +6 -3
  9. qiskit/circuit/_classical_resource_map.py +5 -5
  10. qiskit/circuit/_utils.py +0 -13
  11. qiskit/circuit/add_control.py +1 -1
  12. qiskit/circuit/annotated_operation.py +23 -1
  13. qiskit/circuit/classical/expr/expr.py +4 -4
  14. qiskit/circuit/classical/expr/visitors.py +1 -1
  15. qiskit/circuit/classical/types/__init__.py +1 -1
  16. qiskit/circuit/classical/types/types.py +2 -2
  17. qiskit/circuit/classicalfunction/boolean_expression.py +1 -1
  18. qiskit/circuit/classicalfunction/classical_function_visitor.py +5 -5
  19. qiskit/circuit/classicalfunction/utils.py +1 -1
  20. qiskit/circuit/classicalregister.py +1 -1
  21. qiskit/circuit/commutation_checker.py +83 -35
  22. qiskit/circuit/controlflow/_builder_utils.py +1 -1
  23. qiskit/circuit/controlflow/builder.py +10 -6
  24. qiskit/circuit/controlflow/if_else.py +2 -2
  25. qiskit/circuit/controlflow/switch_case.py +1 -1
  26. qiskit/circuit/delay.py +1 -1
  27. qiskit/circuit/duration.py +2 -2
  28. qiskit/circuit/equivalence.py +5 -7
  29. qiskit/circuit/gate.py +11 -8
  30. qiskit/circuit/instruction.py +31 -13
  31. qiskit/circuit/instructionset.py +2 -5
  32. qiskit/circuit/library/__init__.py +2 -1
  33. qiskit/circuit/library/arithmetic/linear_amplitude_function.py +1 -1
  34. qiskit/circuit/library/arithmetic/linear_pauli_rotations.py +1 -1
  35. qiskit/circuit/library/arithmetic/piecewise_chebyshev.py +1 -1
  36. qiskit/circuit/library/arithmetic/piecewise_linear_pauli_rotations.py +1 -1
  37. qiskit/circuit/library/arithmetic/piecewise_polynomial_pauli_rotations.py +3 -3
  38. qiskit/circuit/library/arithmetic/polynomial_pauli_rotations.py +1 -1
  39. qiskit/circuit/library/basis_change/__init__.py +1 -1
  40. qiskit/circuit/library/basis_change/qft.py +40 -6
  41. qiskit/circuit/library/blueprintcircuit.py +3 -5
  42. qiskit/circuit/library/data_preparation/__init__.py +9 -2
  43. qiskit/circuit/library/data_preparation/initializer.py +8 -0
  44. qiskit/circuit/library/data_preparation/state_preparation.py +98 -178
  45. qiskit/circuit/library/generalized_gates/isometry.py +8 -8
  46. qiskit/circuit/library/generalized_gates/linear_function.py +3 -2
  47. qiskit/circuit/library/generalized_gates/mcg_up_to_diagonal.py +4 -4
  48. qiskit/circuit/library/generalized_gates/permutation.py +8 -9
  49. qiskit/circuit/library/generalized_gates/uc.py +3 -3
  50. qiskit/circuit/library/generalized_gates/uc_pauli_rot.py +2 -2
  51. qiskit/circuit/library/generalized_gates/unitary.py +13 -11
  52. qiskit/circuit/library/graph_state.py +1 -1
  53. qiskit/circuit/library/hamiltonian_gate.py +1 -2
  54. qiskit/circuit/library/hidden_linear_function.py +1 -1
  55. qiskit/circuit/library/n_local/evolved_operator_ansatz.py +3 -2
  56. qiskit/circuit/library/n_local/n_local.py +4 -5
  57. qiskit/circuit/library/n_local/pauli_two_design.py +1 -1
  58. qiskit/circuit/library/n_local/qaoa_ansatz.py +6 -8
  59. qiskit/circuit/library/n_local/two_local.py +1 -1
  60. qiskit/circuit/library/overlap.py +11 -5
  61. qiskit/circuit/library/pauli_evolution.py +7 -3
  62. qiskit/circuit/library/standard_gates/dcx.py +3 -0
  63. qiskit/circuit/library/standard_gates/ecr.py +3 -0
  64. qiskit/circuit/library/standard_gates/global_phase.py +3 -0
  65. qiskit/circuit/library/standard_gates/h.py +13 -5
  66. qiskit/circuit/library/standard_gates/i.py +3 -0
  67. qiskit/circuit/library/standard_gates/iswap.py +3 -0
  68. qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +19 -10
  69. qiskit/circuit/library/standard_gates/p.py +14 -9
  70. qiskit/circuit/library/standard_gates/r.py +3 -0
  71. qiskit/circuit/library/standard_gates/rx.py +21 -6
  72. qiskit/circuit/library/standard_gates/rxx.py +40 -1
  73. qiskit/circuit/library/standard_gates/ry.py +21 -6
  74. qiskit/circuit/library/standard_gates/ryy.py +40 -1
  75. qiskit/circuit/library/standard_gates/rz.py +22 -6
  76. qiskit/circuit/library/standard_gates/rzx.py +40 -1
  77. qiskit/circuit/library/standard_gates/rzz.py +41 -2
  78. qiskit/circuit/library/standard_gates/s.py +77 -0
  79. qiskit/circuit/library/standard_gates/swap.py +12 -5
  80. qiskit/circuit/library/standard_gates/sx.py +14 -5
  81. qiskit/circuit/library/standard_gates/t.py +5 -0
  82. qiskit/circuit/library/standard_gates/u.py +22 -7
  83. qiskit/circuit/library/standard_gates/u1.py +8 -3
  84. qiskit/circuit/library/standard_gates/u2.py +3 -0
  85. qiskit/circuit/library/standard_gates/u3.py +22 -7
  86. qiskit/circuit/library/standard_gates/x.py +156 -92
  87. qiskit/circuit/library/standard_gates/xx_minus_yy.py +40 -1
  88. qiskit/circuit/library/standard_gates/xx_plus_yy.py +52 -11
  89. qiskit/circuit/library/standard_gates/y.py +6 -1
  90. qiskit/circuit/library/standard_gates/z.py +8 -1
  91. qiskit/circuit/operation.py +1 -1
  92. qiskit/circuit/parameter.py +9 -10
  93. qiskit/circuit/parameterexpression.py +16 -13
  94. qiskit/circuit/parametertable.py +1 -190
  95. qiskit/circuit/parametervector.py +1 -1
  96. qiskit/circuit/quantumcircuit.py +395 -387
  97. qiskit/circuit/quantumcircuitdata.py +3 -5
  98. qiskit/circuit/quantumregister.py +1 -1
  99. qiskit/circuit/random/__init__.py +1 -1
  100. qiskit/circuit/random/utils.py +175 -26
  101. qiskit/circuit/register.py +5 -7
  102. qiskit/circuit/singleton.py +3 -3
  103. qiskit/circuit/tools/pi_check.py +4 -4
  104. qiskit/compiler/assembler.py +95 -24
  105. qiskit/compiler/scheduler.py +2 -2
  106. qiskit/compiler/transpiler.py +42 -128
  107. qiskit/converters/circuit_to_dag.py +4 -6
  108. qiskit/converters/circuit_to_gate.py +4 -8
  109. qiskit/converters/circuit_to_instruction.py +5 -17
  110. qiskit/converters/dag_to_circuit.py +2 -6
  111. qiskit/dagcircuit/collect_blocks.py +2 -2
  112. qiskit/dagcircuit/dagcircuit.py +190 -187
  113. qiskit/dagcircuit/dagdependency.py +4 -4
  114. qiskit/dagcircuit/dagdependency_v2.py +4 -4
  115. qiskit/dagcircuit/dagdepnode.py +1 -1
  116. qiskit/dagcircuit/dagnode.py +66 -157
  117. qiskit/passmanager/flow_controllers.py +1 -1
  118. qiskit/passmanager/passmanager.py +3 -3
  119. qiskit/primitives/__init__.py +1 -5
  120. qiskit/primitives/backend_estimator.py +25 -15
  121. qiskit/primitives/backend_estimator_v2.py +31 -7
  122. qiskit/primitives/backend_sampler.py +21 -12
  123. qiskit/primitives/backend_sampler_v2.py +12 -3
  124. qiskit/primitives/base/base_estimator.py +31 -4
  125. qiskit/primitives/base/base_primitive.py +2 -2
  126. qiskit/primitives/base/base_result.py +2 -2
  127. qiskit/primitives/base/base_sampler.py +26 -2
  128. qiskit/primitives/base/estimator_result.py +2 -2
  129. qiskit/primitives/base/sampler_result.py +2 -2
  130. qiskit/primitives/containers/__init__.py +0 -1
  131. qiskit/primitives/containers/bindings_array.py +2 -2
  132. qiskit/primitives/containers/bit_array.py +108 -10
  133. qiskit/primitives/containers/shape.py +3 -3
  134. qiskit/primitives/estimator.py +9 -2
  135. qiskit/primitives/primitive_job.py +1 -1
  136. qiskit/primitives/sampler.py +10 -3
  137. qiskit/primitives/statevector_estimator.py +5 -3
  138. qiskit/primitives/statevector_sampler.py +11 -5
  139. qiskit/primitives/utils.py +16 -0
  140. qiskit/providers/backend.py +15 -6
  141. qiskit/providers/backend_compat.py +7 -4
  142. qiskit/providers/basic_provider/basic_provider_tools.py +1 -1
  143. qiskit/providers/basic_provider/basic_simulator.py +33 -25
  144. qiskit/providers/fake_provider/fake_backend.py +10 -3
  145. qiskit/providers/fake_provider/fake_openpulse_2q.py +157 -149
  146. qiskit/providers/fake_provider/fake_openpulse_3q.py +228 -220
  147. qiskit/providers/fake_provider/fake_pulse_backend.py +2 -1
  148. qiskit/providers/fake_provider/fake_qasm_backend.py +7 -2
  149. qiskit/providers/fake_provider/generic_backend_v2.py +514 -68
  150. qiskit/providers/models/__init__.py +48 -11
  151. qiskit/providers/models/backendconfiguration.py +50 -4
  152. qiskit/providers/models/backendproperties.py +13 -2
  153. qiskit/providers/models/pulsedefaults.py +10 -11
  154. qiskit/providers/options.py +13 -13
  155. qiskit/providers/providerutils.py +3 -1
  156. qiskit/pulse/configuration.py +8 -12
  157. qiskit/pulse/instruction_schedule_map.py +3 -5
  158. qiskit/pulse/instructions/acquire.py +7 -8
  159. qiskit/pulse/instructions/instruction.py +2 -3
  160. qiskit/pulse/library/samplers/decorators.py +5 -9
  161. qiskit/pulse/library/symbolic_pulses.py +4 -7
  162. qiskit/pulse/library/waveform.py +2 -5
  163. qiskit/pulse/macros.py +11 -6
  164. qiskit/pulse/parser.py +8 -10
  165. qiskit/pulse/schedule.py +9 -17
  166. qiskit/pulse/transforms/alignments.py +1 -3
  167. qiskit/pulse/utils.py +1 -2
  168. qiskit/qasm/libs/stdgates.inc +35 -28
  169. qiskit/qasm2/__init__.py +7 -7
  170. qiskit/qasm2/export.py +5 -9
  171. qiskit/qasm2/parse.py +1 -1
  172. qiskit/qasm3/ast.py +9 -25
  173. qiskit/qasm3/exporter.py +582 -479
  174. qiskit/qasm3/printer.py +7 -16
  175. qiskit/qobj/common.py +10 -0
  176. qiskit/qobj/converters/lo_config.py +9 -0
  177. qiskit/qobj/converters/pulse_instruction.py +13 -6
  178. qiskit/qobj/pulse_qobj.py +69 -15
  179. qiskit/qobj/qasm_qobj.py +72 -20
  180. qiskit/qobj/utils.py +9 -0
  181. qiskit/qpy/__init__.py +1 -1
  182. qiskit/qpy/binary_io/circuits.py +8 -5
  183. qiskit/qpy/binary_io/schedules.py +1 -1
  184. qiskit/qpy/binary_io/value.py +3 -3
  185. qiskit/qpy/interface.py +3 -2
  186. qiskit/qpy/type_keys.py +2 -2
  187. qiskit/quantum_info/operators/channel/quantum_channel.py +3 -6
  188. qiskit/quantum_info/operators/channel/superop.py +2 -2
  189. qiskit/quantum_info/operators/channel/transformations.py +1 -1
  190. qiskit/quantum_info/operators/dihedral/dihedral.py +3 -4
  191. qiskit/quantum_info/operators/dihedral/dihedral_circuits.py +1 -3
  192. qiskit/quantum_info/operators/dihedral/random.py +6 -3
  193. qiskit/quantum_info/operators/measures.py +2 -2
  194. qiskit/quantum_info/operators/op_shape.py +12 -20
  195. qiskit/quantum_info/operators/operator.py +14 -21
  196. qiskit/quantum_info/operators/predicates.py +1 -0
  197. qiskit/quantum_info/operators/symplectic/base_pauli.py +7 -11
  198. qiskit/quantum_info/operators/symplectic/clifford.py +1 -1
  199. qiskit/quantum_info/operators/symplectic/pauli.py +3 -3
  200. qiskit/quantum_info/operators/symplectic/pauli_list.py +9 -10
  201. qiskit/quantum_info/operators/symplectic/random.py +1 -1
  202. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +15 -17
  203. qiskit/quantum_info/quaternion.py +1 -1
  204. qiskit/quantum_info/states/densitymatrix.py +5 -8
  205. qiskit/quantum_info/states/stabilizerstate.py +128 -37
  206. qiskit/quantum_info/states/statevector.py +4 -8
  207. qiskit/result/counts.py +2 -2
  208. qiskit/result/mitigation/correlated_readout_mitigator.py +2 -2
  209. qiskit/result/mitigation/local_readout_mitigator.py +2 -2
  210. qiskit/result/mitigation/utils.py +1 -3
  211. qiskit/result/models.py +17 -16
  212. qiskit/result/result.py +15 -20
  213. qiskit/scheduler/lowering.py +2 -2
  214. qiskit/synthesis/__init__.py +2 -1
  215. qiskit/synthesis/clifford/__init__.py +1 -1
  216. qiskit/synthesis/clifford/clifford_decompose_ag.py +2 -2
  217. qiskit/synthesis/clifford/clifford_decompose_bm.py +10 -240
  218. qiskit/synthesis/clifford/clifford_decompose_greedy.py +9 -303
  219. qiskit/synthesis/clifford/clifford_decompose_layers.py +25 -23
  220. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py +1 -1
  221. qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py +1 -1
  222. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
  223. qiskit/synthesis/discrete_basis/solovay_kitaev.py +2 -2
  224. qiskit/synthesis/evolution/evolution_synthesis.py +4 -2
  225. qiskit/synthesis/evolution/lie_trotter.py +46 -19
  226. qiskit/synthesis/evolution/product_formula.py +111 -55
  227. qiskit/synthesis/evolution/qdrift.py +40 -10
  228. qiskit/synthesis/evolution/suzuki_trotter.py +43 -33
  229. qiskit/synthesis/linear/__init__.py +1 -0
  230. qiskit/synthesis/linear/cnot_synth.py +22 -96
  231. qiskit/synthesis/linear/linear_depth_lnn.py +8 -8
  232. qiskit/synthesis/linear/linear_matrix_utils.py +13 -161
  233. qiskit/synthesis/linear_phase/cnot_phase_synth.py +1 -1
  234. qiskit/synthesis/linear_phase/cx_cz_depth_lnn.py +3 -3
  235. qiskit/synthesis/linear_phase/cz_depth_lnn.py +1 -1
  236. qiskit/synthesis/one_qubit/one_qubit_decompose.py +29 -29
  237. qiskit/synthesis/permutation/permutation_full.py +5 -29
  238. qiskit/synthesis/permutation/permutation_lnn.py +2 -24
  239. qiskit/synthesis/permutation/permutation_utils.py +2 -59
  240. qiskit/synthesis/qft/__init__.py +1 -0
  241. qiskit/synthesis/qft/qft_decompose_full.py +79 -0
  242. qiskit/synthesis/qft/qft_decompose_lnn.py +17 -9
  243. qiskit/synthesis/stabilizer/stabilizer_circuit.py +6 -6
  244. qiskit/synthesis/stabilizer/stabilizer_decompose.py +2 -2
  245. qiskit/synthesis/two_qubit/local_invariance.py +8 -38
  246. qiskit/synthesis/two_qubit/two_qubit_decompose.py +48 -129
  247. qiskit/synthesis/unitary/aqc/cnot_structures.py +1 -1
  248. qiskit/synthesis/unitary/qsd.py +5 -3
  249. qiskit/transpiler/__init__.py +1 -0
  250. qiskit/transpiler/basepasses.py +1 -1
  251. qiskit/transpiler/coupling.py +3 -3
  252. qiskit/transpiler/instruction_durations.py +1 -2
  253. qiskit/transpiler/layout.py +3 -3
  254. qiskit/transpiler/passes/__init__.py +2 -0
  255. qiskit/transpiler/passes/basis/basis_translator.py +84 -64
  256. qiskit/transpiler/passes/basis/translate_parameterized.py +3 -5
  257. qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
  258. qiskit/transpiler/passes/basis/unroll_custom_definitions.py +10 -10
  259. qiskit/transpiler/passes/calibration/rx_builder.py +3 -3
  260. qiskit/transpiler/passes/calibration/rzx_builder.py +3 -3
  261. qiskit/transpiler/passes/layout/apply_layout.py +13 -3
  262. qiskit/transpiler/passes/layout/sabre_layout.py +10 -8
  263. qiskit/transpiler/passes/layout/sabre_pre_layout.py +4 -1
  264. qiskit/transpiler/passes/layout/set_layout.py +2 -2
  265. qiskit/transpiler/passes/layout/vf2_layout.py +1 -1
  266. qiskit/transpiler/passes/layout/vf2_utils.py +3 -3
  267. qiskit/transpiler/passes/optimization/__init__.py +1 -0
  268. qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py +2 -2
  269. qiskit/transpiler/passes/optimization/commutation_analysis.py +7 -10
  270. qiskit/transpiler/passes/optimization/commutative_cancellation.py +35 -19
  271. qiskit/transpiler/passes/optimization/consolidate_blocks.py +17 -8
  272. qiskit/transpiler/passes/optimization/inverse_cancellation.py +6 -6
  273. qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +64 -41
  274. qiskit/transpiler/passes/optimization/optimize_1q_gates.py +1 -1
  275. qiskit/transpiler/passes/optimization/split_2q_unitaries.py +83 -0
  276. qiskit/transpiler/passes/optimization/template_matching/backward_match.py +1 -1
  277. qiskit/transpiler/passes/optimization/template_matching/forward_match.py +2 -2
  278. qiskit/transpiler/passes/optimization/template_matching/template_substitution.py +1 -1
  279. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +3 -2
  280. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/swap_strategy.py +1 -1
  281. qiskit/transpiler/passes/routing/layout_transformation.py +2 -1
  282. qiskit/transpiler/passes/routing/sabre_swap.py +35 -26
  283. qiskit/transpiler/passes/routing/star_prerouting.py +80 -105
  284. qiskit/transpiler/passes/routing/stochastic_swap.py +1 -3
  285. qiskit/transpiler/passes/scheduling/alap.py +1 -2
  286. qiskit/transpiler/passes/scheduling/alignments/__init__.py +2 -2
  287. qiskit/transpiler/passes/scheduling/alignments/check_durations.py +1 -1
  288. qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +2 -2
  289. qiskit/transpiler/passes/scheduling/alignments/reschedule.py +1 -1
  290. qiskit/transpiler/passes/scheduling/asap.py +1 -2
  291. qiskit/transpiler/passes/scheduling/base_scheduler.py +5 -5
  292. qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +3 -3
  293. qiskit/transpiler/passes/scheduling/padding/base_padding.py +1 -1
  294. qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +20 -14
  295. qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py +7 -6
  296. qiskit/transpiler/passes/scheduling/time_unit_conversion.py +4 -3
  297. qiskit/transpiler/passes/synthesis/high_level_synthesis.py +211 -36
  298. qiskit/transpiler/passes/synthesis/plugin.py +2 -2
  299. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +80 -40
  300. qiskit/transpiler/passes/utils/__init__.py +0 -1
  301. qiskit/transpiler/passes/utils/check_gate_direction.py +4 -4
  302. qiskit/transpiler/passes/utils/check_map.py +3 -6
  303. qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py +3 -4
  304. qiskit/transpiler/passes/utils/error.py +2 -2
  305. qiskit/transpiler/passes/utils/fixed_point.py +3 -3
  306. qiskit/transpiler/passes/utils/gate_direction.py +1 -1
  307. qiskit/transpiler/passes/utils/gates_basis.py +1 -2
  308. qiskit/transpiler/passmanager.py +7 -6
  309. qiskit/transpiler/preset_passmanagers/__init__.py +4 -228
  310. qiskit/transpiler/preset_passmanagers/builtin_plugins.py +73 -18
  311. qiskit/transpiler/preset_passmanagers/common.py +3 -6
  312. qiskit/transpiler/preset_passmanagers/generate_preset_pass_manager.py +518 -0
  313. qiskit/transpiler/preset_passmanagers/level0.py +1 -1
  314. qiskit/transpiler/target.py +27 -8
  315. qiskit/user_config.py +29 -6
  316. qiskit/utils/classtools.py +3 -3
  317. qiskit/utils/deprecation.py +3 -2
  318. qiskit/utils/lazy_tester.py +2 -2
  319. qiskit/utils/optionals.py +8 -8
  320. qiskit/visualization/bloch.py +18 -23
  321. qiskit/visualization/circuit/_utils.py +34 -10
  322. qiskit/visualization/circuit/circuit_visualization.py +23 -16
  323. qiskit/visualization/circuit/latex.py +29 -27
  324. qiskit/visualization/circuit/matplotlib.py +4 -2
  325. qiskit/visualization/circuit/qcstyle.py +2 -2
  326. qiskit/visualization/circuit/text.py +9 -15
  327. qiskit/visualization/dag_visualization.py +2 -2
  328. qiskit/visualization/pulse_v2/core.py +1 -1
  329. qiskit/visualization/pulse_v2/events.py +1 -1
  330. qiskit/visualization/pulse_v2/generators/frame.py +3 -4
  331. qiskit/visualization/pulse_v2/generators/waveform.py +5 -9
  332. qiskit/visualization/pulse_v2/layouts.py +1 -5
  333. qiskit/visualization/pulse_v2/plotters/matplotlib.py +1 -2
  334. qiskit/visualization/state_visualization.py +5 -6
  335. qiskit/visualization/timeline/plotters/matplotlib.py +1 -2
  336. qiskit/visualization/transition_visualization.py +7 -2
  337. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/METADATA +12 -12
  338. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/RECORD +342 -340
  339. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/entry_points.txt +3 -0
  340. qiskit/transpiler/passes/utils/block_to_matrix.py +0 -47
  341. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/LICENSE.txt +0 -0
  342. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/WHEEL +0 -0
  343. {qiskit-1.1.2.dist-info → qiskit-1.2.0.dist-info}/top_level.txt +0 -0
qiskit/user_config.py CHANGED
@@ -31,9 +31,11 @@ class UserConfig:
31
31
  circuit_mpl_style = default
32
32
  circuit_mpl_style_path = ~/.qiskit:<default location>
33
33
  circuit_reverse_bits = True
34
+ circuit_idle_wires = False
34
35
  transpile_optimization_level = 1
35
36
  parallel = False
36
37
  num_processes = 4
38
+ sabre_all_threads = true
37
39
 
38
40
  """
39
41
 
@@ -62,9 +64,9 @@ class UserConfig:
62
64
  if circuit_drawer:
63
65
  if circuit_drawer not in ["text", "mpl", "latex", "latex_source", "auto"]:
64
66
  raise exceptions.QiskitUserConfigError(
65
- "%s is not a valid circuit drawer backend. Must be "
67
+ f"{circuit_drawer} is not a valid circuit drawer backend. Must be "
66
68
  "either 'text', 'mpl', 'latex', 'latex_source', or "
67
- "'auto'." % circuit_drawer
69
+ "'auto'."
68
70
  )
69
71
  self.settings["circuit_drawer"] = circuit_drawer
70
72
 
@@ -95,8 +97,8 @@ class UserConfig:
95
97
  if circuit_mpl_style:
96
98
  if not isinstance(circuit_mpl_style, str):
97
99
  warn(
98
- "%s is not a valid mpl circuit style. Must be "
99
- "a text string. Will not load style." % circuit_mpl_style,
100
+ f"{circuit_mpl_style} is not a valid mpl circuit style. Must be "
101
+ "a text string. Will not load style.",
100
102
  UserWarning,
101
103
  2,
102
104
  )
@@ -111,8 +113,8 @@ class UserConfig:
111
113
  for path in cpath_list:
112
114
  if not os.path.exists(os.path.expanduser(path)):
113
115
  warn(
114
- "%s is not a valid circuit mpl style path."
115
- " Correct the path in ~/.qiskit/settings.conf." % path,
116
+ f"{path} is not a valid circuit mpl style path."
117
+ " Correct the path in ~/.qiskit/settings.conf.",
116
118
  UserWarning,
117
119
  2,
118
120
  )
@@ -130,6 +132,18 @@ class UserConfig:
130
132
  if circuit_reverse_bits is not None:
131
133
  self.settings["circuit_reverse_bits"] = circuit_reverse_bits
132
134
 
135
+ # Parse circuit_idle_wires
136
+ try:
137
+ circuit_idle_wires = self.config_parser.getboolean(
138
+ "default", "circuit_idle_wires", fallback=None
139
+ )
140
+ except ValueError as err:
141
+ raise exceptions.QiskitUserConfigError(
142
+ f"Value assigned to circuit_idle_wires is not valid. {str(err)}"
143
+ )
144
+ if circuit_idle_wires is not None:
145
+ self.settings["circuit_idle_wires"] = circuit_idle_wires
146
+
133
147
  # Parse transpile_optimization_level
134
148
  transpile_optimization_level = self.config_parser.getint(
135
149
  "default", "transpile_optimization_level", fallback=-1
@@ -155,6 +169,13 @@ class UserConfig:
155
169
  )
156
170
  self.settings["num_processes"] = num_processes
157
171
 
172
+ # Parse sabre_all_threads
173
+ sabre_all_threads = self.config_parser.getboolean(
174
+ "default", "sabre_all_threads", fallback=None
175
+ )
176
+ if sabre_all_threads is not None:
177
+ self.settings["sabre_all_threads"] = sabre_all_threads
178
+
158
179
 
159
180
  def set_config(key, value, section=None, file_path=None):
160
181
  """Adds or modifies a user configuration
@@ -191,9 +212,11 @@ def set_config(key, value, section=None, file_path=None):
191
212
  "circuit_mpl_style",
192
213
  "circuit_mpl_style_path",
193
214
  "circuit_reverse_bits",
215
+ "circuit_idle_wires",
194
216
  "transpile_optimization_level",
195
217
  "parallel",
196
218
  "num_processes",
219
+ "sabre_all_threads",
197
220
  }
198
221
 
199
222
  if section in [None, "default"]:
@@ -31,7 +31,7 @@ class _lift_to_method: # pylint: disable=invalid-name
31
31
  returned unchanged if so, otherwise it is turned into the default implementation for functions,
32
32
  which makes them bindable to instances.
33
33
 
34
- Python-space functions and lambdas already have this behaviour, but builtins like ``print``
34
+ Python-space functions and lambdas already have this behavior, but builtins like ``print``
35
35
  don't; using this class allows us to do::
36
36
 
37
37
  wrap_method(MyClass, "maybe_mutates_arguments", before=print, after=print)
@@ -49,7 +49,7 @@ class _lift_to_method: # pylint: disable=invalid-name
49
49
 
50
50
  def __init__(self, method):
51
51
  if method is self:
52
- # Prevent double-initialisation if we are passed an instance of this object to lift.
52
+ # Prevent double-initialization if we are passed an instance of this object to lift.
53
53
  return
54
54
  self._method = method
55
55
 
@@ -118,7 +118,7 @@ class _WrappedMethod:
118
118
 
119
119
 
120
120
  def wrap_method(cls: Type, name: str, *, before: Callable = None, after: Callable = None):
121
- """Wrap the functionality the instance- or class method ``cls.name`` with additional behaviour
121
+ """Wrap the functionality the instance- or class method ``cls.name`` with additional behavior
122
122
  ``before`` and ``after``.
123
123
 
124
124
  This mutates ``cls``, replacing the attribute ``name`` with the new functionality. This is
@@ -29,6 +29,7 @@ def deprecate_func(
29
29
  package_name: str = "qiskit",
30
30
  removal_timeline: str = "no earlier than 3 months after the release date",
31
31
  is_property: bool = False,
32
+ stacklevel: int = 2,
32
33
  ):
33
34
  """Decorator to indicate a function has been deprecated.
34
35
 
@@ -50,7 +51,7 @@ def deprecate_func(
50
51
  is_property: If the deprecated function is a `@property`, set this to True so that the
51
52
  generated message correctly describes it as such. (This isn't necessary for
52
53
  property setters, as their docstring is ignored by Python.)
53
-
54
+ stacklevel: Stack level passed to :func:`warnings.warn`.
54
55
  Returns:
55
56
  Callable: The decorated callable.
56
57
  """
@@ -92,7 +93,7 @@ def deprecate_func(
92
93
 
93
94
  @functools.wraps(func)
94
95
  def wrapper(*args, **kwargs):
95
- warnings.warn(msg, category=category, stacklevel=2)
96
+ warnings.warn(msg, category=category, stacklevel=stacklevel)
96
97
  return func(*args, **kwargs)
97
98
 
98
99
  add_deprecation_to_docstring(wrapper, msg, since=since, pending=pending)
@@ -174,7 +174,7 @@ class LazyDependencyManager(abc.ABC):
174
174
 
175
175
  def require_in_instance(self, feature_or_class):
176
176
  """A class decorator that requires the dependency is available when the class is
177
- initialised. This decorator can be used even if the class does not define an ``__init__``
177
+ initialized. This decorator can be used even if the class does not define an ``__init__``
178
178
  method.
179
179
 
180
180
  Args:
@@ -186,7 +186,7 @@ class LazyDependencyManager(abc.ABC):
186
186
 
187
187
  Returns:
188
188
  Callable: a class decorator that ensures that the wrapped feature is present if the
189
- class is initialised.
189
+ class is initialized.
190
190
  """
191
191
  if isinstance(feature_or_class, str):
192
192
  feature = feature_or_class
qiskit/utils/optionals.py CHANGED
@@ -79,7 +79,7 @@ External Python Libraries
79
79
 
80
80
  * - .. py:data:: HAS_IPYTHON
81
81
  - If `the IPython kernel <https://ipython.org/>`__ is available, certain additional
82
- visualisations and line magics are made available.
82
+ visualizations and line magics are made available.
83
83
 
84
84
  * - .. py:data:: HAS_IPYWIDGETS
85
85
  - Monitoring widgets for jobs running on external backends can be provided if `ipywidgets
@@ -94,7 +94,7 @@ External Python Libraries
94
94
  interactivity features.
95
95
 
96
96
  * - .. py:data:: HAS_MATPLOTLIB
97
- - Qiskit provides several visualisation tools in the :mod:`.visualization` module.
97
+ - Qiskit provides several visualization tools in the :mod:`.visualization` module.
98
98
  Almost all of these are built using `Matplotlib <https://matplotlib.org/>`__, which must
99
99
  be installed in order to use them.
100
100
 
@@ -116,7 +116,7 @@ External Python Libraries
116
116
  :class:`.DAGCircuit` in certain modes.
117
117
 
118
118
  * - .. py:data:: HAS_PYDOT
119
- - For some graph visualisations, Qiskit uses `pydot <https://github.com/pydot/pydot>`__ as an
119
+ - For some graph visualizations, Qiskit uses `pydot <https://github.com/pydot/pydot>`__ as an
120
120
  interface to GraphViz (see :data:`HAS_GRAPHVIZ`).
121
121
 
122
122
  * - .. py:data:: HAS_PYGMENTS
@@ -134,7 +134,7 @@ External Python Libraries
134
134
  <https://qiskit.github.io/qiskit-qasm3-import>`__.
135
135
 
136
136
  * - .. py:data:: HAS_SEABORN
137
- - Qiskit provides several visualisation tools in the :mod:`.visualization` module. Some
137
+ - Qiskit provides several visualization tools in the :mod:`.visualization` module. Some
138
138
  of these are built using `Seaborn <https://seaborn.pydata.org/>`__, which must be installed
139
139
  in order to use them.
140
140
 
@@ -179,16 +179,16 @@ External Command-Line Tools
179
179
  :widths: 25 75
180
180
 
181
181
  * - .. py:data:: HAS_GRAPHVIZ
182
- - For some graph visualisations, Qiskit uses the `GraphViz <https://graphviz.org/>`__
183
- visualisation tool via its ``pydot`` interface (see :data:`HAS_PYDOT`).
182
+ - For some graph visualizations, Qiskit uses the `GraphViz <https://graphviz.org/>`__
183
+ visualization tool via its ``pydot`` interface (see :data:`HAS_PYDOT`).
184
184
 
185
185
  * - .. py:data:: HAS_PDFLATEX
186
- - Visualisation tools that use LaTeX in their output, such as the circuit drawers, require
186
+ - Visualization tools that use LaTeX in their output, such as the circuit drawers, require
187
187
  ``pdflatex`` to be available. You will generally need to ensure that you have a working
188
188
  LaTeX installation available, and the ``qcircuit.tex`` package.
189
189
 
190
190
  * - .. py:data:: HAS_PDFTOCAIRO
191
- - Visualisation tools that convert LaTeX-generated files into rasterised images use the
191
+ - Visualization tools that convert LaTeX-generated files into rasterized images use the
192
192
  ``pdftocairo`` tool. This is part of the `Poppler suite of PDF tools
193
193
  <https://poppler.freedesktop.org/>`__.
194
194
 
@@ -332,7 +332,7 @@ class Bloch:
332
332
  self.zlabel = ["$\\circlearrowleft$", "$\\circlearrowright$"]
333
333
  self.xlabel = ["$\\leftrightarrow$", "$\\updownarrow$"]
334
334
  else:
335
- raise Exception("No such convention.")
335
+ raise ValueError("No such convention.")
336
336
 
337
337
  def __str__(self):
338
338
  string = ""
@@ -438,7 +438,7 @@ class Bloch:
438
438
  if isinstance(state_or_vector, (list, np.ndarray, tuple)) and len(state_or_vector) == 3:
439
439
  vec = state_or_vector
440
440
  else:
441
- raise Exception("Position needs to be specified by a qubit " + "state or a 3D vector.")
441
+ raise TypeError("Position needs to be specified by a qubit state or a 3D vector.")
442
442
  self.annotations.append({"position": vec, "text": text, "opts": kwargs})
443
443
 
444
444
  def make_sphere(self):
@@ -630,11 +630,11 @@ class Bloch:
630
630
  def plot_vectors(self):
631
631
  """Plot vector"""
632
632
  # -X and Y data are switched for plotting purposes
633
- for k in range(len(self.vectors)):
633
+ for k, vector in enumerate(self.vectors):
634
634
 
635
- xs3d = self.vectors[k][1] * np.array([0, 1])
636
- ys3d = -self.vectors[k][0] * np.array([0, 1])
637
- zs3d = self.vectors[k][2] * np.array([0, 1])
635
+ xs3d = vector[1] * np.array([0, 1])
636
+ ys3d = -vector[0] * np.array([0, 1])
637
+ zs3d = vector[2] * np.array([0, 1])
638
638
 
639
639
  color = self.vector_color[np.mod(k, len(self.vector_color))]
640
640
 
@@ -660,15 +660,10 @@ class Bloch:
660
660
  def plot_points(self):
661
661
  """Plot points"""
662
662
  # -X and Y data are switched for plotting purposes
663
- for k in range(len(self.points)):
664
- num = len(self.points[k][0])
663
+ for k, point in enumerate(self.points):
664
+ num = len(point[0])
665
665
  dist = [
666
- np.sqrt(
667
- self.points[k][0][j] ** 2
668
- + self.points[k][1][j] ** 2
669
- + self.points[k][2][j] ** 2
670
- )
671
- for j in range(num)
666
+ np.sqrt(point[0][j] ** 2 + point[1][j] ** 2 + point[2][j] ** 2) for j in range(num)
672
667
  ]
673
668
  if any(abs(dist - dist[0]) / dist[0] > 1e-12):
674
669
  # combine arrays so that they can be sorted together
@@ -680,9 +675,9 @@ class Bloch:
680
675
  indperm = np.arange(num)
681
676
  if self.point_style[k] == "s":
682
677
  self.axes.scatter(
683
- np.real(self.points[k][1][indperm]),
684
- -np.real(self.points[k][0][indperm]),
685
- np.real(self.points[k][2][indperm]),
678
+ np.real(point[1][indperm]),
679
+ -np.real(point[0][indperm]),
680
+ np.real(point[2][indperm]),
686
681
  s=self.point_size[np.mod(k, len(self.point_size))],
687
682
  alpha=1,
688
683
  edgecolor=None,
@@ -699,9 +694,9 @@ class Bloch:
699
694
  marker = self.point_marker[np.mod(k, len(self.point_marker))]
700
695
  pnt_size = self.point_size[np.mod(k, len(self.point_size))]
701
696
  self.axes.scatter(
702
- np.real(self.points[k][1][indperm]),
703
- -np.real(self.points[k][0][indperm]),
704
- np.real(self.points[k][2][indperm]),
697
+ np.real(point[1][indperm]),
698
+ -np.real(point[0][indperm]),
699
+ np.real(point[2][indperm]),
705
700
  s=pnt_size,
706
701
  alpha=1,
707
702
  edgecolor=None,
@@ -713,9 +708,9 @@ class Bloch:
713
708
  elif self.point_style[k] == "l":
714
709
  color = self.point_color[np.mod(k, len(self.point_color))]
715
710
  self.axes.plot(
716
- np.real(self.points[k][1]),
717
- -np.real(self.points[k][0]),
718
- np.real(self.points[k][2]),
711
+ np.real(point[1]),
712
+ -np.real(point[0]),
713
+ np.real(point[2]),
719
714
  alpha=0.75,
720
715
  zdir="z",
721
716
  color=color,
@@ -14,21 +14,25 @@
14
14
 
15
15
  import re
16
16
  from collections import OrderedDict
17
+ from warnings import warn
17
18
 
18
19
  import numpy as np
19
20
 
20
21
  from qiskit.circuit import (
22
+ ClassicalRegister,
21
23
  Clbit,
24
+ ControlFlowOp,
22
25
  ControlledGate,
23
26
  Delay,
24
27
  Gate,
25
28
  Instruction,
26
29
  Measure,
30
+ QuantumCircuit,
31
+ Qubit,
27
32
  )
33
+ from qiskit.circuit.annotated_operation import AnnotatedOperation, InverseModifier, PowerModifier
28
34
  from qiskit.circuit.controlflow import condition_resources
29
35
  from qiskit.circuit.library import PauliEvolutionGate
30
- from qiskit.circuit import ClassicalRegister, QuantumCircuit, Qubit, ControlFlowOp
31
- from qiskit.circuit.annotated_operation import AnnotatedOperation, InverseModifier, PowerModifier
32
36
  from qiskit.circuit.tools import pi_check
33
37
  from qiskit.converters import circuit_to_dag
34
38
  from qiskit.utils import optionals as _optionals
@@ -112,7 +116,7 @@ def get_gate_ctrl_text(op, drawer, style=None, calibrations=None):
112
116
  gate_text = gate_text.replace("-", "\\mbox{-}")
113
117
  ctrl_text = f"$\\mathrm{{{ctrl_text}}}$"
114
118
 
115
- # Only captitalize internally-created gate or instruction names
119
+ # Only capitalize internally-created gate or instruction names
116
120
  elif (
117
121
  (gate_text == op.name and op_type not in (Gate, Instruction))
118
122
  or (gate_text == base_name and base_type not in (Gate, Instruction))
@@ -370,6 +374,29 @@ def generate_latex_label(label):
370
374
  return final_str.replace(" ", "\\,") # Put in proper spaces
371
375
 
372
376
 
377
+ def _get_valid_justify_arg(justify):
378
+ """Returns a valid `justify` argument, warning if necessary."""
379
+ if isinstance(justify, str):
380
+ justify = justify.lower()
381
+
382
+ if justify is None:
383
+ justify = "left"
384
+
385
+ if justify not in ("left", "right", "none"):
386
+ # This code should be changed to an error raise, once the deprecation is complete.
387
+ warn(
388
+ f"Setting QuantumCircuit.draw()’s or circuit_drawer()'s justify argument: {justify}, to a "
389
+ "value other than 'left', 'right', 'none' or None (='left'). Default 'left' will be used. "
390
+ "Support for invalid justify arguments is deprecated as of Qiskit 1.2.0. Starting no "
391
+ "earlier than 3 months after the release date, invalid arguments will error.",
392
+ DeprecationWarning,
393
+ 2,
394
+ )
395
+ justify = "left"
396
+
397
+ return justify
398
+
399
+
373
400
  def _get_layered_instructions(
374
401
  circuit, reverse_bits=False, justify=None, idle_wires=True, wire_order=None, wire_map=None
375
402
  ):
@@ -384,9 +411,10 @@ def _get_layered_instructions(
384
411
  reverse_bits (bool): If true the order of the bits in the registers is
385
412
  reversed.
386
413
  justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
387
- the circuit should be justified.
414
+ the circuit should be justified. If an invalid value is provided,
415
+ default `left` will be used.
388
416
  idle_wires (bool): Include idle wires. Default is True.
389
- wire_order (list): A list of ints that modifies the order of the bits
417
+ wire_order (list): A list of ints that modifies the order of the bits.
390
418
 
391
419
  Returns:
392
420
  Tuple(list,list,list): To be consumed by the visualizer directly.
@@ -394,11 +422,7 @@ def _get_layered_instructions(
394
422
  Raises:
395
423
  VisualizationError: if both reverse_bits and wire_order are entered.
396
424
  """
397
- if justify:
398
- justify = justify.lower()
399
-
400
- # default to left
401
- justify = justify if justify in ("right", "none") else "left"
425
+ justify = _get_valid_justify_arg(justify)
402
426
 
403
427
  if wire_map is not None:
404
428
  qubits = [bit for bit in wire_map if isinstance(bit, Qubit)]
@@ -28,21 +28,22 @@ from __future__ import annotations
28
28
 
29
29
  import logging
30
30
  import os
31
+ import shutil
31
32
  import subprocess
32
33
  import tempfile
33
- import shutil
34
34
  import typing
35
35
  from warnings import warn
36
36
 
37
37
  from qiskit import user_config
38
- from qiskit.utils import optionals as _optionals
39
38
  from qiskit.circuit import ControlFlowOp, Measure
39
+ from qiskit.utils import optionals as _optionals
40
+
41
+ from ..exceptions import VisualizationError
42
+ from ..utils import _trim as trim_image
43
+ from . import _utils
40
44
  from . import latex as _latex
41
- from . import text as _text
42
45
  from . import matplotlib as _matplotlib
43
- from . import _utils
44
- from ..utils import _trim as trim_image
45
- from ..exceptions import VisualizationError
46
+ from . import text as _text
46
47
 
47
48
  if typing.TYPE_CHECKING:
48
49
  from typing import Any
@@ -63,7 +64,7 @@ def circuit_drawer(
63
64
  reverse_bits: bool | None = None,
64
65
  justify: str | None = None,
65
66
  vertical_compression: str | None = "medium",
66
- idle_wires: bool = True,
67
+ idle_wires: bool | None = None,
67
68
  with_layout: bool = True,
68
69
  fold: int | None = None,
69
70
  # The type of ax is matplotlib.axes.Axes, but this is not a fixed dependency, so cannot be
@@ -115,7 +116,7 @@ def circuit_drawer(
115
116
 
116
117
  output: Select the output method to use for drawing the circuit.
117
118
  Valid choices are ``text``, ``mpl``, ``latex``, ``latex_source``.
118
- By default the `text` drawer is used unless the user config file
119
+ By default, the ``text`` drawer is used unless the user config file
119
120
  (usually ``~/.qiskit/settings.conf``) has an alternative backend set
120
121
  as the default. For example, ``circuit_drawer = latex``. If the output
121
122
  kwarg is set, that backend will always be used over the default in
@@ -131,17 +132,19 @@ def circuit_drawer(
131
132
  alternative value set. For example, ``circuit_reverse_bits = True``.
132
133
  plot_barriers: Enable/disable drawing barriers in the output
133
134
  circuit. Defaults to ``True``.
134
- justify: Options are ``left``, ``right`` or ``none``. If
135
- anything else is supplied, it defaults to left justified. It refers
136
- to where gates should be placed in the output circuit if there is
137
- an option. ``none`` results in each gate being placed in its own
138
- column.
135
+ justify: Options are ``"left"``, ``"right"`` or ``"none"`` (str).
136
+ If anything else is supplied, left justified will be used instead.
137
+ It refers to where gates should be placed in the output circuit if
138
+ there is an option. ``none`` results in each gate being placed in
139
+ its own column. Defaults to ``left``.
139
140
  vertical_compression: ``high``, ``medium`` or ``low``. It
140
141
  merges the lines generated by the `text` output so the drawing
141
142
  will take less vertical room. Default is ``medium``. Only used by
142
143
  the ``text`` output, will be silently ignored otherwise.
143
144
  idle_wires: Include idle wires (wires with no circuit elements)
144
- in output visualization. Default is ``True``.
145
+ in output visualization. Default is ``True`` unless the
146
+ user config file (usually ``~/.qiskit/settings.conf``) has an
147
+ alternative value set. For example, ``circuit_idle_wires = False``.
145
148
  with_layout: Include layout information, with labels on the
146
149
  physical layout. Default is ``True``.
147
150
  fold: Sets pagination. It can be disabled using -1. In ``text``,
@@ -200,6 +203,7 @@ def circuit_drawer(
200
203
  # Get default from config file else use text
201
204
  default_output = "text"
202
205
  default_reverse_bits = False
206
+ default_idle_wires = config.get("circuit_idle_wires", True)
203
207
  if config:
204
208
  default_output = config.get("circuit_drawer", "text")
205
209
  if default_output == "auto":
@@ -215,6 +219,9 @@ def circuit_drawer(
215
219
  if reverse_bits is None:
216
220
  reverse_bits = default_reverse_bits
217
221
 
222
+ if idle_wires is None:
223
+ idle_wires = default_idle_wires
224
+
218
225
  if wire_order is not None and reverse_bits:
219
226
  raise VisualizationError(
220
227
  "The wire_order option cannot be set when the reverse_bits option is True."
@@ -339,8 +346,8 @@ def circuit_drawer(
339
346
  )
340
347
  else:
341
348
  raise VisualizationError(
342
- "Invalid output type %s selected. The only valid choices "
343
- "are text, latex, latex_source, and mpl" % output
349
+ f"Invalid output type {output} selected. The only valid choices "
350
+ "are text, latex, latex_source, and mpl"
344
351
  )
345
352
  if image and interactive:
346
353
  image.show()
@@ -213,17 +213,22 @@ class QCircuitImage:
213
213
  self._latex.append([" "] * (self._img_depth + 1))
214
214
 
215
215
  # display the bit/register labels
216
- for wire in self._wire_map:
216
+ for wire, index in self._wire_map.items():
217
217
  if isinstance(wire, ClassicalRegister):
218
218
  register = wire
219
- index = self._wire_map[wire]
219
+ wire_label = get_wire_label(
220
+ "latex", register, index, layout=self._layout, cregbundle=self._cregbundle
221
+ )
220
222
  else:
221
223
  register, bit_index, reg_index = get_bit_reg_index(self._circuit, wire)
222
- index = bit_index if register is None else reg_index
224
+ wire_label = get_wire_label(
225
+ "latex",
226
+ register,
227
+ bit_index if register is None else reg_index,
228
+ layout=self._layout,
229
+ cregbundle=self._cregbundle,
230
+ )
223
231
 
224
- wire_label = get_wire_label(
225
- "latex", register, index, layout=self._layout, cregbundle=self._cregbundle
226
- )
227
232
  wire_label += " : "
228
233
  if self._initial_state:
229
234
  wire_label += "\\ket{{0}}" if isinstance(wire, Qubit) else "0"
@@ -234,7 +239,7 @@ class QCircuitImage:
234
239
  self._latex[pos][1] = "\\lstick{/_{_{" + str(register.size) + "}}} \\cw"
235
240
  wire_label = f"\\mathrm{{{wire_label}}}"
236
241
  else:
237
- pos = self._wire_map[wire]
242
+ pos = index
238
243
  self._latex[pos][0] = "\\nghost{" + wire_label + " & " + "\\lstick{" + wire_label
239
244
 
240
245
  def _get_image_depth(self):
@@ -410,7 +415,7 @@ class QCircuitImage:
410
415
  cwire_list = []
411
416
 
412
417
  if len(wire_list) == 1 and not node.cargs:
413
- self._latex[wire_list[0]][column] = "\\gate{%s}" % gate_text
418
+ self._latex[wire_list[0]][column] = f"\\gate{{{gate_text}}}"
414
419
 
415
420
  elif isinstance(op, ControlledGate):
416
421
  num_cols_op = self._build_ctrl_gate(op, gate_text, wire_list, column)
@@ -438,20 +443,20 @@ class QCircuitImage:
438
443
  self._latex[wire_min][col] = (
439
444
  f"\\multigate{{{wire_max - wire_min}}}{{{gate_text}}}_"
440
445
  + "<" * (len(str(wire_ind)) + 2)
441
- + "{%s}" % wire_ind
446
+ + f"{{{wire_ind}}}"
442
447
  )
443
448
  for wire in range(wire_min + 1, wire_max + 1):
444
449
  if wire < cwire_start:
445
- ghost_box = "\\ghost{%s}" % gate_text
450
+ ghost_box = f"\\ghost{{{gate_text}}}"
446
451
  if wire in wire_list:
447
452
  wire_ind = wire_list.index(wire)
448
453
  else:
449
- ghost_box = "\\cghost{%s}" % gate_text
454
+ ghost_box = f"\\cghost{{{gate_text}}}"
450
455
  if wire in cwire_list:
451
456
  wire_ind = cwire_list.index(wire)
452
457
  if wire in wire_list + cwire_list:
453
458
  self._latex[wire][col] = (
454
- ghost_box + "_" + "<" * (len(str(wire_ind)) + 2) + "{%s}" % wire_ind
459
+ ghost_box + "_" + "<" * (len(str(wire_ind)) + 2) + f"{{{wire_ind}}}"
455
460
  )
456
461
  else:
457
462
  self._latex[wire][col] = ghost_box
@@ -479,7 +484,7 @@ class QCircuitImage:
479
484
  elif isinstance(op.base_gate, (U1Gate, PhaseGate)):
480
485
  num_cols_op = self._build_symmetric_gate(op, gate_text, wire_list, col)
481
486
  else:
482
- self._latex[wireqargs[0]][col] = "\\gate{%s}" % gate_text
487
+ self._latex[wireqargs[0]][col] = f"\\gate{{{gate_text}}}"
483
488
  else:
484
489
  # Treat special cases of swap and rzz gates
485
490
  if isinstance(op.base_gate, (SwapGate, RZZGate)):
@@ -522,7 +527,7 @@ class QCircuitImage:
522
527
  )
523
528
  self._latex[wire_last][col] = "\\control \\qw"
524
529
  # Put side text to the right between bottom wire in wire_list and the one above it
525
- self._latex[wire_max - 1][col + 1] = "\\dstick{\\hspace{2.0em}%s} \\qw" % gate_text
530
+ self._latex[wire_max - 1][col + 1] = f"\\dstick{{\\hspace{{2.0em}}{gate_text}}} \\qw"
526
531
  return 4 # num_cols for side text gates
527
532
 
528
533
  def _build_measure(self, node, col):
@@ -539,11 +544,9 @@ class QCircuitImage:
539
544
  idx_str = str(self._circuit.find_bit(node.cargs[0]).registers[0][1])
540
545
  else:
541
546
  wire2 = self._wire_map[node.cargs[0]]
542
-
543
- self._latex[wire2][col] = "\\dstick{_{_{\\hspace{%sem}%s}}} \\cw \\ar @{<=} [-%s,0]" % (
544
- cond_offset,
545
- idx_str,
546
- str(wire2 - wire1),
547
+ self._latex[wire2][col] = (
548
+ f"\\dstick{{_{{_{{\\hspace{{{cond_offset}em}}{idx_str}}}}}}} "
549
+ f"\\cw \\ar @{{<=}} [-{str(wire2 - wire1)},0]"
547
550
  )
548
551
  else:
549
552
  wire2 = self._wire_map[node.cargs[0]]
@@ -568,7 +571,7 @@ class QCircuitImage:
568
571
  if node.op.label is not None:
569
572
  pos = indexes[0]
570
573
  label = node.op.label.replace(" ", "\\,")
571
- self._latex[pos][col] = "\\cds{0}{^{\\mathrm{%s}}}" % label
574
+ self._latex[pos][col] = f"\\cds{{0}}{{^{{\\mathrm{{{label}}}}}}}"
572
575
 
573
576
  def _add_controls(self, wire_list, ctrlqargs, ctrl_state, col):
574
577
  """Add one or more controls to a gate"""
@@ -610,21 +613,20 @@ class QCircuitImage:
610
613
  )
611
614
  gap = cwire - max(wire_list)
612
615
  control = "\\control" if op.condition[1] else "\\controlo"
613
- self._latex[cwire][col] = f"{control}" + " \\cw^(%s){^{\\mathtt{%s}}} \\cwx[-%s]" % (
614
- meas_offset,
615
- label,
616
- str(gap),
617
- )
616
+ self._latex[cwire][
617
+ col
618
+ ] = f"{control} \\cw^({meas_offset}){{^{{\\mathtt{{{label}}}}}}} \\cwx[-{str(gap)}]"
619
+
618
620
  # If condition is a register and cregbundle is false
619
621
  else:
620
622
  # First sort the val_bits in the order of the register bits in the circuit
621
623
  cond_wires = []
622
624
  cond_bits = []
623
- for wire in self._wire_map:
625
+ for wire, index in self._wire_map.items():
624
626
  reg, _, reg_index = get_bit_reg_index(self._circuit, wire)
625
627
  if reg == cond_reg:
626
628
  cond_bits.append(reg_index)
627
- cond_wires.append(self._wire_map[wire])
629
+ cond_wires.append(index)
628
630
 
629
631
  gap = cond_wires[0] - max(wire_list)
630
632
  prev_wire = cond_wires[0]