diff --git a/CondaPkg.toml b/CondaPkg.toml index a8db9b1..b88aa5a 100644 --- a/CondaPkg.toml +++ b/CondaPkg.toml @@ -7,4 +7,5 @@ scipy = "" pymatching = "" ldpc = ">=2.2.8" sinter = ">=1.14" -stim = ">=1.14" \ No newline at end of file +stim = ">=1.14" +mwpf = ">=0.2.6" diff --git a/README.md b/README.md index d64107b..abcc86c 100644 --- a/README.md +++ b/README.md @@ -99,4 +99,57 @@ julia> syndrome = PyArray(H)*error .% 2 julia> decoding = bpd.decode(np.array(syndrome)) Python: array([0, 1, 0]) +``` + +## `mwpf` + +The python mwpf module is immediately available: + +``` +julia> using PyQDecoders + +julia> PyQDecoders.mwpf +Python: +``` + +Running the example from `mwpf`'s [original Readme](https://github.com/yuewuo/mwpf): + +``` +julia> using PyQDecoders: mwpf + +julia> HyperEdge = mwpf.HyperEdge; + +julia> SolverInitializer = mwpf.SolverInitializer; + +julia> SolverSerialJointSingleHair = mwpf.SolverSerialJointSingleHair; + +julia> SyndromePattern = mwpf.SyndromePattern; + +julia> vertex_num = 4; + +julia> weighted_edges = [ + HyperEdge([0, 1], 100), # [vertices], weight + HyperEdge([1, 2], 100), + HyperEdge([2, 3], 100), + HyperEdge([0], 100), # boundary vertex + HyperEdge([0, 1, 2], 60), # hyperedge + ]; + +julia> initializer = SolverInitializer(vertex_num, weighted_edges); + +julia> hyperion = SolverSerialJointSingleHair(initializer); + +julia> syndrome = [0, 1, 3]; + +julia> hyperion.solve(SyndromePattern(syndrome)); + +julia> hyperion_subgraph = hyperion.subgraph(); + +julia> println("Hyperion Subgraph: ", hyperion_subgraph) +Hyperion Subgraph: [2, 4] + +julia> _, bound = hyperion.subgraph_range(); + +julia> println("Subgraph Range: ", (bound.lower, bound.upper)) +Subgraph Range: (, ) ``` \ No newline at end of file diff --git a/src/PyQDecoders.jl b/src/PyQDecoders.jl index 570fbca..7a1274f 100644 --- a/src/PyQDecoders.jl +++ b/src/PyQDecoders.jl @@ -7,6 +7,7 @@ const np = PythonCall.pynew() const pm = PythonCall.pynew() const ldpc = PythonCall.pynew() const ldpccodes = PythonCall.pynew() +const mwpf = PythonCall.pynew() function __init__() PythonCall.pycopy!(sp, PythonCall.pyimport("scipy")) @@ -15,6 +16,7 @@ function __init__() PythonCall.pycopy!(pm, PythonCall.pyimport("pymatching")) PythonCall.pycopy!(ldpc, PythonCall.pyimport("ldpc")) PythonCall.pycopy!(ldpccodes, PythonCall.pyimport("ldpc.codes")) + PythonCall.pycopy!(mwpf, PythonCall.pyimport("mwpf")) end end # module