Closed nonhermitian closed 1 month ago
@nonhermitian I'm wondering if the currently available behaviour meets your needs?
data = list(job.result()[0].data.values())
In short, .data
here is mapping type, so you can do whatever you usually do with mapping types, including getting all the names as list(job.result()[0].data)
.
(Also, btw, this is technically a qiskit-core issue because that's where primitive types/abstraction are defined.)
Ok thanks! I think that probably does the same thing that I would want. Since I was looking to wrap runtime to get backend.run()
back I ended up using item.join_data().get_counts()
(which I was also unaware of until recent) to combine and then chunk it based on the num_bits
.
What is the expected feature or enhancement?
Currently one has to know the name of the classical register in order to extract values from a data object. This is not ideal. Namely, the following circuits do the same thing, have no user input into the naming of the registers, but need to have the their corresponding data accessed differently.
Unless I know the register names, I cannot access the data. Currently there are two ways to know these values without having the circuit available. One is the private fields method,
data._FIELDS
, and the other is iterating over the data object itself, which returnsstr
values for the registers. However, as an user I rarely care about the register name itself, it is a free variable that does not change the computation, but rather just want access to the data, most commonly from a single register.Since only the register order matters, it would be nice if one could iterate through the
data
object and obtain the data directly without knowing the register names.Acceptance criteria For the above examples it should be possible to extract that
BitArray
data for the registers for both circuits in a manner such as:that is independent of the underlying register name.