def acquisition_extinction():
    tab = {}
    manager = Classes.Manager()
    manager.addSI("food", 1)
    manager.addSI("goOut", 0.8)
    manager.addSC("light", 0.25)
    manager.addSC("sound", 0.6)
    manager.addSC("move", 0.3)
    manager.showAssociationsTitles()
    manager.showAssociations()

    myFile = open('fichier.csv', 'w')
    
    manager.exportCSVHeader( myFile )
    manager.exportCSV(myFile)
    tab = manager.createArray()
    
    for i in range(10):
        manager.trial(["light", "sound"], "food", 0)
        manager.exportCSV(myFile)
        tab = manager.exportArray(tab)
    
    for i in range(10):
        manager.trial(["light", "sound"], [], 0)
        manager.exportCSV(myFile)
        tab = manager.exportArray(tab)
    Paint.savePlot(tab, 'graph.png', True)

    myFile.close()
예제 #2
0
    def __init__(self,
                 program,
                 programSize,
                 pos,
                 w=100,
                 h=600,
                 borderColor=(0, 0, 0),
                 fillColor=(240, 240, 240)):
        WindowRectangle.__init__(self, program, programSize, pos, w, h,
                                 borderColor, fillColor)

        self.brushes = []
        self.currentBrush = None
        self.currentColor = Paint.ColorIcon(programSize, (258, 210 - 35), 35,
                                            35, (0, 0, 0), (255, 255, 255))
        self.wheel = Paint.ColorWheel((10, 10), 200)

        self.value_slider = Slider((15, 235))
        self.size_slider = Slider((230, 110), False)

        brush1 = Paint.PaintBrush((275, 20), 20, "Square")
        brush2 = Paint.PaintBrush((275, 50), 20)
        #brush3 = Paint.PaintBrush((275,10+(30*2)),30)
        #brush4 = Paint.PaintBrush((275,10+(40*2.5)),40)

        self.brushes.append(brush1)
        self.brushes.append(brush2)
예제 #3
0
    def save_performance(self, _name, param, if_print=False, booksize=1000000):
        system = platform.system()
        sep_str = "/" if system.lower() == "linux" else "\\"

        eval_root_dir = "eval_opt_res"
        # 创建主目录歘来,策略目录
        strategy_dir = eval_root_dir + sep_str + _name.replace("*", sep_str)
        strategy_dir = ".." + sep_str + strategy_dir

        if not os.path.exists(strategy_dir):
            os.makedirs(strategy_dir)

        i = 0
        while os.path.exists('{}{}{}'.format(strategy_dir, sep_str,
                                             "res" + str(i))):
            i += 1
        os.makedirs('{}{}{}'.format(strategy_dir, sep_str, "res" + str(i)))

        param_file = '{}{}{}{}param.txt'.format(strategy_dir, sep_str,
                                                "res" + str(i), sep_str)
        self.save_config_file(params=param, file_name=param_file)

        for guideline in self.performance.keys():
            if if_print:
                print('Evaluate <{}>...'.format(guideline),
                      self.performance[guideline])
            file_name = '{}{}{}{}{}'.format(strategy_dir, sep_str,
                                            "res" + str(i), sep_str, guideline)
            if guideline == "daily_pnl":
                Paint.plot_daily_pnl(self.performance[guideline],
                                     save_dir=file_name + ".png")
            self.performance[guideline].to_csv(file_name + ".csv")
예제 #4
0
def main():
    from pygame import K_q, K_w, K_a, K_s, K_z, K_x

    cube = Physical(  # 0         1            2            3           4            5            6            7
        vertices=((1, 1, 1), (1, 1, -1), (1, -1, 1), (1, -1, -1), (-1, 1, 1),
                  (-1, 1, -1), (-1, -1, 1), (-1, -1, -1)),
        edges=({0, 1}, {0, 2}, {2, 3}, {1, 3}, {4, 5}, {4, 6}, {6, 7}, {5, 7},
               {0, 4}, {1, 5}, {2, 6}, {3, 7}))

    counter_clockwise = 0.05  # radians
    clockwise = -counter_clockwise

    params = {
        K_q: (X, clockwise),
        K_w: (X, counter_clockwise),
        K_a: (Y, clockwise),
        K_s: (Y, counter_clockwise),
        K_z: (Z, clockwise),
        K_x: (Z, counter_clockwise),
    }

    def keys_handler(keys):
        for key in params:
            if keys[key]:
                cube.rotate(*params[key])

    pygame.init()
    pygame.display.set_caption('Control -   q,w : X    a,s : Y    z,x : Z')
    Paint(cube, keys_handler)
def login_verify():

    username1 = username_verify.get()
    password1 = password_verify.get()
    username_entry1.delete(0, END)
    password_entry1.delete(0, END)

    list_of_files = os.listdir()
    if username1 in list_of_files:
        file1 = open(username1, "r")
        verify = file1.read().splitlines()
        if password1 in verify:
            login_sucess()
            Paint.run_it()
        else:
            password_not_recognised()

    else:
        user_not_found()
예제 #6
0
def continue_after():
    global epoch, performance_datalist
    if not check:
        frame.pack_forget()
        left_frame.pack_forget()
        esttime.pack_forget()
        title2.pack_forget()
        plt.plot(range(epoch + 1), performance_datalist)
        plt.xlabel('Number of Epochs')
        plt.ylabel('Performance (% Correct)')
        plt.savefig('graph_image.png')
        im = Image.open('graph_image.png')
        im.save('graph_image.gif')
        cv = Paint(root, net)
    else:
        root.after(1000, continue_after)
예제 #7
0
def main(function, step, file_name, fig_id=1):
    start_pos = [50, 50]
    alpha = get_alpha(start_pos[0], start_pos[1], function)
    print('alpha = ' + str(alpha))
    next_pos = get_next_coord(start_pos[0], start_pos[1], alpha, step)
    print(next_pos)
    num_iter = 300//step  # количество отрисованных отрезков
    for i in range(num_iter):
        '''
        draw - отрисовка линии
        возвращает вторую точку
        '''
        start_pos = P.draw(start_pos, next_pos, png_file=file_name, fig_num=fig_id)
        alpha = get_alpha(start_pos[0], start_pos[1], function)
        print('alpha = ' + str(alpha))
        next_pos = get_next_coord(start_pos[0], start_pos[1], alpha, step)
        print(next_pos)
    print('end')
예제 #8
0
    def plot_all_Performance(factor_analyzer, _name, booksize=1000000):
        for factor_i in factor_analyzer.factors_list:
            print('Evaluate <{}> performance...'.format(factor_i))
            # print(factor_i)
            p_demo_industry = Performance(factor_analyzer.cleaned_factor_data,
                                          factor_i,
                                          demeaned=True,
                                          neutral_type='industry')
            print(p_demo_industry.performance['turnover'])
            p_demo_none = Performance(factor_analyzer.cleaned_factor_data,
                                      factor_i,
                                      demeaned=True,
                                      neutral_type='None')
            pnl_industry_daily = p_demo_industry.performance['daily_pnl']
            pnl_none_daily = p_demo_none.performance['daily_pnl']

            plot_industry = {}
            plot_none = {}
            plot_industry['data'], plot_industry[
                'name'] = Paint.plot_cumsum_pnl(pnl_industry_daily,
                                                '{}_{}_{}'.format(
                                                    _name, factor_i,
                                                    'industry'),
                                                booksize,
                                                if_show=False)
            plot_none['data'], plot_none['name'] = Paint.plot_cumsum_pnl(
                pnl_none_daily,
                '{}_{}_{}'.format(_name, factor_i, 'none'),
                booksize,
                if_show=False)
            Paint.compare_plot(plot_none, plot_industry, if_show=False)
            for guideline in ['turnover', 'fitness', 'sharpe']:
                Paint.plot_annual_guideline(
                    guideline=p_demo_industry.performance[guideline],
                    name='{}_{}_{}'.format(_name, factor_i, guideline),
                    if_show=False)
예제 #9
0
scaleX2 = memX.max()
scaleY2 = memY.max()

scaleListX = np.array([scaleX1, scaleX2])
scaleListY = np.array([scaleY1, scaleY2])

scaleX = windowScaleX / scaleListX.max()
scaleY = windowScaleY / scaleListY.max()

print("scaleX=" + str(scaleX))
print("scaleY=" + str(scaleY))
#---------- drawing img

root = Tk()
root.geometry(str(windowScaleX) + "x" + str(windowScaleY) + "+100+100")
p = Paint(root)
scaleX = scaleX * 0.7
scaleY = scaleY * 0.7
indent = 50  #to see all img
circleDiameter = 0.1 * scaleX
widthLine = 0.1 * scaleX
for i in range(procPins.size):
    p.drawCircle(newX=procX[i] * scaleX + indent,
                 newY=procY[i] * scaleY + indent,
                 newBrushSize=circleDiameter,
                 newColor="green")

for i in range(40, 40 + memPins.size):
    p.drawCircle(newX=memX[i] * scaleX + indent,
                 newY=memY[i] * scaleY + indent,
                 newBrushSize=circleDiameter,
예제 #10
0
    def __init__(self):
        """ Initialize application which uses OpenCV + Tkinter. It displays
            a video stream in a Tkinter window and stores current snapshot on disk """
        self.vs = cv2.VideoCapture(
            0)  # capture video frames, 0 is your default video camera

        # self.output_path = output_path  # store output path
        self.current_image = None  # current image from the camera
        ok, frame = self.vs.read()  # reading opencv
        if not ok:
            messagebox.showerror("ERROR",
                                 "Check the webcam connection and try again")
            self.vs.release()  # release web camera
            cv2.destroyAllWindows()
            exit()

        Application.filter_point = np.zeros_like(frame)  # start saving picture

        self.root = tk.Tk()  # initialize root window
        self.root.geometry("910x600")  # size of window
        self.root.title("Webcam_Paint")  # set window title
        # self.destructor function gets fired when the window is closed
        self.root.protocol('WM_DELETE_WINDOW',
                           self.destructor)  # destroy behavior

        self.panel = tk.Label(self.root)  # initialize image panel
        self.panel.pack(padx=10, pady=10, side='left')  # show panel

        # size of window display
        self.screen_width = self.root.winfo_screenwidth()
        self.screen_height = self.root.winfo_screenheight()

        # create a buttons and remembering they in list-button, that when pressed the command is called
        btn_start = tk.Button(self.root,
                              text="START",
                              font=100,
                              command=self.reading,
                              bg="lightgreen")
        btn_start.pack(padx=10, pady=10, ipadx=100,
                       ipady=100)  # show BIG START button
        btn_info = tk.Button(self.root,
                             text="INFO",
                             font=100,
                             command=self.inform,
                             bg="lightblue")
        btn_info.pack(padx=10, pady=10, ipadx=110, ipady=100)
        Application.button.append(btn_start)
        Application.button.append(
            tk.Button(self.root, text="CLICK ME!",
                      command=self.counting))  # сччтает клики СLICK_ME
        Application.button.append(
            tk.Button(self.root, text="NEXT", command=self.moving))
        Application.button.append(
            tk.Button(
                self.root, text="RESTART",
                command=self.reading))  # меняет состояние на чтение-калибровку
        Application.button.append(
            tk.Button(self.root, text="CHANGE_MODE",
                      command=self.change_calib))

        Application.button.append(
            tk.Button(self.root, text="REC", command=self.rec))

        Application.button.append(btn_info)
        self.backBut = []
        self.backBut.append(
            tk.Button(self.root, text="BACK", command=self.back_to_start))
        self.backBut.append(
            tk.Button(self.root, text="BACK", command=self.back_to_read))
        self.backBut.append(
            tk.Button(self.root, text="BACK", command=self.back_to_setting))
        # create a scrolls and labels-scrolls
        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="b_min"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="g_min"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="r_min"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="b_max"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="g_max"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=0,
                     to=255))
        Application.label.append(tk.Label(self.root, text="r_max"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=1,
                     to=50))
        Application.label.append(tk.Label(self.root, text="blur_coef"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=1,
                     to=50))
        Application.label.append(tk.Label(self.root, text="coef_rect_in"))

        Application.scroll.append(
            tk.Scale(self.root,
                     length=255,
                     orient='horizontal',
                     from_=1,
                     to=50))
        Application.label.append(tk.Label(self.root, text="coef_rect_out"))

        # inform labels
        Application.info_label.append(
            tk.Label(
                self.root,
                text="Place the marker object\nin the area of the square\n "
                "and click the button.\n"
                "SRUARE changes position\n(12 button clicks)",
                font=20))
        Application.info_label.append(
            tk.Label(
                self.root,
                text=
                "Put your hand\n(mb in the glove)\nin the area of the squares\n "
                "and click the button.\n(1 button click)",
                font=20))
        # инит пэинта
        self.paint = Paint.Paint()
        self.paint.init(self.root)
        # start a self.video_loop that constantly pools the video sensor
        # for the most recently read frame
        self.video_loop()
예제 #11
0
# *****   2.7 and the widgets contained in each. In this case, we use     *****
# *****   a variety of frame based classes to have compartmentelized code *****
# *****   for each sub piece of the car.                                  *****
# *****************************************************************************

from XExtraOptions import *
from HeaderBar import *
from Paint import *
from Options import Options
from PowerRange import PowerRange
from Home import *
from ContactInfo import *
from ttk import *

# each item can be called via a button, or otherwise as needed
# thecar is defined in Globals.py, and acts as our common information
# need to erase settings if we change model of the car

HeaderBar(thecar)
stuff = Notebook()
stuff.add(Home(), text="Home")
stuff.add(PowerRange(), text="Power")
stuff.add(Paint(), text="Paint")
stuff.add(Options(), text="Options")
stuff.add(XInteriorOptions(), text="Interior Options")
stuff.add(ContactInfo(), text="Contact")

stuff.grid()

thecar.mainloop()
예제 #12
0
def query():
    graph_frame.pack_forget()
    b.pack_forget()
    cv = Paint(root, net)
예제 #13
0
scaleX2=memX.max()
scaleY2=memY.max()

scaleListX=np.array([scaleX1,scaleX2])
scaleListY=np.array([scaleY1,scaleY2])

scaleX=windowScaleX/scaleListX.max()
scaleY=windowScaleY/scaleListY.max()

print("scaleX="+str(scaleX))
print("scaleY="+str(scaleY))
#---------- drawing img

root = Tk()
root.geometry(str(windowScaleX)+"x"+str(windowScaleY)+"+100+100")
p=Paint(root)
scaleX=scaleX*0.7
scaleY=scaleY*0.7
indent=50 #to see all img
circleDiameter=0.1*scaleX
widthLine=0.1*scaleX
for i in range(procPins.size):
    p.drawCircle(newX=procX[i]*scaleX+indent, newY=procY[i]*scaleY+indent,newBrushSize=circleDiameter,newColor="green")

for i in range(40, 40+memPins.size):
    p.drawCircle(newX=memX[i]*scaleX+indent, newY=memY[i]*scaleY+indent,newBrushSize=circleDiameter,newColor="red")

myLineMas=[]

for i in range(40):