# 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:


from matplotlib import path
from math import floor
from src import common
import sys
############ Decode function and base decoder classes ############

## Call with Decode(code, decoder)
def Decode(code, decoder):
    decoder(code)


class decoder(object):

    def __call__(self, code):
        return code

class surface_decoder(decoder):

    def __init__(self):
        self.recover = self.algorithm()

    def __call__(self, code):
        for type in code.types:
            for charge_type in ['X', 'Z']:
                syndrome = code.Syndrome(type, charge_type)
                code = self.recover(code, syndrome, type, charge_type)

        code = reset_measures(code)
        return code


def reset_measures(code):
    for type in code.types:
        for measure_qubit in code.Stabilizers[type]:

# 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/decoders/decoders.py
from matplotlib import path
from math import floor
from src import common
import sys

############ Decode function and base decoder classes ############

## Call with Decode(code, decoder)
def Decode(code, decoder):
    decoder(code)


class decoder(object):

    def __call__(self, code):
        return code

class surface_decoder(decoder):

    def __init__(self):
        self.recover = self.algorithm()

    def __call__(self, code):
        for type in code.types:
            for charge_type in ['X', 'Z']:
                syndrome = code.Syndrome(type, charge_type)
                code = self.recover(code, syndrome, type, charge_type)

        code = reset_measures(code)
        return code


def reset_measures(code):
    for type in code.types:
        for measure_qubit in code.Stabilizers[type]:

            code.Stabilizers[type][measure_qubit]['charge'] = common.Charge()