dwavesystems / dwave-system

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers
https://docs.ocean.dwavesys.com/
Apache License 2.0
87 stars 62 forks source link

Handle exception when BQM is passed to DQM sampler #444

Open Abdullahjavednesar opened 2 years ago

Abdullahjavednesar commented 2 years ago

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 commented 2 years ago

Hi @arcondello, can you please take a look!

Abdullahjavednesar commented 2 years ago

Addressed both the comments. Thanks for the review!

codecov-commenter commented 2 years ago

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.

arcondello commented 1 year ago

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