qiskit 1.1.0rc1__cp38-abi3-win32.whl → 1.1.2__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 (69) hide show
  1. qiskit/VERSION.txt +1 -1
  2. qiskit/_accelerate.pyd +0 -0
  3. qiskit/assembler/__init__.py +5 -10
  4. qiskit/circuit/__init__.py +21 -153
  5. qiskit/circuit/_classical_resource_map.py +3 -0
  6. qiskit/circuit/classical/expr/__init__.py +1 -1
  7. qiskit/circuit/classical/types/__init__.py +5 -4
  8. qiskit/circuit/classicalfunction/__init__.py +9 -0
  9. qiskit/circuit/library/__init__.py +3 -19
  10. qiskit/circuit/library/data_preparation/pauli_feature_map.py +1 -1
  11. qiskit/circuit/library/n_local/two_local.py +1 -1
  12. qiskit/circuit/library/standard_gates/x.py +2 -0
  13. qiskit/circuit/parameterexpression.py +3 -0
  14. qiskit/circuit/parametervector.py +22 -16
  15. qiskit/circuit/quantumcircuit.py +1100 -200
  16. qiskit/converters/__init__.py +17 -2
  17. qiskit/dagcircuit/dagcircuit.py +8 -1
  18. qiskit/passmanager/passmanager.py +11 -11
  19. qiskit/primitives/__init__.py +15 -9
  20. qiskit/primitives/containers/__init__.py +1 -0
  21. qiskit/primitives/containers/bit_array.py +6 -2
  22. qiskit/primitives/containers/shape.py +3 -3
  23. qiskit/providers/__init__.py +49 -17
  24. qiskit/providers/backend.py +0 -6
  25. qiskit/providers/basic_provider/__init__.py +2 -23
  26. qiskit/providers/fake_provider/__init__.py +1 -1
  27. qiskit/providers/fake_provider/generic_backend_v2.py +5 -0
  28. qiskit/providers/models/__init__.py +2 -2
  29. qiskit/pulse/builder.py +2 -2
  30. qiskit/pulse/schedule.py +3 -3
  31. qiskit/qasm2/parse.py +8 -0
  32. qiskit/qasm3/exporter.py +2 -2
  33. qiskit/qobj/converters/pulse_instruction.py +6 -6
  34. qiskit/qpy/__init__.py +60 -62
  35. qiskit/qpy/binary_io/value.py +1 -1
  36. qiskit/quantum_info/operators/symplectic/pauli.py +18 -13
  37. qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +8 -4
  38. qiskit/result/__init__.py +6 -0
  39. qiskit/scheduler/__init__.py +10 -1
  40. qiskit/scheduler/methods/__init__.py +1 -8
  41. qiskit/synthesis/__init__.py +1 -6
  42. qiskit/synthesis/discrete_basis/generate_basis_approximations.py +1 -1
  43. qiskit/synthesis/discrete_basis/solovay_kitaev.py +22 -12
  44. qiskit/transpiler/__init__.py +5 -5
  45. qiskit/transpiler/layout.py +3 -3
  46. qiskit/transpiler/passes/__init__.py +4 -2
  47. qiskit/transpiler/passes/basis/basis_translator.py +2 -2
  48. qiskit/transpiler/passes/layout/vf2_layout.py +10 -4
  49. qiskit/transpiler/passes/layout/vf2_utils.py +2 -2
  50. qiskit/transpiler/passes/optimization/collect_cliffords.py +6 -15
  51. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +8 -1
  52. qiskit/transpiler/passes/routing/commuting_2q_gate_routing/pauli_2q_evolution_commutation.py +5 -1
  53. qiskit/transpiler/passes/routing/star_prerouting.py +5 -5
  54. qiskit/transpiler/passes/synthesis/unitary_synthesis.py +3 -0
  55. qiskit/transpiler/preset_passmanagers/__init__.py +29 -3
  56. qiskit/transpiler/target.py +1 -1
  57. qiskit/utils/__init__.py +3 -2
  58. qiskit/utils/parallel.py +24 -15
  59. qiskit/visualization/bloch.py +44 -1
  60. qiskit/visualization/dag_visualization.py +10 -3
  61. qiskit/visualization/gate_map.py +9 -1
  62. qiskit/visualization/pass_manager_visualization.py +9 -9
  63. qiskit/visualization/pulse_v2/device_info.py +58 -31
  64. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/METADATA +18 -18
  65. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/RECORD +69 -69
  66. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/WHEEL +1 -1
  67. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/LICENSE.txt +0 -0
  68. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/entry_points.txt +0 -0
  69. {qiskit-1.1.0rc1.dist-info → qiskit-1.1.2.dist-info}/top_level.txt +0 -0
qiskit/qpy/__init__.py CHANGED
@@ -11,9 +11,9 @@
11
11
  # that they have been altered from the originals.
12
12
 
13
13
  """
14
- ###########################################################
14
+ =====================================
15
15
  QPY serialization (:mod:`qiskit.qpy`)
16
- ###########################################################
16
+ =====================================
17
17
 
18
18
  .. currentmodule:: qiskit.qpy
19
19
 
@@ -32,9 +32,8 @@ which will preserve the Qiskit object exactly but will only work for a single Qi
32
32
  version (it is also
33
33
  `potentially insecure <https://docs.python.org/3/library/pickle.html#module-pickle>`__).
34
34
 
35
- *********
36
- Using QPY
37
- *********
35
+ Basic Usage
36
+ ===========
38
37
 
39
38
  Using QPY is defined to be straightforward and mirror the user API of the
40
39
  serializers in Python's standard library, ``pickle`` and ``json``. There are
@@ -128,7 +127,7 @@ with. The following table lists the QPY versions that were supported in every
128
127
  Qiskit (and qiskit-terra prior to Qiskit 1.0.0) release going back to the introduction
129
128
  of QPY in qiskit-terra 0.18.0.
130
129
 
131
- .. list-table: QPY Format Version History
130
+ .. list-table:: QPY Format Version History
132
131
  :header-rows: 1
133
132
 
134
133
  * - Qiskit (qiskit-terra for < 1.0.0) version
@@ -139,7 +138,7 @@ of QPY in qiskit-terra 0.18.0.
139
138
  - 12
140
139
  * - 1.0.2
141
140
  - 10, 11
142
- - 12
141
+ - 11
143
142
  * - 1.0.1
144
143
  - 10, 11
145
144
  - 11
@@ -248,9 +247,8 @@ of QPY in qiskit-terra 0.18.0.
248
247
 
249
248
  .. _qpy_format:
250
249
 
251
- **********
252
250
  QPY Format
253
- **********
251
+ ==========
254
252
 
255
253
  The QPY serialization format is a portable cross-platform binary
256
254
  serialization format for :class:`~qiskit.circuit.QuantumCircuit` objects in Qiskit. The basic
@@ -303,14 +301,14 @@ circuits in the data.
303
301
  .. _qpy_version_12:
304
302
 
305
303
  Version 12
306
- ==========
304
+ ----------
307
305
 
308
306
  Version 12 adds support for:
309
307
 
310
308
  * circuits containing memory-owning :class:`.expr.Var` variables.
311
309
 
312
310
  Changes to HEADER
313
- -----------------
311
+ ~~~~~~~~~~~~~~~~~
314
312
 
315
313
  The HEADER struct for an individual circuit has added three ``uint32_t`` counts of the input,
316
314
  captured and locally declared variables in the circuit. The new form looks like:
@@ -336,7 +334,7 @@ that, the data continues with custom definitions and instructions as in prior ve
336
334
 
337
335
 
338
336
  EXPR_VAR_DECLARATION
339
- --------------------
337
+ ~~~~~~~~~~~~~~~~~~~~
340
338
 
341
339
  An ``EXPR_VAR_DECLARATION`` defines an :class:`.expr.Var` instance that is standalone; that is, it
342
340
  represents a self-owned memory location rather than wrapping a :class:`.Clbit` or
@@ -367,7 +365,7 @@ Type code Meaning
367
365
 
368
366
 
369
367
  Changes to EXPR_VAR
370
- -------------------
368
+ ~~~~~~~~~~~~~~~~~~~
371
369
 
372
370
  The EXPR_VAR variable has gained a new type code and payload, in addition to the pre-existing ones:
373
371
 
@@ -400,7 +398,7 @@ Qiskit class Type code Payload
400
398
  .. _qpy_version_11:
401
399
 
402
400
  Version 11
403
- ==========
401
+ ----------
404
402
 
405
403
  Version 11 is identical to Version 10 except for the following.
406
404
  First, the names in the CUSTOM_INSTRUCTION blocks
@@ -418,7 +416,7 @@ MODIFIER struct.
418
416
  .. _modifier_qpy:
419
417
 
420
418
  MODIFIER
421
- --------
419
+ ~~~~~~~~
422
420
 
423
421
  This represents :class:`~qiskit.circuit.annotated_operation.Modifier`
424
422
 
@@ -441,7 +439,7 @@ operation, and in the third case the field ``power`` represents the power of the
441
439
  .. _qpy_version_10:
442
440
 
443
441
  Version 10
444
- ==========
442
+ ----------
445
443
 
446
444
  Version 10 adds support for:
447
445
 
@@ -454,7 +452,7 @@ is introduced, mapped to each symbolic library as follows: ``p`` refers to sympy
454
452
  encoding and ``e`` refers to symengine encoding.
455
453
 
456
454
  Changes to FILE_HEADER
457
- ----------------------
455
+ ~~~~~~~~~~~~~~~~~~~~~~
458
456
 
459
457
  The contents of FILE_HEADER after V10 are defined as a C struct as:
460
458
 
@@ -470,7 +468,7 @@ The contents of FILE_HEADER after V10 are defined as a C struct as:
470
468
  } FILE_HEADER_V10;
471
469
 
472
470
  Changes to LAYOUT
473
- -----------------
471
+ ~~~~~~~~~~~~~~~~~
474
472
 
475
473
  The ``LAYOUT`` struct is updated to have an additional ``input_qubit_count`` field.
476
474
  With version 10 the ``LAYOUT`` struct is now:
@@ -493,14 +491,14 @@ and ``_output_qubit_list`` in the :class:`~.TranspileLayout` object are ``None``
493
491
  .. _qpy_version_9:
494
492
 
495
493
  Version 9
496
- =========
494
+ ---------
497
495
 
498
496
  Version 9 adds support for classical :class:`~.expr.Expr` nodes and their associated
499
497
  :class:`~.types.Type`\\ s.
500
498
 
501
499
 
502
500
  EXPRESSION
503
- ----------
501
+ ~~~~~~~~~~
504
502
 
505
503
  An :class:`~.expr.Expr` node is represented by a stream of variable-width data. A node itself is
506
504
  represented by (in order in the byte stream):
@@ -532,7 +530,7 @@ Qiskit class Type code Payload
532
530
 
533
531
 
534
532
  EXPR_TYPE
535
- ---------
533
+ ~~~~~~~~~
536
534
 
537
535
  A :class:`~.types.Type` is encoded by a single-byte ASCII ``char`` that encodes the kind of type,
538
536
  followed by a payload that varies depending on the type. The defined codes are:
@@ -547,7 +545,7 @@ Qiskit class Type code Payload
547
545
 
548
546
 
549
547
  EXPR_VAR
550
- --------
548
+ ~~~~~~~~
551
549
 
552
550
  This represents a runtime variable of a :class:`~.expr.Var` node. These are a type code, followed
553
551
  by a type-code-specific payload:
@@ -564,7 +562,7 @@ Python class Type code Payload
564
562
 
565
563
 
566
564
  EXPR_VALUE
567
- ----------
565
+ ~~~~~~~~~~
568
566
 
569
567
  This represents a literal object in the classical type system, such as an integer. Currently there
570
568
  are very few such literals. These are encoded as a type code, followed by a type-code-specific
@@ -582,7 +580,7 @@ Python type Type code Payload
582
580
 
583
581
 
584
582
  Changes to INSTRUCTION
585
- ----------------------
583
+ ~~~~~~~~~~~~~~~~~~~~~~
586
584
 
587
585
  To support the use of :class:`~.expr.Expr` nodes in the fields :attr:`.IfElseOp.condition`,
588
586
  :attr:`.WhileLoopOp.condition` and :attr:`.SwitchCaseOp.target`, the INSTRUCTION struct is changed
@@ -629,7 +627,7 @@ Value Effects
629
627
 
630
628
 
631
629
  Changes to INSTRUCTION_PARAM
632
- ----------------------------
630
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
633
631
 
634
632
  A new type code ``x`` is added that defines an EXPRESSION parameter.
635
633
 
@@ -637,7 +635,7 @@ A new type code ``x`` is added that defines an EXPRESSION parameter.
637
635
  .. _qpy_version_8:
638
636
 
639
637
  Version 8
640
- =========
638
+ ---------
641
639
 
642
640
  Version 8 adds support for handling a :class:`~.TranspileLayout` stored in the
643
641
  :attr:`.QuantumCircuit.layout` attribute. In version 8 immediately following the
@@ -646,7 +644,7 @@ calibrations block at the end of the circuit payload there is now the
646
644
  :class:`~.TranspileLayout` class.
647
645
 
648
646
  LAYOUT
649
- ------
647
+ ~~~~~~
650
648
 
651
649
  .. code-block:: c
652
650
 
@@ -668,7 +666,7 @@ are ``initial_layout_size`` ``INITIAL_LAYOUT_BIT`` structs to define the
668
666
  :attr:`.TranspileLayout.initial_layout` attribute.
669
667
 
670
668
  INITIAL_LAYOUT_BIT
671
- ------------------
669
+ ~~~~~~~~~~~~~~~~~~
672
670
 
673
671
  .. code-block:: c
674
672
 
@@ -694,7 +692,7 @@ circuit.
694
692
  .. _qpy_version_7:
695
693
 
696
694
  Version 7
697
- =========
695
+ ---------
698
696
 
699
697
  Version 7 adds support for :class:`.~Reference` instruction and serialization of
700
698
  a :class:`.~ScheduleBlock` program while keeping its reference to subroutines::
@@ -740,7 +738,7 @@ condition of an INSTRUCTION field <qpy_instructions>`.
740
738
  .. _qpy_version_6:
741
739
 
742
740
  Version 6
743
- =========
741
+ ---------
744
742
 
745
743
  Version 6 adds support for :class:`.~ScalableSymbolicPulse`. These objects are saved and read
746
744
  like `SymbolicPulse` objects, and the class name is added to the data to correctly handle
@@ -767,7 +765,7 @@ identical to :ref:`qpy_version_5`.
767
765
  .. _qpy_version_5:
768
766
 
769
767
  Version 5
770
- =========
768
+ ---------
771
769
 
772
770
  Version 5 changes from :ref:`qpy_version_4` by adding support for :class:`.~ScheduleBlock`
773
771
  and changing two payloads the INSTRUCTION metadata payload and the CUSTOM_INSTRUCTION block.
@@ -802,7 +800,7 @@ immediately follows the file header block to represent the program type stored i
802
800
  .. _qpy_schedule_block:
803
801
 
804
802
  SCHEDULE_BLOCK
805
- --------------
803
+ ~~~~~~~~~~~~~~
806
804
 
807
805
  :class:`~.ScheduleBlock` is first supported in QPY Version 5. This allows
808
806
  users to save pulse programs in the QPY binary format as follows:
@@ -827,7 +825,7 @@ no extra option is required to save the schedule block.
827
825
  .. _qpy_schedule_block_header:
828
826
 
829
827
  SCHEDULE_BLOCK_HEADER
830
- ---------------------
828
+ ~~~~~~~~~~~~~~~~~~~~~
831
829
 
832
830
  :class:`~.ScheduleBlock` block starts with the following header:
833
831
 
@@ -846,7 +844,7 @@ attached to the schedule.
846
844
  .. _qpy_schedule_alignments:
847
845
 
848
846
  SCHEDULE_BLOCK_ALIGNMENTS
849
- -------------------------
847
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
850
848
 
851
849
  Then, alignment context of the schedule block starts with ``char``
852
850
  representing the supported context type followed by the :ref:`qpy_sequence` block representing
@@ -864,7 +862,7 @@ stored in the context parameters.
864
862
  .. _qpy_schedule_instructions:
865
863
 
866
864
  SCHEDULE_BLOCK_INSTRUCTIONS
867
- ---------------------------
865
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
868
866
 
869
867
  This alignment block is further followed by ``num_element`` length of block elements which may
870
868
  consist of nested schedule blocks and schedule instructions.
@@ -889,7 +887,7 @@ The mapping of type char to the instruction subclass is defined as follows:
889
887
  .. _qpy_schedule_operands:
890
888
 
891
889
  SCHEDULE_BLOCK_OPERANDS
892
- -----------------------
890
+ ~~~~~~~~~~~~~~~~~~~~~~~
893
891
 
894
892
  The operands of these instances can be serialized through the standard QPY value serialization
895
893
  mechanism, however there are special object types that only appear in the schedule operands.
@@ -906,7 +904,7 @@ Special objects start with the following type key:
906
904
  .. _qpy_schedule_channel:
907
905
 
908
906
  CHANNEL
909
- -------
907
+ ~~~~~~~
910
908
 
911
909
  Channel block starts with channel subtype ``char`` that maps an object data to
912
910
  :class:`~qiskit.pulse.channels.Channel` subclass. Mapping is defined as follows:
@@ -923,7 +921,7 @@ The key is immediately followed by the channel index serialized as the INSTRUCTI
923
921
  .. _qpy_schedule_waveform:
924
922
 
925
923
  Waveform
926
- --------
924
+ ~~~~~~~~
927
925
 
928
926
  Waveform block starts with WAVEFORM header:
929
927
 
@@ -945,7 +943,7 @@ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
945
943
  .. _qpy_schedule_symbolic_pulse:
946
944
 
947
945
  SymbolicPulse
948
- -------------
946
+ ~~~~~~~~~~~~~
949
947
 
950
948
  SymbolicPulse block starts with SYMBOLIC_PULSE header:
951
949
 
@@ -979,7 +977,7 @@ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
979
977
  .. _qpy_mapping:
980
978
 
981
979
  MAPPING
982
- -------
980
+ ~~~~~~~
983
981
 
984
982
  The MAPPING is a representation for arbitrary mapping object. This is a fixed length
985
983
  :ref:`qpy_sequence` of key-value pair represented by the MAP_ITEM payload.
@@ -1001,7 +999,7 @@ QPY serializable ``type``.
1001
999
  .. _qpy_circuit_calibrations:
1002
1000
 
1003
1001
  CIRCUIT_CALIBRATIONS
1004
- --------------------
1002
+ ~~~~~~~~~~~~~~~~~~~~
1005
1003
 
1006
1004
  The CIRCUIT_CALIBRATIONS block is a dictionary to define pulse calibrations of the custom
1007
1005
  instruction set. This block starts with the following CALIBRATION header:
@@ -1036,7 +1034,7 @@ Finally, :ref:`qpy_schedule_block` payload is packed for each CALIBRATION_DEF en
1036
1034
  .. _qpy_instruction_v5:
1037
1035
 
1038
1036
  INSTRUCTION
1039
- -----------
1037
+ ~~~~~~~~~~~
1040
1038
 
1041
1039
  The INSTRUCTION block was modified to add two new fields ``num_ctrl_qubits`` and ``ctrl_state``
1042
1040
  which are used to model the :attr:`.ControlledGate.num_ctrl_qubits` and
@@ -1062,7 +1060,7 @@ The rest of the instruction payload is the same. You can refer to
1062
1060
  :ref:`qpy_instructions` for the details of the full payload.
1063
1061
 
1064
1062
  CUSTOM_INSTRUCTION
1065
- ------------------
1063
+ ~~~~~~~~~~~~~~~~~~
1066
1064
 
1067
1065
  The CUSTOM_INSTRUCTION block in QPY version 5 adds a new field
1068
1066
  ``base_gate_size`` which is used to define the size of the
@@ -1105,7 +1103,7 @@ indicate the custom instruction is a custom :class:`~.ControlledGate`.
1105
1103
  .. _qpy_version_4:
1106
1104
 
1107
1105
  Version 4
1108
- =========
1106
+ ---------
1109
1107
 
1110
1108
  Version 4 is identical to :ref:`qpy_version_3` except that it adds 2 new type strings
1111
1109
  to the INSTRUCTION_PARAM struct, ``z`` to represent ``None`` (which is encoded as
@@ -1135,7 +1133,7 @@ part of the circuit or not.
1135
1133
  .. _qpy_range_pack:
1136
1134
 
1137
1135
  RANGE
1138
- -----
1136
+ ~~~~~
1139
1137
 
1140
1138
  A RANGE is a representation of a ``range`` object. It is defined as:
1141
1139
 
@@ -1150,7 +1148,7 @@ A RANGE is a representation of a ``range`` object. It is defined as:
1150
1148
  .. _qpy_sequence:
1151
1149
 
1152
1150
  SEQUENCE
1153
- --------
1151
+ ~~~~~~~~
1154
1152
 
1155
1153
  A SEQUENCE is a representation of an arbitrary sequence object. As sequence are just fixed length
1156
1154
  containers of arbitrary python objects their QPY can't fully represent any sequence,
@@ -1172,7 +1170,7 @@ into proper type, e.g. ``tuple``, afterwards.
1172
1170
  .. _qpy_version_3:
1173
1171
 
1174
1172
  Version 3
1175
- =========
1173
+ ---------
1176
1174
 
1177
1175
  Version 3 of the QPY format is identical to :ref:`qpy_version_2` except that it defines
1178
1176
  a struct format to represent a :class:`~qiskit.circuit.library.PauliEvolutionGate`
@@ -1187,7 +1185,7 @@ as follows:
1187
1185
  .. _pauli_evo_qpy:
1188
1186
 
1189
1187
  PAULI_EVOLUTION
1190
- ---------------
1188
+ ~~~~~~~~~~~~~~~
1191
1189
 
1192
1190
  This represents the high level :class:`~qiskit.circuit.library.PauliEvolutionGate`
1193
1191
 
@@ -1215,7 +1213,7 @@ the :class:`.EvolutionSynthesis` class used by the gate.
1215
1213
  .. _qpy_pauli_sum_op:
1216
1214
 
1217
1215
  SPARSE_PAULI_OP_LIST_ELEM
1218
- -------------------------
1216
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
1219
1217
 
1220
1218
  This represents an instance of :class:`.SparsePauliOp`.
1221
1219
 
@@ -1239,7 +1237,7 @@ parameters are defined below as :ref:`qpy_param_vector`.
1239
1237
  .. _qpy_param_vector:
1240
1238
 
1241
1239
  PARAMETER_VECTOR_ELEMENT
1242
- ------------------------
1240
+ ~~~~~~~~~~~~~~~~~~~~~~~~
1243
1241
 
1244
1242
  A PARAMETER_VECTOR_ELEMENT represents a :class:`~qiskit.circuit.ParameterVectorElement`
1245
1243
  object the data for a INSTRUCTION_PARAM. The contents of the PARAMETER_VECTOR_ELEMENT are
@@ -1261,7 +1259,7 @@ the parameter's vector name.
1261
1259
 
1262
1260
 
1263
1261
  PARAMETER_EXPR
1264
- --------------
1262
+ ~~~~~~~~~~~~~~
1265
1263
 
1266
1264
  Additionally, since QPY format version v3 distinguishes between a
1267
1265
  :class:`~qiskit.circuit.Parameter` and :class:`~qiskit.circuit.ParameterVectorElement`
@@ -1315,14 +1313,14 @@ and size will be 0 as the value will just be the same as the key. If
1315
1313
  .. _qpy_version_2:
1316
1314
 
1317
1315
  Version 2
1318
- =========
1316
+ ---------
1319
1317
 
1320
1318
  Version 2 of the QPY format is identical to version 1 except for the HEADER
1321
1319
  section is slightly different. You can refer to the :ref:`qpy_version_1` section
1322
1320
  for the details on the rest of the payload format.
1323
1321
 
1324
1322
  HEADER
1325
- ------
1323
+ ~~~~~~
1326
1324
 
1327
1325
  The contents of HEADER are defined as a C struct are:
1328
1326
 
@@ -1352,10 +1350,10 @@ object which is represented by a PARAM struct (see below), ``e`` defines a
1352
1350
  .. _qpy_version_1:
1353
1351
 
1354
1352
  Version 1
1355
- =========
1353
+ ---------
1356
1354
 
1357
1355
  HEADER
1358
- ------
1356
+ ~~~~~~
1359
1357
 
1360
1358
  The contents of HEADER as defined as a C struct are:
1361
1359
 
@@ -1375,7 +1373,7 @@ This is immediately followed by ``name_size`` bytes of utf8 data for the name
1375
1373
  of the circuit.
1376
1374
 
1377
1375
  METADATA
1378
- --------
1376
+ ~~~~~~~~
1379
1377
 
1380
1378
  The METADATA field is a UTF8 encoded JSON string. After reading the HEADER
1381
1379
  (which is a fixed size at the start of the QPY file) and the ``name`` string
@@ -1385,7 +1383,7 @@ the metadata for the circuit.
1385
1383
  .. _qpy_registers:
1386
1384
 
1387
1385
  REGISTERS
1388
- ---------
1386
+ ~~~~~~~~~
1389
1387
 
1390
1388
  The contents of REGISTERS is a number of REGISTER object. If num_registers is
1391
1389
  > 0 then after reading METADATA you read that number of REGISTER structs defined
@@ -1435,7 +1433,7 @@ the register ``qr`` would be a standalone register. While something like::
1435
1433
  .. _qpy_custom_definition:
1436
1434
 
1437
1435
  CUSTOM_DEFINITIONS
1438
- ------------------
1436
+ ~~~~~~~~~~~~~~~~~~
1439
1437
 
1440
1438
  This section specifies custom definitions for any of the instructions in the circuit.
1441
1439
 
@@ -1475,7 +1473,7 @@ it will be a :class:`~qiskit.circuit.Instruction` object.
1475
1473
  .. _qpy_instructions:
1476
1474
 
1477
1475
  INSTRUCTIONS
1478
- ------------
1476
+ ~~~~~~~~~~~~
1479
1477
 
1480
1478
  The contents of INSTRUCTIONS is a list of INSTRUCTION metadata objects
1481
1479
 
@@ -1551,7 +1549,7 @@ and in QPY :ref:`qpy_version_3` ``'v'`` represents a
1551
1549
  .. _qpy_param_struct:
1552
1550
 
1553
1551
  PARAMETER
1554
- ---------
1552
+ ~~~~~~~~~
1555
1553
 
1556
1554
  A PARAMETER represents a :class:`~qiskit.circuit.Parameter` object the data for
1557
1555
  a INSTRUCTION_PARAM. The contents of the PARAMETER are defined as:
@@ -1569,7 +1567,7 @@ parameter name.
1569
1567
  .. _qpy_param_expr:
1570
1568
 
1571
1569
  PARAMETER_EXPR
1572
- --------------
1570
+ ~~~~~~~~~~~~~~
1573
1571
 
1574
1572
  A PARAMETER_EXPR represents a :class:`~qiskit.circuit.ParameterExpression`
1575
1573
  object that the data for an INSTRUCTION_PARAM. The contents of a PARAMETER_EXPR
@@ -1608,7 +1606,7 @@ Finally, if type is ``i`` it represents an integer which is an ``int64_t``.
1608
1606
  .. _qpy_complex:
1609
1607
 
1610
1608
  COMPLEX
1611
- -------
1609
+ ~~~~~~~
1612
1610
 
1613
1611
  When representing a double precision complex value in QPY the following
1614
1612
  struct is used:
@@ -45,7 +45,7 @@ def _write_parameter_vec(file_obj, obj):
45
45
  struct.pack(
46
46
  formats.PARAMETER_VECTOR_ELEMENT_PACK,
47
47
  len(name_bytes),
48
- obj._vector._size,
48
+ len(obj._vector),
49
49
  obj.uuid.bytes,
50
50
  obj._index,
51
51
  )
@@ -77,7 +77,7 @@ class Pauli(BasePauli):
77
77
 
78
78
  An :math:`n`-qubit Pauli may be represented by a string consisting of
79
79
  :math:`n` characters from ``['I', 'X', 'Y', 'Z']``, and optionally phase
80
- coefficient in :math:`['', '-i', '-', 'i']`. For example: ``XYZ`` or
80
+ coefficient in ``['', '-i', '-', 'i']``. For example: ``'XYZ'`` or
81
81
  ``'-iZIZ'``.
82
82
 
83
83
  In the string representation qubit-0 corresponds to the right-most
@@ -144,13 +144,13 @@ class Pauli(BasePauli):
144
144
 
145
145
  .. code-block:: python
146
146
 
147
- p = Pauli('-iXYZ')
147
+ P = Pauli('-iXYZ')
148
148
 
149
149
  print('P[0] =', repr(P[0]))
150
150
  print('P[1] =', repr(P[1]))
151
151
  print('P[2] =', repr(P[2]))
152
152
  print('P[:] =', repr(P[:]))
153
- print('P[::-1] =, repr(P[::-1]))
153
+ print('P[::-1] =', repr(P[::-1]))
154
154
  """
155
155
 
156
156
  # Set the max Pauli string size before truncation
@@ -160,21 +160,23 @@ class Pauli(BasePauli):
160
160
  _CANONICAL_PHASE_LABEL = {"": 0, "-i": 1, "-": 2, "i": 3}
161
161
 
162
162
  def __init__(self, data: str | tuple | Pauli | ScalarOp | QuantumCircuit | None = None):
163
- """Initialize the Pauli.
163
+ r"""Initialize the Pauli.
164
164
 
165
165
  When using the symplectic array input data both z and x arguments must
166
166
  be provided, however the first (z) argument can be used alone for string
167
- label, Pauli operator, or ScalarOp input data.
167
+ label, Pauli operator, or :class:`.ScalarOp` input data.
168
168
 
169
169
  Args:
170
170
  data (str or tuple or Pauli or ScalarOp): input data for Pauli. If input is
171
- a tuple it must be of the form ``(z, x)`` or (z, x, phase)`` where
172
- ``z`` and ``x`` are boolean Numpy arrays, and phase is an integer from Z_4.
171
+ a tuple it must be of the form ``(z, x)`` or ``(z, x, phase)`` where
172
+ ``z`` and ``x`` are boolean Numpy arrays, and phase is an integer from
173
+ :math:`\mathbb{Z}_4`.
173
174
  If input is a string, it must be a concatenation of a phase and a Pauli string
174
- (e.g. 'XYZ', '-iZIZ') where a phase string is a combination of at most three
175
- characters from ['+', '-', ''], ['1', ''], and ['i', 'j', ''] in this order,
176
- e.g. '', '-1j' while a Pauli string is 1 or more characters of 'I', 'X', 'Y' or 'Z',
177
- e.g. 'Z', 'XIYY'.
175
+ (e.g. ``'XYZ', '-iZIZ'``) where a phase string is a combination of at most three
176
+ characters from ``['+', '-', '']``, ``['1', '']``, and ``['i', 'j', '']`` in this order,
177
+ e.g. ``''``, ``'-1j'`` while a Pauli string is 1 or more
178
+ characters of ``'I'``, ``'X'``, ``'Y'``, or ``'Z'``,
179
+ e.g. ``'Z'``, ``'XIYY'``.
178
180
 
179
181
  Raises:
180
182
  QiskitError: if input array is invalid shape.
@@ -736,8 +738,11 @@ class Pauli(BasePauli):
736
738
  n_qubits = num_qubits
737
739
  if layout is None:
738
740
  layout = list(range(self.num_qubits))
739
- elif any(x >= n_qubits for x in layout):
740
- raise QiskitError("Provided layout contains indices outside the number of qubits.")
741
+ else:
742
+ if any(x < 0 or x >= n_qubits for x in layout):
743
+ raise QiskitError("Provided layout contains indices outside the number of qubits.")
744
+ if len(set(layout)) != len(layout):
745
+ raise QiskitError("Provided layout contains duplicate indices.")
741
746
  new_op = type(self)("I" * n_qubits)
742
747
  return new_op.compose(self, qargs=layout)
743
748
 
@@ -54,7 +54,7 @@ class SparsePauliOp(LinearOp):
54
54
  :class:`~qiskit.quantum_info.Operator` in terms of N-qubit
55
55
  :class:`~qiskit.quantum_info.PauliList` and complex coefficients.
56
56
 
57
- It can be used for performing operator arithmetic for hundred of qubits
57
+ It can be used for performing operator arithmetic for hundreds of qubits
58
58
  if the number of non-zero Pauli basis terms is sufficiently small.
59
59
 
60
60
  The Pauli basis components are stored as a
@@ -1139,7 +1139,6 @@ class SparsePauliOp(LinearOp):
1139
1139
  specified will be applied without any expansion. If layout is
1140
1140
  None, the operator will be expanded to the given number of qubits.
1141
1141
 
1142
-
1143
1142
  Returns:
1144
1143
  A new :class:`.SparsePauliOp` with the provided layout applied
1145
1144
  """
@@ -1159,10 +1158,15 @@ class SparsePauliOp(LinearOp):
1159
1158
  f"applied to a {n_qubits} qubit operator"
1160
1159
  )
1161
1160
  n_qubits = num_qubits
1162
- if layout is not None and any(x >= n_qubits for x in layout):
1163
- raise QiskitError("Provided layout contains indices outside the number of qubits.")
1164
1161
  if layout is None:
1165
1162
  layout = list(range(self.num_qubits))
1163
+ else:
1164
+ if any(x < 0 or x >= n_qubits for x in layout):
1165
+ raise QiskitError("Provided layout contains indices outside the number of qubits.")
1166
+ if len(set(layout)) != len(layout):
1167
+ raise QiskitError("Provided layout contains duplicate indices.")
1168
+ if self.num_qubits == 0:
1169
+ return type(self)(["I" * n_qubits] * self.size, self.coeffs)
1166
1170
  new_op = type(self)("I" * n_qubits)
1167
1171
  return new_op.compose(self, qargs=layout)
1168
1172
 
qiskit/result/__init__.py CHANGED
@@ -17,6 +17,9 @@ Experiment Results (:mod:`qiskit.result`)
17
17
 
18
18
  .. currentmodule:: qiskit.result
19
19
 
20
+ Core classes
21
+ ============
22
+
20
23
  .. autosummary::
21
24
  :toctree: ../stubs/
22
25
 
@@ -24,6 +27,9 @@ Experiment Results (:mod:`qiskit.result`)
24
27
  ResultError
25
28
  Counts
26
29
 
30
+ Marginalization
31
+ ===============
32
+
27
33
  .. autofunction:: marginal_counts
28
34
  .. autofunction:: marginal_distribution
29
35
  .. autofunction:: marginal_memory
@@ -19,13 +19,22 @@ Circuit Scheduler (:mod:`qiskit.scheduler`)
19
19
 
20
20
  A circuit scheduler compiles a circuit program to a pulse program.
21
21
 
22
+ Core API
23
+ ========
24
+
22
25
  .. autoclass:: ScheduleConfig
23
26
 
24
27
  .. currentmodule:: qiskit.scheduler.schedule_circuit
25
28
  .. autofunction:: schedule_circuit
26
29
  .. currentmodule:: qiskit.scheduler
27
30
 
28
- .. automodule:: qiskit.scheduler.methods
31
+ Pulse scheduling methods
32
+ ========================
33
+
34
+ .. currentmodule:: qiskit.scheduler.methods
35
+ .. autofunction:: as_soon_as_possible
36
+ .. autofunction:: as_late_as_possible
37
+ .. currentmodule:: qiskit.scheduler
29
38
  """
30
39
  from qiskit.scheduler import schedule_circuit
31
40
  from qiskit.scheduler.config import ScheduleConfig
@@ -10,13 +10,6 @@
10
10
  # copyright notice, and modified files need to carry a notice indicating
11
11
  # that they have been altered from the originals.
12
12
 
13
- """
14
- .. currentmodule:: qiskit.scheduler.methods
15
-
16
- Pulse scheduling methods.
17
-
18
- .. autofunction:: as_soon_as_possible
19
- .. autofunction:: as_late_as_possible
20
- """
13
+ """Scheduling methods."""
21
14
 
22
15
  from qiskit.scheduler.methods.basic import as_soon_as_possible, as_late_as_possible
@@ -99,12 +99,7 @@ Decomposition of general :math:`2^n \times 2^n` unitary matrices for any number
99
99
 
100
100
  .. autofunction:: qs_decomposition
101
101
 
102
- The Approximate Quantum Compiler is available here:
103
-
104
- .. autosummary::
105
- :toctree: ../stubs/
106
-
107
- qiskit.synthesis.unitary.aqc
102
+ The Approximate Quantum Compiler is available as the module :mod:`qiskit.synthesis.unitary.aqc`.
108
103
 
109
104
  One-Qubit Synthesis
110
105
  ===================