dwave-system icon indicating copy to clipboard operation
dwave-system copied to clipboard

Handle exception when BQM is passed to DQM sampler

Open Abdullahjavednesar opened this issue 3 years ago • 4 comments

Closes #375

Before BinaryQuadraticModel objects when passed to DQM sampler, raised an exception which wasn't informative.

>>> import dimod
>>> from dwave.system import LeapHybridDQMSampler
>>> bqm = dimod.BinaryQuadraticModel('SPIN')
>>> LeapHybridDQMSampler().sample_dqm(bqm)
...
AttributeError: 'BinaryQuadraticModel' object has no attribute 'num_variable_interactions'

Now (after fix)

>>> LeapHybridDQMSampler().sample_dqm(bqm)
TypeError: Expecting DiscreteQuadraticModel object, got <class 'dimod.binary.binary_quadratic_model.BinaryQuadraticModel'>

Abdullahjavednesar avatar Feb 28 '22 15:02 Abdullahjavednesar

Hi @arcondello, can you please take a look!

Abdullahjavednesar avatar Mar 01 '22 18:03 Abdullahjavednesar

Addressed both the comments. Thanks for the review!

Abdullahjavednesar avatar Mar 01 '22 19:03 Abdullahjavednesar

Codecov Report

Merging #444 (ff432b4) into master (4fa4b27) will decrease coverage by 2.93%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #444      +/-   ##
==========================================
- Coverage   90.52%   87.59%   -2.94%     
==========================================
  Files          22       22              
  Lines        1520     1523       +3     
==========================================
- Hits         1376     1334      -42     
- Misses        144      189      +45     
Impacted Files Coverage Δ
dwave/system/samplers/leap_hybrid_sampler.py 61.97% <100.00%> (-13.75%) :arrow_down:
dwave/system/samplers/clique.py 77.35% <0.00%> (-5.04%) :arrow_down:
dwave/system/samplers/dwave_sampler.py 84.14% <0.00%> (-3.05%) :arrow_down:
dwave/system/composites/embedding.py 96.00% <0.00%> (-1.15%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4fa4b27...ff432b4. Read the comment docs.

codecov-commenter avatar Mar 01 '22 19:03 codecov-commenter

Hi @Abdullahjavednesar , sorry for the very long delay. Any chance you can rebase this against the current master branch? We can also do it on our side

arcondello avatar Jan 26 '23 18:01 arcondello