Exemplo n.º 1
0
    def test_sampleset_trim(self):
        h = {'a': -4.0, 'b': -4.0, 'c': 0}
        J = {('a', 'b'): 3.2}

        sampler = PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 6)
        samples = sampler.sample_ising(h, J)

        self.assertEqual(len(samples), 6)
Exemplo n.º 2
0
    def test_sampleset_shorter(self):
        h = {'a': -4.0, 'b': -4.0, 'c': 0}
        J = {('a', 'b'): 3.2}

        sampler = PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 10)
        with self.assertWarns(DeprecationWarning):
            samples = sampler.sample_ising(h, J)

        # we should see 2**n < 10 rows
        self.assertEqual(len(samples), 8)
Exemplo n.º 3
0
    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 = PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 6, aggregate=True)
        with self.assertWarns(DeprecationWarning):
            samples = sampler.sample_ising(h, J)

        self.assertEqual(len(samples), 6)
Exemplo n.º 4
0
 def test_0(self):
     with self.assertRaises(ValueError):
         PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 0)
Exemplo n.º 5
0
    def test_10(self):
        sampler = PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 10)
        dtest.assert_composite_api(sampler)

        self.assertEqual(sampler.parameters, sampler.child.parameters)