Skip to content

Commit d25a8fc

Browse files
authored
Merge pull request #37 from arcondello/bugfix_#36
Bugfix #36
2 parents 27cbfa3 + b60d44d commit d25a8fc

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__all__ = ['__version__', '__author__', '__authoremail__', '__description__']
22

3-
__version__ = '0.2.2'
3+
__version__ = '0.2.3'
44
__author__ = 'D-Wave Systems Inc.'
55
__authoremail__ = '[email protected]'
66
__description__ = 'All things D-Wave System.'

dwave/system/samplers/dwave_sampler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def sample_qubo(self, Q, **kwargs):
141141
info_keys = {'timing'}
142142

143143
future = self.solver.sample_qubo(Q, **kwargs)
144-
return dimod.Response.from_futures((future,), vartype=dimod.SPIN,
144+
return dimod.Response.from_futures((future,), vartype=dimod.BINARY,
145145
num_variables=num_variables,
146146
data_vector_keys=data_vector_keys,
147147
active_variables=active_variables,

tests/test_dwave_sampler.py

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from concurrent.futures import Future
55

6+
import numpy as np
7+
68
import dimod
79
import dwave_networkx as dnx
810

@@ -125,6 +127,9 @@ def test_sample_ising_variables(self):
125127

126128
self.assertEqual(cols, 2)
127129

130+
self.assertFalse(np.any(response.samples_matrix == 0))
131+
self.assertIs(response.vartype, dimod.SPIN)
132+
128133
self.assertIn('num_occurrences', response.data_vectors)
129134
self.assertIn('timing', response.info)
130135

@@ -144,5 +149,8 @@ def test_sample_qubo_variables(self):
144149

145150
self.assertEqual(cols, 2)
146151

152+
self.assertTrue(np.all(response.samples_matrix >= 0))
153+
self.assertIs(response.vartype, dimod.BINARY)
154+
147155
self.assertIn('num_occurrences', response.data_vectors)
148156
self.assertIn('timing', response.info)

tests_integration/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import unittest
2+
3+
import numpy as np
4+
import dimod
5+
6+
from dwave.system.samplers import DWaveSampler
7+
8+
try:
9+
DWaveSampler()
10+
_config_found = True
11+
except ValueError:
12+
_config_found = False
13+
14+
15+
@unittest.skipUnless(_config_found, "no configuration found to connect to a system")
16+
class TestDWaveSamplerSystem(unittest.TestCase):
17+
def test_typical_small(self):
18+
h = [0, 0, 0, 0, 0]
19+
J = {(0, 4): 1}
20+
bqm = dimod.BinaryQuadraticModel.from_ising(h, J)
21+
22+
response = DWaveSampler().sample(bqm)
23+
24+
self.assertFalse(np.any(response.samples_matrix == 0))
25+
self.assertIs(response.vartype, dimod.SPIN)
26+
27+
rows, cols = response.samples_matrix.shape
28+
29+
self.assertEqual(cols, 5)

0 commit comments

Comments
 (0)