orquestra-core icon indicating copy to clipboard operation
orquestra-core copied to clipboard

Add method for retrieving constant term from PauliSum

Open AthenaCaesura opened this issue 2 years ago • 0 comments

Description

One of our scientists recently asked "what’s is the way to get a constant term from the PauliSum?" Currently the only way to do that is to iterate through all the terms like this [term for term in pauli_sum.terms if term.is_constant].

Previously you could do that like this: constant_term_energy = estimation_task.operator.terms.get((), 0.0). It would be nice to keep this format or something similar.

Deliverable

We should add a method to the PauliSum class, that will return the coefficient of the constant term.

Additional context

When naming your branch for the PR, make sure to put "ZQS-1181" somewhere in the name so that jira notifies us that the story has been completed.

AthenaCaesura avatar Sep 14 '22 14:09 AthenaCaesura