def test_simple(self): qm = QM() a = qm.add_variable('SPIN', 'a') qm.set_linear(a, 1.5) qm.change_vartype('BINARY', a) self.assertEqual(qm.energy({a: 1}), 1.5) self.assertEqual(qm.energy({a: 0}), -1.5) self.assertIs(qm.vartype(a), dimod.BINARY)
def test_invalid(self): qm = QM() a = qm.add_variable('INTEGER', 'a') with self.assertRaises(TypeError): qm.change_vartype('SPIN', a)