Skip to content

Commit

Permalink
Fix doctests for new repr of numpy2 scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
randomir committed Oct 23, 2024
1 parent f13debd commit 2c12f63
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dwave/embedding/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ def embed_bqm(source_bqm, embedding=None, target_adjacency=None,
>>> embedding = {'a': {0}, 'b': {1}, 'c': {2, 3}}
>>> # Embed and show the chain strength
>>> target_bqm = dwave.embedding.embed_bqm(bqm, embedding, target)
>>> target_bqm.quadratic[(2, 3)]
-1.9996979771955565
>>> print(target_bqm.quadratic[(2, 3)])
-1.999...
>>> print(target_bqm.quadratic) # doctest: +SKIP
{(0, 1): 1.0, (0, 3): 1.0, (1, 2): 1.0, (2, 3): -1.9996979771955565}
Expand Down
8 changes: 5 additions & 3 deletions dwave/system/composites/cutoffcomposite.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class CutOffComposite(dimod.ComposedSampler):
... {'ab': 0.8, 'ac': 0.7, 'bc': -1},
... 0,
... dimod.SPIN)
>>> CutOffComposite(AutoEmbeddingComposite(sampler), 0.75).sample(bqm,
... num_reads=1000).first.energy
>>> samples = CutOffComposite(
... AutoEmbeddingComposite(sampler), 0.75).sample(bqm, num_reads=1000)
>>> print(samples.first.energy)
-5.5
"""
Expand Down Expand Up @@ -238,7 +239,8 @@ class PolyCutOffComposite(dimod.ComposedPolySampler):
>>> import dimod
>>> sampler = dimod.HigherOrderComposite(dimod.ExactSolver())
>>> poly = dimod.BinaryPolynomial({'a': 3, 'abc':-4, 'ac': 0.2}, dimod.SPIN)
>>> PolyCutOffComposite(sampler, 1).sample_poly(poly).first.sample['a']
>>> samples = PolyCutOffComposite(sampler, 1).sample_poly(poly)
>>> print(samples.first.sample['a'])
-1
"""
Expand Down
2 changes: 1 addition & 1 deletion dwave/system/composites/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class EmbeddingComposite(dimod.ComposedSampler):
>>> h = {'a': -1., 'b': 2}
>>> J = {('a', 'b'): 1.5}
>>> sampleset = sampler.sample_ising(h, J, num_reads=100)
>>> sampleset.first.energy
>>> print(sampleset.first.energy)
-4.5
Expand Down
4 changes: 2 additions & 2 deletions dwave/system/samplers/dwave_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class DWaveSampler(dimod.Sampler, dimod.Structured):
>>> sampleset = sampler.sample_ising({qubit_a: -1, qubit_b: 1},
... {},
... num_reads=100)
>>> sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1
>>> print(sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1)
True
See `Ocean Glossary <https://docs.ocean.dwavesys.com/en/stable/concepts/index.html>`_
Expand Down Expand Up @@ -396,7 +396,7 @@ def sample(self, bqm, warnings=None, **kwargs):
>>> sampleset = sampler.sample_ising({qubit_a: -1, qubit_b: 1},
... {},
... num_reads=100)
>>> sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1
>>> print(sampleset.first.sample[qubit_a] == 1 and sampleset.first.sample[qubit_b] == -1)
True
See `Ocean Glossary <https://docs.ocean.dwavesys.com/en/stable/concepts/index.html>`_
Expand Down

0 comments on commit 2c12f63

Please sign in to comment.