-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BitArray.get_counts()
fails given an empty classical register
#12062
Comments
Shouldn't it return |
That array may be "empty" but it still has a shape. It just means there are 1024 instances of nothing. Also, following my suggestion means there are fewer special cases a user must worry about; for instance, it maintains that the dict's values will sum up to the total number of shots, even if the register is empty. |
Thanks @garrison . It looks like from_samples also breaks with num_bits=0, so we'd need to fix that too for full support. |
Environment
What is happening?
BitArray
is not fully tested with empty classical registers. For instance,get_counts()
fails during the reshape if the output has zero bits. It appears thatget_int_counts()
will have the same problem, too.How can we reproduce the issue?
results in
What should happen?
I expect a sensible result, such as
{"": 1024}
forget_counts()
or{0: 1024}
forget_int_counts()
.Any suggestions?
No response
The text was updated successfully, but these errors were encountered: