Skip to content

Commit

Permalink
Simplify DWaveCliqueSampler after changes to DWaveSampler init
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Sep 22, 2020
1 parent f5d5c2c commit cd6bd2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 2 additions & 10 deletions dwave/system/samplers/clique.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,15 @@ class DWaveCliqueSampler(dimod.Sampler):
...
>>> bqm = dimod.generators.ran_r(1, 6)
...
>>> sampler = DWaveCliqueSampler(solver={'qpu': True})
>>> sampler = DWaveCliqueSampler()
>>> sampler.largest_clique_size > 5
True
>>> sampleset = sampler.sample(bqm, num_reads=100)
"""
def __init__(self, **config):

# to get the QPU with the most qubits available (subject to other
# constraints specified in **config), we need to set order_by
# (use simple solver parsing for now, i.e. until we have
# https://github.com/dwavesystems/dwave-cloud-client/issues/424)
solver = config.pop('solver', {})
if isinstance(solver, str):
solver = dict(name__eq=solver)
solver.update(order_by='-num_active_qubits')
self.child = child = DWaveSampler(solver=solver, **config)
self.child = child = DWaveSampler(**config)

# do some topology checking
try:
Expand Down
6 changes: 2 additions & 4 deletions tests/qpu/test_dwavecliquesampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
class TestDWaveCliqueSampler(unittest.TestCase):
def test_chimera(self):
try:
sampler = DWaveCliqueSampler(
solver=dict(topology__type='chimera', qpu=True))
sampler = DWaveCliqueSampler(solver=dict(topology__type='chimera'))
except (ValueError, ConfigFileError, SolverNotFoundError):
raise unittest.SkipTest("no Chimera-structured QPU available")

Expand All @@ -40,8 +39,7 @@ def test_chimera(self):

def test_pegasus(self):
try:
sampler = DWaveCliqueSampler(
solver=dict(topology__type='pegasus', qpu=True))
sampler = DWaveCliqueSampler(solver=dict(topology__type='pegasus'))
except (ValueError, ConfigFileError, SolverNotFoundError):
raise unittest.SkipTest("no Pegasus-structured QPU available")

Expand Down

0 comments on commit cd6bd2e

Please sign in to comment.