def test_empty_bqm(self):
        bqm = BinaryQuadraticModel(linear={1: -1.3, 4: -0.5},
                                   quadratic={(1, 4): -0.6},
                                   offset=0,
                                   vartype=Vartype.SPIN)

        fixed_variables = {1: -1, 4: -1}
        sampler = FixedVariableComposite(ExactSolver())
        response = sampler.sample(bqm, fixed_variables=fixed_variables)
        self.assertIsInstance(response, SampleSet)
    def test_sample(self):
        bqm = BinaryQuadraticModel(linear={1: -1.3, 4: -0.5},
                                   quadratic={(1, 4): -0.6},
                                   offset=0,
                                   vartype=Vartype.SPIN)

        fixed_variables = {1: -1}
        sampler = FixedVariableComposite(ExactSolver())
        response = sampler.sample(bqm, fixed_variables=fixed_variables)

        self.assertEqual(response.first.sample, {4: -1, 1: -1})
        self.assertAlmostEqual(response.first.energy, 1.2)
        def test_empty_bqm(self):
            bqm = BinaryQuadraticModel({
                1: -1.3,
                4: -0.5
            }, {(1, 4): -0.6},
                                       0,
                                       vartype=Vartype.SPIN)

            fixed_variables = {1: -1, 4: -1}
            with self.assertWarns(DeprecationWarning):
                sampler = FixedVariableComposite(ExactSolver())
            response = sampler.sample(bqm, fixed_variables=fixed_variables)
            self.assertIsInstance(response, SampleSet)
        def test_sample(self):
            bqm = BinaryQuadraticModel({
                1: -1.3,
                4: -0.5
            }, {(1, 4): -0.6},
                                       0,
                                       vartype=Vartype.SPIN)

            fixed_variables = {1: -1}
            with self.assertWarns(DeprecationWarning):
                sampler = FixedVariableComposite(ExactSolver())
            response = sampler.sample(bqm, fixed_variables=fixed_variables)

            self.assertEqual(response.first.sample, {4: -1, 1: -1})
            self.assertAlmostEqual(response.first.energy, 1.2)