Exemplo n.º 1
0
    def test_multiple_spin_transforms(self):
        sampler = dimod.SpinReversalTransform(self.sampler)

        h = {v: .1 for v in range(10)}
        J = {(u, v): -1. for (u, v) in itertools.combinations(h, 2)}

        response = sampler.sample_ising(h, J)

        response2 = sampler.sample_ising(h, J, num_spin_reversal_transforms=2)

        # should be twice as many samples
        self.assertEqual(len(response2), 2 * len(response))
Exemplo n.º 2
0
    def test_double_stack(self):

        # nested spin reversal transforms
        sampler = dimod.SpinReversalTransform(self.sampler)

        h = {v: .1 for v in range(10)}
        J = {(u, v): -1. for (u, v) in itertools.combinations(h, 2)}

        response = sampler.sample_ising(h, J, orig_h=h)

        for __, data in response.samples(data=True):
            # should be two spin-reversal-transform reports in addition to the three other fields
            self.assertEqual(len(data), 5)
Exemplo n.º 3
0
 def setUp(self):
     self.sampler = dimod.SpinReversalTransform(MockSampler())
Exemplo n.º 4
0
    def test_kwarg_propogation_composite(self):
        sampler = dimod.SpinReversalTransform(self.sampler)

        # kwargs should have propogated through, correctness is tested elsewhere
        self.assertIn('orig_h', sampler.accepted_kwargs)