prototype-qrao icon indicating copy to clipboard operation
prototype-qrao copied to clipboard

Add tests of small known solutions for translator

Open garrison opened this issue 2 years ago • 1 comments

What is the expected enhancement?

It would be nice to test whether QuantumRandomAccessEncoding.encode() (see encoding.py) encodes the Hamiltonian correctly (as stored in qubit_op, and -- for now, until #14 is merged -- offset) when given some small QuadraticPrograms explicitly. Having some explicit tests would fully ensure all the factors of 2 and minus signs are right. We are confident in its current state, but it's always better to have tests so things don't regress.

Qiskit Optimization has tests of a similar method, to_ising(), in test_ising.py.

Relevant information for understanding what the encode() method is meant to do can be found in the QRACs section of the background material.

garrison avatar May 25 '22 14:05 garrison

I've factored the part of the encode() method that contains all the factors of 2 and minus signs into its own staticmethod in eb9c4185e8bae0de2e7e47af2c3a36109eb22a6f.

It might still be nice to have a few end-to-end tests of encode(), but I now think the emphasis should be on testing this new _generate_ising_terms() static method. (I'm still open to improving the name of this protected method, as well.)

garrison avatar May 27 '22 00:05 garrison