Closed LeDernier closed 1 year ago
Thank you. The issue arises when there are repeated strings in H.primitive. I wonder if a judicious call to H.reduce() could solve this for all cases. I've merged your code and expanded test coverage for this case.
Yes. "operator".reduce() should also solve the problem. It could be added in the method "convert" of the class "DensePauliExpectation". However, I don't know if that will have a negative effect in the rest of the code (I doubt it).
The coefficient associated to the identity in 2^n dimensions, I^n, was zero if there were other Pauli strings with zero coefficient (because all the Pauli strings with zero coefficient are mapped to the identity, so when creating "id_dict", the id associated to I^n would be the last Pauli string transformed into the identity and not 0). I just proposed a quick solution. It can be improved later.