# Path: src/surface_codes.py
# def check0(qubit):
# def check1(qubit):
# def check2(qubit):
# def check3(qubit):
#     def __init__(self, depth, dimension = 2):
#     def Plaquette(self, qubit):
#     def generateColors(self):
#     def Sign(self, count, num_sides):
#     def generateCode(self):
#     def generateDual(self):
#     def CodeCycle(self, model, p = 0):
#     def hasLogicalError(self):
# class SurfaceCode(Code):
# 
# Path: src/error_models.py
# def PauliX(charge, dim):
# def PauliZ(charge, dim):
# def PauliXZ(charge, dim):
# def Identity_Channel(charge):
# def PhaseFlip_Channel(charge, dim, p):
# def BitFlip_Channel(charge, dim, p):
# def Correlated_Channel(charge, dim, p):
# def BP_Channel(charge, dim, p):
# def Depolarizing_Channel(charge, dim, p):
# def Depolarizing_Helper(charge, dim):
# def Error_Channel(charge, dim, p, type):
# 	def __init__(self, **kwargs):
# 	def Initialize(self, code, type, p):
# 	def Identity(self, code, p):
# 	def Fourier(self, code, type, p):
# 	def Measure(self, code, type, p):
# 	def Sum(self, code, count, num_sides, type, charge_type, control_p, target_p):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# class ErrorModel:
# class CodeCapacity(ErrorModel):
# class Depolarizing(ErrorModel):
# class Phenomenological(ErrorModel):
# class CircuitLevel(ErrorModel):
# class PhaseFlip(ErrorModel):
# class BitFlip(ErrorModel):
# 
# Path: src/visualization.py
# def PlotPrimal(code, title, plot_number = 1):
# def PlotDual(code, title, plot_number = 2):
# def PlotPlaquette(code, title, plot_number = 3):
# def PlotShrunk(code, type, title, plot_number = 4):


import sys
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from src import surface_codes, error_models, visualization
from rg import *
 #
 # QTop
 #
 # Copyright (c) 2016 Jacob Marks (jacob.marks@yale.edu)
 #
 # This file is part of QTop.
 #
 # QTop is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.

sys.path.append('../')
sys.path.append('decoders/')

L, d, p = 7, 7, .1

code = surface_codes.SurfaceCode(L, d)
model = error_models.CodeCapacity()
code = code.CodeCycle(model, p)
visualization.PlotPlaquette(code, "Before Decoding", 1)

decoder = HDRG_decoder()
code = decoder(code)

# Path: src/surface_codes.py
# def check0(qubit):
# def check1(qubit):
# def check2(qubit):
# def check3(qubit):
#     def __init__(self, depth, dimension = 2):
#     def Plaquette(self, qubit):
#     def generateColors(self):
#     def Sign(self, count, num_sides):
#     def generateCode(self):
#     def generateDual(self):
#     def CodeCycle(self, model, p = 0):
#     def hasLogicalError(self):
# class SurfaceCode(Code):
# 
# Path: src/error_models.py
# def PauliX(charge, dim):
# def PauliZ(charge, dim):
# def PauliXZ(charge, dim):
# def Identity_Channel(charge):
# def PhaseFlip_Channel(charge, dim, p):
# def BitFlip_Channel(charge, dim, p):
# def Correlated_Channel(charge, dim, p):
# def BP_Channel(charge, dim, p):
# def Depolarizing_Channel(charge, dim, p):
# def Depolarizing_Helper(charge, dim):
# def Error_Channel(charge, dim, p, type):
# 	def __init__(self, **kwargs):
# 	def Initialize(self, code, type, p):
# 	def Identity(self, code, p):
# 	def Fourier(self, code, type, p):
# 	def Measure(self, code, type, p):
# 	def Sum(self, code, count, num_sides, type, charge_type, control_p, target_p):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# 	def __init__(self):
# class ErrorModel:
# class CodeCapacity(ErrorModel):
# class Depolarizing(ErrorModel):
# class Phenomenological(ErrorModel):
# class CircuitLevel(ErrorModel):
# class PhaseFlip(ErrorModel):
# class BitFlip(ErrorModel):
# 
# Path: src/visualization.py
# def PlotPrimal(code, title, plot_number = 1):
# def PlotDual(code, title, plot_number = 2):
# def PlotPlaquette(code, title, plot_number = 3):
# def PlotShrunk(code, type, title, plot_number = 4):


# Path: src/tests/test_RG.py
import sys
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
from src import surface_codes, error_models, visualization
from rg import *

 #
 # QTop
 #
 # Copyright (c) 2016 Jacob Marks (jacob.marks@yale.edu)
 #
 # This file is part of QTop.
 #
 # QTop is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.

sys.path.append('../')
sys.path.append('decoders/')

L, d, p = 7, 7, .1

code = surface_codes.SurfaceCode(L, d)
model = error_models.CodeCapacity()
code = code.CodeCycle(model, p)
visualization.PlotPlaquette(code, "Before Decoding", 1)

decoder = HDRG_decoder()
code = decoder(code)

visualization.PlotPlaquette(code, "After Decoding", 2)