prototype-qrao
prototype-qrao copied to clipboard
Add tests of small known solutions for translator
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 QuadraticProgram
s 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.
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.)