def test_sampleset_trim(self): h = {'a': -4.0, 'b': -4.0, 'c': 0} J = {('a', 'b'): 3.2} sampler = TruncateComposite(ExactSolver(), 6) samples = sampler.sample_ising(h, J) self.assertEqual(len(samples), 6)
def test_sampleset_shorter(self): h = {'a': -4.0, 'b': -4.0, 'c': 0} J = {('a', 'b'): 3.2} sampler = TruncateComposite(ExactSolver(), 10) samples = sampler.sample_ising(h, J) # we should see 2**n < 10 rows self.assertEqual(len(samples), 8)
def test_with_aggration(self): # this is actually just a smoke test, needs better testing in the # future... h = {'a': -4.0, 'b': -4.0, 'c': 0} J = {('a', 'b'): 3.2} sampler = TruncateComposite(ExactSolver(), 6, aggregate=True) samples = sampler.sample_ising(h, J) self.assertEqual(len(samples), 6)
def test_0(self): with self.assertRaises(ValueError): TruncateComposite(ExactSolver(), 0)
def test_10(self): sampler = TruncateComposite(ExactSolver(), 10) dtest.assert_sampler_api(sampler) dtest.assert_composite_api(sampler) self.assertEqual(sampler.parameters, {})
class TestConstruction(unittest.TestCase): def test_10(self): sampler = TruncateComposite(ExactSolver(), 10) dtest.assert_sampler_api(sampler) dtest.assert_composite_api(sampler) self.assertEqual(sampler.parameters, {}) def test_0(self): with self.assertRaises(ValueError): TruncateComposite(ExactSolver(), 0) @dtest.load_sampler_bqm_tests(TruncateComposite(ExactSolver(), 100)) class TestSample(unittest.TestCase): def test_sampleset_shorter(self): h = {'a': -4.0, 'b': -4.0, 'c': 0} J = {('a', 'b'): 3.2} sampler = TruncateComposite(ExactSolver(), 10) samples = sampler.sample_ising(h, J) # we should see 2**n < 10 rows self.assertEqual(len(samples), 8) def test_sampleset_trim(self): h = {'a': -4.0, 'b': -4.0, 'c': 0} J = {('a', 'b'): 3.2}