qiskit/releasenotes/notes/0.22/update-prob-quasi-2044285a4...

22 lines
755 B
YAML

---
upgrade:
- |
Updated :class:`~qiskit.result.ProbDistribution` and :class:`~qiskit.result.QuasiDistribution`
to store the information of the number of bits if bitstrings without prefix "0b" are given.
:meth:`.ProbDistribution.binary_probabilities` and
:meth:`.QuasiDistribution.binary_probabilities` use the stored number of bits
as the default value of the number of bits.
.. code-block: python
import qiskit.result import ProbDistribution, QuasiDistribution
prob = ProbDistribution({"00": 0.5, "01": 0.5})
quasi = QuasiDistribution({"00": 0.5, "01": 0.5})
print(prob.binary_probabilities())
# {'00': 0.5, '01': 0.5}
print(quasi.binary_probabilities())
# {'00': 0.5, '01': 0.5}