예제 #1
0
 def test_crossover(self):
     run = Run()
     p1 = [1,2,3,4,5]
     p2 = [3,2,4,5,1]
     expected = [1,2,3,5,4]
     real = run.crossover(p1,p2)
     print(real)
     self.assertEqual(expected, real)
예제 #2
0
    def createRunBySite(self, site_name):

        if (site_name == None):
            return None

        run = Run()
        site = Site()
        site.setShortName(site_name)
        run.setSite(site)
        return (self.createRun(run))
예제 #3
0
    def test_pick_two_swappers(self):
        run = Run()
        array_1 = [1, 2, 3, 4, 5, 6, 7]

        real = run.pick_two_swappers(array_1)

        self.assertGreater(real[0], 0)
        self.assertGreater(real[1], 0)
        self.assertLessEqual(real[0], 7)
        self.assertLessEqual(real[1], 7)
        self.assertEqual(len(real), 2)
예제 #4
0
 def test_mutate(self):
     # Todo!
     run = Run()
     array_1 = [1, 2, 3, 4, 5, 6, 7]
     result = run.mutate(array_1)
     print(array_1)
     print(result)
     # the lengths of the lists are the same
     self.assertEqual(len(array_1), len(result))
     # But the order must be different
     self.assertNotEqual(array_1, result)
예제 #5
0
    def test_swap(self):
        self.run = Run()

        array_1 = [1,2,3,4,5,6,7]
        i = 1
        j = 4
        print('/nExpected:')
        expected = [1,5,3,4,2,6,7]
        print(expected)
        real = self.run.swap(array_1, i, j)
        print("Real:")
        print(real)

        self.assertEqual(real, expected)
예제 #6
0
 def genInParams(self, proj, show_panel):
     Run.read_blob(proj)
     params = Run.read_param(proj)
     scrollPanel = show_panel.scrolledWindow
     show_panel.staticText4 = wx.StaticText(
         scrollPanel, wx.ID_ANY, u"模型输入参数共" + str(len(params)) + u"个:",
         wx.DefaultPosition, wx.DefaultSize, 0)
     show_panel.gbSizer.Add(show_panel.staticText4, wx.GBPosition(7, 4),
                            wx.GBSpan(1, 2), wx.ALL, 5)
     show_panel.staticText5 = wx.StaticText(scrollPanel, wx.ID_ANY, u"参数描述",
                                            wx.DefaultPosition,
                                            wx.DefaultSize, 0)
     show_panel.gbSizer.Add(show_panel.staticText5, wx.GBPosition(7, 4),
                            wx.GBSpan(1, 2), wx.ALL, 5)
     show_panel.Layout()
예제 #7
0
    def getRunByID(self, run_id, lock=False):

        if (run_id == None):
            self._printError("Requires a run_id to be specified.")
            return None

        run = Run()
        run.setRunID(run_id)

        # Query existing data for this run_id
        runs = self.getRuns(run, lock)
        if (runs == None):
            return None

        return runs[0]
예제 #8
0
def loadslices(base, dim, boxsize):
    """from specified directory base find all 21cm boxes with
    pixel dimensions dim and boxlength boxsize and sort them
    into a list of Slices"""

    #first identify relevant files
    filenames = findrun(base, dim, boxsize)

    #now sort them into redshift collections
    filedict = dictByRedshift(filenames)

    print filedict

    myrun = Run()
    myrun.setFromDict(filedict)

    return myrun
    def reco(self):
        bbox = (110, 150, 480, 400)
        im = ImageGrab.grab(bbox)
        img = cv2.cvtColor(numpy.asarray(im), cv2.COLOR_RGB2BGR)
        if (self.xiala.currentText() == 'CNN'):
            re = ''
            tr = Run.Run(img, 1)
            print(tr)
            re = ''.join(str(s) for s in tr)

        elif (self.xiala.currentText() == 'DNN'):
            re = ''
            rt = Run.Run(img, 2)
            print(rt)
            re = ''.join(str(s) for s in rt)
        self.label_result.setText(re)
        self.update()
예제 #10
0
def loadslices(base,dim,boxsize):
    """from specified directory base find all 21cm boxes with
    pixel dimensions dim and boxlength boxsize and sort them
    into a list of Slices"""

    #first identify relevant files
    filenames=findrun(base,dim,boxsize)

    #now sort them into redshift collections
    filedict=dictByRedshift(filenames)

    print filedict

    myrun=Run()
    myrun.setFromDict(filedict)

    return myrun
예제 #11
0
    def getRunStatsByID(self, run_id):

        if (run_id == None):
            self._printError("Requires a run_id to be specified.")
            return None

        run = Run()
        run.setRunID(run_id)

        # Query existing data for this run_id
        runs = self.getRuns(run, lock=False)
        if (runs == None):
            return None

        # Collect statistics
        runstat = self.__getRunStats(runs[0])

        return runstat
예제 #12
0
    def getRunsByParam(self, site, erf_id, sgt_var_id, rup_var_id, lock=False):
        if ((site == None) or (erf_id == None) or \
                (sgt_var_id == None) or (rup_var_id == None)):
            self._printError("Requires site name, erf, sgt_var, and rup_var.")
            return None

        run = Run()
        site = Site()
        site.setShortName(site)
        run.setSite(site)
        run.setERFID(erf_id)
        run.setSGTVarID(sgt_var_id)
        run.setRupVarID(rup_var_id)

        # Query existing data for this combination
        runs = self.getRuns(run, lock)
        if (runs == None):
            return None

        return runs[0]
예제 #13
0
def service_python():
    if not request.json:
        return

    if not 'data' in request.json:
        return

    if not 'tests' in request.json:
        return

    Run.ParsePython(conn, request.json)
예제 #14
0
def slepton_mass(i, scandir):
    fit1 = Run.adaptive_scan(
        [["me2", "EXTPAR", ["16"]], ["me332", "EXTPAR", ["17"]]],
        [["se1", "MASS", ["1000011"]], ["se3", "MASS", ["1000015"]],
         ["ch1", "MASS", ["1000022"]], ["ch2", "MASS", ["1000023"]]],
        [1000, 1200, 1200, 2000, 2000],
        adapt_sleptons,
        Init.changemultiparameter,
        SPheno_MSSM,
        model="MSSM")
    fit1(i, scandir)
예제 #15
0
def stop_mass(i, scandir):
    fit1 = Run.adaptive_scan(
        [["mq2", "EXTPAR", ["13"]], ["mu2", "EXTPAR", ["9"]],
         ["md2", "EXTPAR", ["15"]]],
        [["su1", "MASS", ["1000002"]], ["su2", "MASS", ["1000004"]],
         ["sd2", "MASS", ["1000003"]]], [1000, 1200, 1200],
        adapt_stop_mass,
        Init.changemultiparameter,
        SPheno_MSSM,
        model="MSSM")
    fit1(i, scandir)
    wrapper(i, scandir)
 def runQueue(self):
     size = self.listbox.size()
     queue = self.listbox.get(0, size)
     q1 = Run.Run(queue, size, self.root)
     try:
         _thread.start_new_thread(q1.runQueue, ())
     except:
         print("Error: unable to start thread")
     try:
         _thread.start_new_thread(self.wait, (q1, ))
     except:
         print("Error: unable to start thread wait")
    def retranslateUi(self, ReviewsWindow):
        _translate = QtCore.QCoreApplication.translate
        ReviewsWindow.setWindowTitle(_translate("ReviewsWindow", "Reviews"))
        self.featureSelectLabel.setText(
            _translate("ReviewsWindow", "Select Feature"))
        self.label.setText(_translate("ReviewsWindow", "Positive Reviews"))
        self.label_2.setText(_translate("ReviewsWindow", "Negative Reviews"))

        #our stuff
        self.featurecomboBox.addItem("All")
        self.featurecomboBox.addItem("Camera")
        self.featurecomboBox.addItem("Battery")
        self.featurecomboBox.addItem("Screen")
        self.featurecomboBox.addItem("Memory")
        self.featurecomboBox.addItem("Size")
        self.featurecomboBox.addItem("Audio")
        self.featurecomboBox.addItem("Processor")
        asin = Asin.getAsinValue()
        Run.pos_neg(asin)
        self.show(asin)
        self.featurecomboBox.currentIndexChanged.connect(self.search)
예제 #18
0
    def do_GET(self):
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        self.wfile.write(
            bytes("<html><head><title>PyMiner</title></head>", "utf-8"))
        self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8"))
        self.wfile.write(bytes("<body>", "utf-8"))
        self.wfile.write(bytes("<p>Player Data:</p>", "utf-8"))
        self.wfile.write(bytes("</body></html>", "utf-8"))
        query_components = parse_qs(urlparse(self.path).query)
        if 'posX' in query_components:
            Variables.posX = query_components["posX"][0]
            Run.commands()
        if 'posY' in query_components:
            Variables.posY = query_components["posY"][0]
            Run.commands()
        if 'posZ' in query_components:
            Variables.posZ = query_components["posZ"][0]
            Run.commands()

        positionX = f"<html><head></head><body><h1>Current Player X: {Variables.posX}</h1></body></html>"
        positionY = f"<html><head></head><body><h1>Current Player Y: {Variables.posY}</h1></body></html>"
        positionZ = f"<html><head></head><body><h1>Current Player Z: {Variables.posZ}</h1></body></html>"
        # Some custom HTML code, possibly generated by another function
        # Writing the HTML contents with UTF-8
        self.wfile.write(bytes(positionX, "utf8"))
        self.wfile.write(bytes(positionY, "utf8"))
        self.wfile.write(bytes(positionZ, "utf8"))
예제 #19
0
class MyTestCase(unittest.TestCase):

    def test_swap(self):
        self.run = Run()

        array_1 = [1,2,3,4,5,6,7]
        i = 1
        j = 4
        print('/nExpected:')
        expected = [1,5,3,4,2,6,7]
        print(expected)
        real = self.run.swap(array_1, i, j)
        print("Real:")
        print(real)

        self.assertEqual(real, expected)

    def test_pick_two_swappers(self):
        run = Run()
        array_1 = [1, 2, 3, 4, 5, 6, 7]

        real = run.pick_two_swappers(array_1)

        self.assertGreater(real[0], 0)
        self.assertGreater(real[1], 0)
        self.assertLessEqual(real[0], 7)
        self.assertLessEqual(real[1], 7)
        self.assertEqual(len(real), 2)

    def test_mutate(self):
        # Todo!
        run = Run()
        array_1 = [1, 2, 3, 4, 5, 6, 7]
        result = run.mutate(array_1)
        print(array_1)
        print(result)
        # the lengths of the lists are the same
        self.assertEqual(len(array_1), len(result))
        # But the order must be different
        self.assertNotEqual(array_1, result)

    def test_crossover(self):
        run = Run()
        p1 = [1,2,3,4,5]
        p2 = [3,2,4,5,1]
        expected = [1,2,3,5,4]
        real = run.crossover(p1,p2)
        print(real)
        self.assertEqual(expected, real)
def run_tool(fname, props_data):
    """
    This command run tool
    """
    for key in props_data.keys():
        cmd = ["vcs", "-R", fname, key + ".v"]
        print "command for vector generation %s" % (" ".join(cmd))
        with open("%s.log" % fname, "w") as fout:
            state = Run.Popen(cmd, stdout=fout, stderr=fout).wait()
            if state != 0:
                print(
                    "Error: Simulation falied. See details in "
                    "%s.lis(or .log) file." % fname)
                return 1
    return 0
예제 #21
0
 def upload(self):  ##上传图像,并检测图片尺寸,尺寸应小于1000*1000
     imgName, imgType = QFileDialog.getOpenFileName(
         self, "打开图片", "", "*.jpg;;*.png;;All Files(*)")
     if imgName == '':  ##关闭文件夹则pass(即文件为空)
         pass
     else:
         self.uploadimg = imgName
         jpg = QtGui.QPixmap(imgName).scaled(self.label.width(),
                                             self.label.height())
         self.label.setPixmap(jpg)
         img = Run.cv_imread(self.uploadimg)
         if img.shape[0] > 1000 or img.shape[1] > 1000:
             self.pushButton_2.setDisabled(True)
             self.ImageSizeError()
         else:
             self.pushButton_2.setDisabled(False)
예제 #22
0
def swapflag(db, scanp):
    # comm = ('SELECT C.identifier, C.lamsd, C.lamsu'
    #         'FROM (SELECT points.identifier, IFNULL(mhmw.mh1,0)'
    #         'AS fls,points.lamsd, points.lamsu FROM points'
    #         'LEFT OUTER JOIN mhmw ON points.identifier=mhmw.identifier) C'
    #         'WHERE C.fls==0')
    # pts = Init.points(db,comm)
    method = []
    # for i in range(len(pts)-1):
    #     # if pts[i-1][0] == pts[i][0]-1 and pts[i+1][0] == pts[i][0]+1:
    #     #     continue
    #     # else:
    #     method.append(pts[i][0])
    print len(method)
    runfunc = Run.run_on_dir(scanp)
    twolchange = Init.changeSLHAwrapper(Init.changeoneparameter,
                                        ['tachy', 'SPhenoInput', ['52']], 0)
    runfunc(twolchange, parallel=False)
예제 #23
0
 def work(self):  ##调用Pose函数处理图片并显示在窗口上
     self.sinOut2.emit("start")  ##向信号队列sinOut2发送start信号
     self.pushButton_2.setDisabled(True)
     tic = time.time()
     pc = Run.Pose(self.uploadimg)[1]
     print(pc)
     jpg = QtGui.QPixmap("result.png").scaled(self.label.width(),
                                              self.label.height())
     self.label_2.setPixmap(jpg)
     jpg = QtGui.QPixmap("only_Pose.png").scaled(self.label.width(),
                                                 self.label.height())
     self.label_3.setPixmap(jpg)
     toc = time.time()
     print("The process time is %.1fs" % (toc - tic))
     self.pushButton_2.setDisabled(False)
     durationT = round((toc - tic), 2)
     self.sinOut2.emit("end")  ###处理结束后向信号队列sinOut2发送end信号
     self.sinOut.emit(str(durationT))  ##向信号队列sinOut发送时间信号
     self.sinOut3.emit(pc)
예제 #24
0
    def __init__(self):

        # Check the OS first
        if not str(sys.platform) == "darwin":
            self.head("Incompatible System")
            print(" ")
            print("This script can only be run from macOS/OS X.")
            print(" ")
            print("The current running system is \"{}\".".format(sys.platform))
            print(" ")
            self.grab("Press [enter] to quit...")
            print(" ")
            exit(1)
        # Init some vars
        self.apfs        = self.apfs_path = "/usr/standalone/i386/apfs.efi"
        self.hex_find    = "00 74 07 B8 FF FF"
        self.hex_replace = "00 90 90 B8 FF FF"

        self.hex_digits  = "0123456789ABCDEF"
        # Credit to PMHeart for the hex patch
        self.r = Run.Run()
        self.u = Utils.Utils("APFS Non Verbose")
예제 #25
0
def stop_mass_wrapper(i, scandir):
    fit1 = Run.adaptive_scan(
        [
            ["mq2", "EXTPAR", ["13"]],
            ["mu2", "EXTPAR", ["9"]],
            ["md2", "EXTPAR", ["15"]],
            #["mo2","EXTPAR",["20"]]
        ],
        [
            ["su1", "MASS", ["1000002"]],
            ["su2", "MASS", ["1000004"]],
            ["sd2", "MASS", ["1000003"]],
            # ["phiO","MASS",["3000021"]]
        ],
        [2000, 3000, 3000],
        adapt_stop_mass,
        Init.changemultiparameter,
        SPheno_MRSSM,
        eps=0.001)
    SPheno_MRSSM(i, scandir)
    fit1(i, scandir)
    wrapper(i, scandir)
 def onClick(self):
     if (self.BrandRadio.isChecked() == True):
         product = str(self.ProductCombo.currentText())
         textboxValue = Asin.getAsinCompare(product)
         Run.crawl(textboxValue)
         Run.convert(textboxValue)
         self.setAsin(textboxValue)
         self.openDashboard()
     elif (self.AsinRadio.isChecked() == True):
         textboxValue = self.Asintext.text()
         if (len(textboxValue) != 10):
             msgbox = QtWidgets.QMessageBox()
             msgbox.setGeometry(550, 340, 600, 450)
             msgbox.setIcon(QtWidgets.QMessageBox.Warning)
             msgbox.setText("Please enter valid ASIN!")
             msgbox.setWindowTitle("Error")
             msgbox.setEscapeButton(QtWidgets.QMessageBox.Close)
             msgbox.exec_()
             self.Asintext.clear()
         else:
             Run.crawl(textboxValue)
             Run.convert(textboxValue)
             self.setAsin(textboxValue)
             self.openDashboard()
예제 #27
0
    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title('qmcPACK Input Builder')
        manager = MainManager()
        self.window.add_accel_group(manager.get_accel_group())
        manager.Setup()
        mainMenu = manager.get_widget("/MenuBar")
        mainBox = gtk.VBox()
        mainBox.pack_start(mainMenu, False, False)
        # Connect menu callbacks
        manager.SaveAsAction.connect("activate", self.save_as_callback)
        manager.SaveAction.connect("activate", self.save_callback)
        self.About = GUIAboutDialog()
        manager.AboutAction.connect("activate", self.about_callback)

        self.window.connect("delete_event", self.delete)
        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_LEFT)
        self.GeometryFrame = Geometry()
        self.WavefunctionFrame = Wavefunction()
        self.RunFrame = Run()
        notebook.append_page(self.GeometryFrame, gtk.Label("Geometry"))
        notebook.append_page(self.WavefunctionFrame,
                             gtk.Label("Wave function"))
        notebook.append_page(self.RunFrame, gtk.Label("Run"))
        if (viewerOkay):
            self.Viewer = StructureViewer()
            notebook.append_page(self.Viewer, gtk.Label("Viewer"))
        mainBox.pack_start(notebook, False, False, 5)
        self.window.add(mainBox)
        # Setup dialogs
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE,
                   gtk.RESPONSE_OK)
        self.SaveAsDialog = gtk.FileChooserDialog("Save qmcPACK input as", \
                                                  self.window, gtk.FILE_CHOOSER_ACTION_SAVE, buttons)
        self.SaveAsDialog.hide()
        self.Filename = None
        self.window.show_all()
예제 #28
0
    def TryRun(self, event):
        show_panel = self.GetCurrentPage()
        model_id = show_panel.old_id
        inputform = show_panel.inputform
        varsform = show_panel.varsform
        outputform = show_panel.outputform
        inputargs = []
        vars = []
        """保存输入参数信息到inputargs"""
        for i in range(inputform.GetItemCount()):
            inputargs.append(float(inputform.GetItemText(i, 2)))
        """保存自变量信息到vars"""
        for i in range(varsform.GetItemCount()):
            vars.append(float(varsform.GetItemText(i, 2)))

        result = Run.tryrun(model_id, vars, inputargs)
        print '=================================运行成功', result
        if type(result) == float:
            outputform.SetStringItem(0, 3, str(result))
        elif type(result) == tuple:
            for i in range(min(len(result), outputform.GetItemCount())):
                outputform.SetItem(i, 3, str(result[i]))
        show_panel.Refresh()
예제 #29
0
# _*_ coding:utf-8 _*_
"""
-----------------------------------------------------------
 Name:            ToolsProject/__init__.py
 Purpose:         

 Author:          lucas.wang

 Created:         2018-07-30
 Copyright:       (C) lucas.wang 2018
 Licence:          MIT
 ----------------------------------------------------------
"""
# ! /usr/bin/env python

import configparser
import Run
import Global

cp = configparser.SafeConfigParser()
cp.read('Config.cfg')
# cp.read('MaVie_Config.cfg')

if __name__ == '__main__':

    Global.set_master_1_url(cp.get('Master-1', 'URL'))
    Global.set_master_2_url(cp.get('Master-2', 'URL'))
    Global.set_comm_week(cp.get('Week', 'Run_Week'))

    run = Run.init_run()
    run.main()
예제 #30
0
    # Data Shit
    data = []
    if os.path.isdir('Data') is False:
        Data.get_data_from_yahoo()

        print("Hello")
    os.mkdir('/Data1')
    #Update data instead

    # for item in Data folder, update most recent data
    currDate = start
    dict = {"Targets": 0, "Stops": 0}
    print("STARTING BACKTEST")
    #strategy must be defined here
    while currDate != dt.datetime.today:
        count = 0
        # testData = Fit.rolling_window(data, count)

        # fit data to find best strategy

        # test strategy on following year data

        portfolio = r.run(data, portfolio, 'BOrders.csv', dict, 0, date)
        date = a.next_business_day(date)
        print("\n")

    print("Target rate of {} made on {} trades".format(
        dict["Targets"] / (dict["Stops"] + dict["Targets"]),
        dict["Stops"] + dict["Targets"]))
    print(portfolio)
예제 #31
0
            if ret.is_valid == False:
                tips = '验证码错误'
                break
            if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) == None:
                email = None
            if passwd == None or qq == None:
                tips = 'SKey or QQ 不合法,重新输入'
                break
            if email != None:
                Data.updateUserEmailData(qq, email)
            Data.updateUserData(qq, passwd)
            tips = '提交成功,每日0和12点自动签到'
            break
        self.render("template_taken.html",
        title = 'QQ群自动签到',
        tips = tips)

if __name__ == "__main__":
    settings = {
    "static_path": os.path.join(os.path.dirname(__file__), "static")
    }

    application = tornado.web.Application([
        (r"/taken", TakenHandler),
        (r"/", NormalHandler),
    ], **settings)
    application.listen(7788)

    Run.Run()

    tornado.ioloop.IOLoop.instance().start()
예제 #32
0
        if verbose:
           print "now processing files for execution:%s" % execName
        concurrency = e['concurrency']
        if (concurrency.find("PTHREADS") >= 0) or \
           (concurrency.find("OPENMP") >= 0):
           threaded = True
        else:
           threaded = False
 
        buildFile = eInfo.dataDir + "/" + execName + ".bld"
        # creates build and execution resources
        Build.getBuildInfo(resIdx, buildFile, execName, ptds)
 
        runFile = eInfo.dataDir + "/" + execName + ".run"
        #  uses build and execution resources in resIdx
        Run.getRunInfo(resIdx, runFile, eInfo, ptds)
       
        [execution] = resIdx.findResourcesByType("execution")  
        app.addExecution(execution)
        
        parsePerf.getPerfInfo(resIdx, execName, \
                       eInfo.dataDir, eInfo.perfTools,  \
                       threaded, ptds)
        writeLst = resIdx.PTdF()
        write_files(eInfo.dataDir, execName, writeLst, opt.split)
        print "PTDF execution data generation complete."
  except PTexception, a:
      if testMode:
         print a.value
         raise PTexception(a)
      else: