import math ## this may be useful!!
#import numpy as np 

class Qubit:

    # Default Constructor
    #  Constructor without input arguments
    #  Initialize value to white or |0>
    def __init__(self):
        self.state = [1.0, 0.0]   # initialize to 100% 0


    # These are standard "setters" and "getters" 
    # You need to support inputs of both list and string
    # String is bra-ket notation, list is vector notation
    # Inputs: v - either a string (braket notation) or list (vector)
    #   The precise string will be something like |0> or |1>
    #   But it may have extra spaces surrounding it...
    # Outputs: none
    # Function: It sets the self.state based on the input value
    def setvalue(self,v):

        if (type(v) == str):
            print("String: " + v)
        elif (type(v) == list):
            print("List: " + v)
                
        # TODO - fill in this code */
        # Use the input to set the self.state properly */
        print("This method not yet implemented");
            

    # String is bra-ket notation, list is vector notation
    # Inputs: none
    # Outputs: string
    #   It should take the form a|0> + b|1> where a, b are the amplitudes
    #   Please be careful to follow this form exactly, otherwise the regex capture won't work
    #   To test, you can go to https://regex101.com/r/SAflUm/1 and check your output
    # Function: It expresses the state as a string, braket notation, and returns it
    def getvalue_braket(self):
        #/* TODO - fill in this code */
        print("This method not yet implemented")
        return "none"


    # String is bra-ket notation, list is vector notation
    # Inputs: none
    # Outputs: list
    # Function: It expresses the state as a vector and returns it
    def getvalue_vector(self):
        #/* TODO - fill in this code */
        print("This method not yet implemented")
        return [0,0]


	# notgate
    # Inputs: none
    # Outputs: none
    # Function: Perform a not gate on the qubit
    def gate_not(self):
        #/* TODO - fill in this code */
        print("notgate not yet implemented")


	# hgate
    # Inputs: none
    # Outputs: none
    # Function: Perform a hadamard gate on the qubit
    def gate_H(self):
        #/* TODO - fill in this code */
        print("hgate not yet implemented")


	# zgate
    # Inputs: none
    # Outputs: none
    # Function: Perform a z gate on the qubit
    def gate_Z(self):
        #/* TODO - fill in this code */
        print("zgate not yet implemented")


	# measure
    # Inputs: none
    # Outputs: int result - result of measurement (0 or 1)
    # Function: Perform a measurement based on the qubit state. 
    #   this both changes the qubit state as a result of the measurement
    #   and returns the result of the measurement.
    def measure(self):
        #/* TODO - fill in this code */
        print("measure not yet implemented")

    #/* these are for grading purposes - do NOT change anything below this line!!! */
    def compare(qb1, qb2):
        # if they are equal within a certain precision
        # because they are floats, we must put in a fudge factor
        i = 0
        for v1 in qb1.state:
            v2 = qb2.state[i]
            if ((v1 - v2) > 0.01):
                return 1
            elif ((v2 - v1) > 0.01):
                return -1
            i += 1
        # if all values are equivalent, then the two are equal
        return 0
