Skip to content

Commit

Permalink
Update docs to reflect recommended use of close()
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Jan 29, 2025
1 parent 9786064 commit ee047a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dwave/system/samplers/dwave_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class DWaveSampler(dimod.Sampler, dimod.Structured):
... num_reads=100)
>>> print(sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1)
True
...
>>> sampler.close()
See `Ocean Glossary <https://docs.ocean.dwavesys.com/en/stable/concepts/index.html>`_
for explanations of technical terms in descriptions of Ocean tools.
Expand Down
19 changes: 14 additions & 5 deletions dwave/system/samplers/leap_hybrid_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class LeapHybridSampler(dimod.Sampler):
>>> sampler = LeapHybridSampler(solver=solver) # doctest: +SKIP
>>> sampler.solver # doctest: +SKIP
BQMSolver(id='hybrid_binary_quadratic_model_version2')
...
>>> sampler.close() # doctest: +SKIP
"""

_INTEGER_BQM_SIZE_THRESHOLD = 10000
Expand Down Expand Up @@ -221,10 +222,12 @@ def sample(self, bqm, time_limit=None, **kwargs):
>>> bqm = dimod.BQM.from_qubo(qubo)
...
>>> # Find a good solution
>>> sampler = LeapHybridSampler() # doctest: +SKIP
>>> sampleset = sampler.sample(bqm) # doctest: +SKIP
>>> sampler = LeapHybridSampler() # doctest: +SKIP
>>> sampleset = sampler.sample(bqm) # doctest: +SKIP
...
>>> sampler.close() # doctest: +SKIP
"""

if not isinstance(bqm, dimod.BQM):
bqm = dimod.BQM(bqm)

Expand Down Expand Up @@ -356,6 +359,8 @@ class LeapHybridDQMSampler:
>>> print("{} beats {}".format(cases[sampleset.first.sample['my_hand']],
... cases[sampleset.first.sample['their_hand']])) # doctest: +SKIP
rock beats scissors
...
>>> dqm_sampler.close() # doctest: +SKIP
"""

@classproperty
Expand Down Expand Up @@ -620,8 +625,10 @@ class LeapHybridCQMSampler:
The best (lowest-energy) solution found has :math:`i=j=2` as expected,
a solution that is feasible because all the constraints (one in this
example) are satisfied.
...
>>> sampler.close() # doctest: +SKIP
"""

def __init__(self, **config):
# strongly prefer hybrid solvers; requires kwarg-level override
config.setdefault('client', 'hybrid')
Expand Down Expand Up @@ -866,6 +873,8 @@ class LeapHybridNLSampler:
... f"objective value {model.objective.state(0)} for order " \ # doctest: +SKIP
... f"{job_order.state(0)}.") # doctest: +SKIP
State 0 of 8 has an objective value 50.0 for order [1. 2. 0.].
...
>>> sampler.close() # doctest: +SKIP
"""

def __init__(self, **config):
Expand Down

0 comments on commit ee047a0

Please sign in to comment.