# Path: src/common.py
# def removekey(d, key):
# def colinear(p0, p1, p2):
# def manhattan_dist(A,B):
# def euclidean_dist(A,B):
# def Charge(X_charge = 0, Z_charge = 0):
# def Sign(count, num_sides):
#     def __init__(self, depth, dimension = 2):
#     def Syndrome(self, type, charge_type):
#     def PhysicalErrors(self):
#     def distance(self, type, node1, node2):
#     def Assessment(self):
# class Code:
# 
# Path: src/simulation.py
# class simulation:
# 
# 	def __init__(self, dimension, code_type, model, decoder, path_to):
# 		self.model = model
# 		[self.decoder, self.decoder_type] = decoder
# 		[self.model, self.model_type] = model
# 		self.dimension = dimension
# 		self.code_type = code_type
# 		self.path = path_to
# 
# 	def __call__(self, L, p):
# 		signal.signal(signal.SIGALRM, timeout_handler)
# 		signal.alarm(10)
# 		if self.code_type == 'Surface Code':
# 			code = SurfaceCode(L, self.dimension)
# 		if self.code_type == '6-6-6 Color Code':
# 			code = Color_6_6_6(L, self.dimension)
# 		code = code.CodeCycle(self.model, p)
# 		try:
# 			decoders.Decode(code, self.decoder)
# 			return code.Assessment()
# 		except TimeoutException:
# 			return self(L, p)
# 		except ValueError:
# 			return self(L, p)
# 
# 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):


import numpy as np
import sys
from src import common, simulation, error_models
from decoders import dsp
 #
 # 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('../src')

################## Color Code Simulation ##################
path_to = str(sys.argv[1])
model = error_models.Depolarizing()
decoder = dsp.DSP_decoder()
L_vals = [9,11,13]
p_vals = np.linspace(0.05,0.13,15)
num_trials = 30000
d = 2

# Path: src/common.py
# def removekey(d, key):
# def colinear(p0, p1, p2):
# def manhattan_dist(A,B):
# def euclidean_dist(A,B):
# def Charge(X_charge = 0, Z_charge = 0):
# def Sign(count, num_sides):
#     def __init__(self, depth, dimension = 2):
#     def Syndrome(self, type, charge_type):
#     def PhysicalErrors(self):
#     def distance(self, type, node1, node2):
#     def Assessment(self):
# class Code:
# 
# Path: src/simulation.py
# class simulation:
# 
# 	def __init__(self, dimension, code_type, model, decoder, path_to):
# 		self.model = model
# 		[self.decoder, self.decoder_type] = decoder
# 		[self.model, self.model_type] = model
# 		self.dimension = dimension
# 		self.code_type = code_type
# 		self.path = path_to
# 
# 	def __call__(self, L, p):
# 		signal.signal(signal.SIGALRM, timeout_handler)
# 		signal.alarm(10)
# 		if self.code_type == 'Surface Code':
# 			code = SurfaceCode(L, self.dimension)
# 		if self.code_type == '6-6-6 Color Code':
# 			code = Color_6_6_6(L, self.dimension)
# 		code = code.CodeCycle(self.model, p)
# 		try:
# 			decoders.Decode(code, self.decoder)
# 			return code.Assessment()
# 		except TimeoutException:
# 			return self(L, p)
# 		except ValueError:
# 			return self(L, p)
# 
# 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/sims/DSP_dp.py
import numpy as np
import sys
from src import common, simulation, error_models
from decoders import dsp

 #
 # 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('../src')

################## Color Code Simulation ##################
path_to = str(sys.argv[1])
model = error_models.Depolarizing()
decoder = dsp.DSP_decoder()
L_vals = [9,11,13]
p_vals = np.linspace(0.05,0.13,15)
num_trials = 30000
d = 2

sim = simulation.simulation(d, '6-6-6 Color Code', [model, 'Depolarizing Channel'], [decoder, 'DSP'], path_to)