Ejemplo 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)
Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 4
0
 def test_0(self):
     with self.assertRaises(ValueError):
         PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 0)
Ejemplo n.º 5
0
    def test_10(self):
        sampler = PolyTruncateComposite(HigherOrderComposite(ExactSolver()), 10)
        dtest.assert_composite_api(sampler)

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