Skip to content

Commit

Permalink
Additional test for Dijkstra search
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarhiggott committed May 21, 2021
1 parent 93c1729 commit 6dc126e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pymatching/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ PYBIND11_MODULE(_cpp_mwpm, m) {
.def_readwrite("all_distances", &WeightedStabiliserGraph::all_distances)
.def_readwrite("all_edges_have_error_probabilities",
&WeightedStabiliserGraph::all_edges_have_error_probabilities)
.def_readwrite("_distances", &WeightedStabiliserGraph::_distances)
.def_readwrite("_predecessors", &WeightedStabiliserGraph::_predecessors)
.def("add_edge", &WeightedStabiliserGraph::AddEdge, "node1"_a, "node2"_a, "qubit_ids"_a,
"weight"_a, "error_probability"_a=-1.0, "has_error_probability"_a=false)
.def("add_noise", &WeightedStabiliserGraph::AddNoise)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_nearest_neighbours.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import sys

import networkx as nx
import numpy as np
import pytest
Expand Down Expand Up @@ -50,3 +52,13 @@ def test_neighbourhood_matching(defects,num_neighbours,correction):
assert (np.array_equal(decode_match_neighbourhood(m.stabiliser_graph,
np.array(defects), num_neighbours, False).correction, np.array(correction)))


def test_distances_and_predecessors_reset():
M = Matching([[1,1,0,0],[0,1,1,0],[0,0,1,1],[1,0,0,1]])
assert M.stabiliser_graph._distances == []
assert M.stabiliser_graph._predecessors == []
for z in ([1,0,0,1],[0,1,1,0],[0,0,1,1]):
M.decode(z)
infty = sys.float_info.max
assert [infty]*4 == M.stabiliser_graph._distances
assert list(range(4)) == M.stabiliser_graph._predecessors

0 comments on commit 6dc126e

Please sign in to comment.