MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / _submit_and_check

Method _submit_and_check

tests/test_solver.py:99–123  ·  view source on GitHub ↗
(self, solver, linear, quad, **kwargs)

Source from the content-addressed store, hash-verified

97
98class _QueryTest(unittest.TestCase):
99 def _submit_and_check(self, solver, linear, quad, **kwargs):
100 results = solver.sample_ising(linear, quad, num_reads=100, **kwargs)
101
102 # Did we get the right number of samples?
103 self.assertEqual(100, sum(results.num_occurrences))
104
105 # verify .occurrences property still works, although is deprecated
106 with warnings.catch_warnings():
107 warnings.simplefilter("ignore")
108 self.assertEqual(100, sum(results.num_occurrences))
109
110 # offset is optional
111 offset = kwargs.get('offset', 0)
112
113 # Make sure the number of occurrences and energies are all correct
114 for energy, state in zip(results.energies, results.samples):
115 self.assertAlmostEqual(
116 energy, evaluate_ising(linear, quad, state, offset=offset))
117
118 # label is optional
119 label = kwargs.get('label')
120 if label is not None:
121 self.assertEqual(results.label, label)
122
123 return results
124
125@unittest.skipUnless(config, "No live server configuration available.")
126class Submission(_QueryTest):

Calls 3

evaluate_isingFunction · 0.90
sample_isingMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected