Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_king_graph(self):
h = {}
J = {(0, 1): -1.0, (1, 2): -3.0}
king_interaction = [[0, 0, 1, 0, -1.0], [1, 0, 2, 0, -3.0]]
king_graph = oj.KingGraph(machine_type="ASIC", linear=h, quadratic=J)
correct_mat = np.array([[0, -1, 0, ], [-1, 0, -3], [0, -3, 0]])
np.testing.assert_array_equal(
king_graph.ising_interactions(), correct_mat.astype(np.float))
np.testing.assert_array_equal(
king_interaction, king_graph._ising_king_graph)
king_graph = oj.KingGraph(
machine_type="ASIC", king_graph=king_interaction)
np.testing.assert_array_equal(
king_interaction, king_graph._ising_king_graph)
king_graph = oj.KingGraph.from_qubo(machine_type="ASIC", Q={
(0, 1): -1})
king_interaction = [[0, 0, 0, 0, -0.25],
[0, 0, 1, 0, -0.25], [1, 0, 1, 0, -0.25]]
np.testing.assert_array_equal(
king_interaction, king_graph._ising_king_graph)
def test_king_graph(self):
h = {}
J = {(0, 1): -1.0, (1, 2): -3.0}
king_interaction = [[0, 0, 1, 0, -1.0], [1, 0, 2, 0, -3.0]]
king_graph = oj.KingGraph(machine_type="ASIC", linear=h, quadratic=J)
correct_mat = np.array([[0, -1, 0, ], [-1, 0, -3], [0, -3, 0]])
np.testing.assert_array_equal(
king_graph.ising_interactions(), correct_mat.astype(np.float))
np.testing.assert_array_equal(
king_interaction, king_graph._ising_king_graph)
king_graph = oj.KingGraph(
machine_type="ASIC", king_graph=king_interaction)
np.testing.assert_array_equal(
king_interaction, king_graph._ising_king_graph)
king_graph = oj.KingGraph.from_qubo(machine_type="ASIC", Q={
(0, 1): -1})
king_interaction = [[0, 0, 0, 0, -0.25],
[0, 0, 1, 0, -0.25], [1, 0, 1, 0, -0.25]]
np.testing.assert_array_equal(