entropicalabs / openqaoa

Multi-backend SDK for quantum optimisation
MIT License
119 stars 58 forks source link

Bug Fix: Added missing constant term contribution in energy_expectation #197

Closed ezerc closed 1 year ago

ezerc commented 1 year ago

Description

The energy_expectation() function in utilities.oy did not account for constant terms, and the respective test wasa ring of disagrees Hamiltonian with vanishing constant.

I have fixed the issue by adding the constant after the averaging, I have modified the current test by adding a constant term to the ring of disagrees Hamiltonian and added a second test on a Minimum Vertex Cover Hamiltonian.

Checklist

Type of change

How Has This Been Tested?

Modified test_utilities.py as per in the description

codecov[bot] commented 1 year ago

Codecov Report

Merging #197 (9d39cb1) into dev (1fe7e02) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #197      +/-   ##
==========================================
+ Coverage   88.76%   88.79%   +0.02%     
==========================================
  Files          32       32              
  Lines        5786     5799      +13     
==========================================
+ Hits         5136     5149      +13     
  Misses        650      650              
Impacted Files Coverage Δ
tests/test_utilities.py 99.42% <100.00%> (+0.02%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

Q-lds commented 1 year ago

@vishal-ph, I leave you the honour of merging. My only question is whether we could have more tests ... but I couldn't think of any