当前位置: 首页>>代码示例>>Python>>正文


Python Main类代码示例

本文整理汇总了Python中Main的典型用法代码示例。如果您正苦于以下问题:Python Main类的具体用法?Python Main怎么用?Python Main使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Main类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDependMatrix

def testDependMatrix():
    global sequenceCombinationDependMatrix
    for j in range(Main.countComp):
         sequenceCombinationDependMatrix[j] = 1
    while (getNextVarietyOfDependecyMatrix()):
        depMatr = []
        tmpMatr = []
        for k in range(len(sequenceCombinationDependMatrix)):
            tmpMatr.append(generalD[k][sequenceCombinationDependMatrix[k]-1])
        for k in range(len(tmpMatr)):
            tmparr = []
            for k1 in range(len(tmpMatr)):
                tmparr.append(-1)
            depMatr.append(tmparr)
        for k in range(len(tmpMatr)):
            for k1 in range(len(tmpMatr)):
                depMatr[k1][k] = tmpMatr[k][k1]
        #Now we have depend matrix and we should test is it works
        isCorrect = 1
        for i in range (1,len(resultMatrix)):
            testState = []
            Main.modelingNextState(resultMatrix[i],testState,depMatr,Main.countComp,Main.KState)
            val  = i + 1
            if val == len(resultMatrix):
                val = 0
            if testState != resultMatrix[val]:
                isCorrect = 0
                break
        if isCorrect == 1:
            print "Yes"
            print depMatr
开发者ID:Sobolvitya,项目名称:Diploma,代码行数:31,代码来源:SolveAlgorithm.py

示例2: main

def main():
    for filename in os.listdir(os.getcwd() + '/Output'): 
        if(filename[-4:] == '.mp3'): os.remove('Output/' + filename)
    localAudioFiles = []
    for filename in os.listdir(os.getcwd() + '/Input'):
        print filename
        if(filename != '.DS_Store' and filename != 'Thumb.db'):
            localAudioFiles.append(audio.LocalAudioFile('Input/' + filename))
    keys = [localAudioFiles[0].analysis.key['value'], localAudioFiles[1].
                analysis.key['value'], 0,0,0]
    for i,laf in enumerate(localAudioFiles[0:2]):
            if(laf.analysis.mode['value'] == 0): keys[i] = keys[i]+3
            if(keys[i] > 11): keys[i] = keys[i] - 12
    tempos = [localAudioFiles[0].analysis.tempo['value'], localAudioFiles[1].
                  analysis.tempo['value'], 0,0,0]
    localAudioFiles = matchTempoAndKey(localAudioFiles, tempos, keys)
    for i in range(3): localAudioFiles[i+2].encode(str(i)+'.mp3')
    print "tempos after match should equal midTempo: ", [laf.analysis.tempo['value']
                                                             for laf in localAudioFiles]
    equalize_tracks([localAudioFiles[0],localAudioFiles[1],localAudioFiles[2]])
    equalize_tracks([localAudioFiles[3],localAudioFiles[4]])
    print "len(localAudioFiles)/5 after match: ", len(localAudioFiles)/5
    loudnessMarkers = Main.findLoudestRegion([localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],
            [localAudioFiles[0].analysis.tempo['value'],
            localAudioFiles[1].analysis.tempo['value']])
    beatMarkers = Main.getBeatMarkers(loudnessMarkers,
            [localAudioFiles[0].analysis.segments,
            localAudioFiles[1].analysis.segments],[localAudioFiles[0].analysis.beats,
            localAudioFiles[1].analysis.beats])
    mashComponents(localAudioFiles, beatMarkers)  
开发者ID:JordanHawkins,项目名称:Demonstrations,代码行数:31,代码来源:AutoMashUp.py

示例3: handler

    def handler(self, request, threads):
        # Record the start timestamp
        start_time = datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d-%H:%M:%S")

        # Call Main to execute the kernel function
        # TODO: set configargs, json
        configargs = request
        Main.handler(configloader=ITRIConfigLoader.SQL2K5TConfig, configargs=configargs, db_handler=ITRIOutput.db_handler)
开发者ID:hyili,项目名称:Tree_Walker,代码行数:8,代码来源:Worker.py

示例4: get_result

    def get_result(self):
        Main.main(self.text)

        # заменить на target.txt
        for item in open("target.txt"):
            self.sys_txt.insert(END, item)

        if self.sys_txt.get("1.0", END + "-1c"):
            self.buffer_btn["state"] = NORMAL
开发者ID:fargelus,项目名称:RulesParser,代码行数:9,代码来源:graphics.py

示例5: test_worker_get

    def test_worker_get(self):
        if Main.server_state == 1:
            self.assertEqual(Main.worker_get(),
                             {'state': 'PAUSE', 'task': [], 'main_dot': Main.main_dot, 'worker_number': -1})
        elif Main.server_state == 0:
            self.assertEqual(Main.worker_get(), {'state': 'STOP', 'task': [], 'main_dot': [], 'worker_number': -1})

        elif Main.server_state == 2:
            self.assertNotEqual(Main.worker_get(), {})
开发者ID:komolebo,项目名称:Computer-architecture-Lab2,代码行数:9,代码来源:tests.py

示例6: createTestDataSet

def createTestDataSet(fileName, numExpr):
        global matrixA,pirsonMatrix,fileNameResult,fileNameDepend
        pirsonMatrix = []
        matrixA = []
        fileRes = fileNameResult + str(numExpr)+".txt"
        Main.read(fileRes, matrixA)
        global  size
        size = len(matrixA)
        CalculatePirsonCorelation(size)
        Main.write("DataMatrixExpr"+ str(numExpr)+".txt",pirsonMatrix)
开发者ID:Sobolvitya,项目名称:Diploma,代码行数:10,代码来源:PrepareDataForNN.py

示例7: get_image

 def get_image(self):
     """
     Prompts the Ximea camera to capture a photo after the next GPI spike.
     """
     try:
         self.camera.get_image(self.image)
         return self.image.get_image_data_numpy()
     except xiapi.Xi_error:
         Interface.choose_print(self.gui, 'camera', 'Xi_error: ERROR 10: Timeout')
         Main.abort_session()
         return None
开发者ID:GhoulPoP,项目名称:ProjectScarberry,代码行数:11,代码来源:XimeaController.py

示例8: general

def general():
	for message in file_read:
		if message.startswith("#"):
			pass
		else:
			try:
				Main.check_Message_Contents(message)
				time.sleep(1)
				Main.Word_based_string(message)
				time.sleep(1)
				Main.Unusual_charecter_codes(message)
				time.sleep(1)
			except Exception as e:
				print(e)
				input(" ")
开发者ID:brandonskerritt51,项目名称:Ciphey,代码行数:15,代码来源:Main_test.py

示例9: OnInit

    def OnInit(self):
        self.main = Main.create(None)
        self.main.Show()
        self.SetTopWindow(self.main)

#        self.main.SetTransparent(200)
        return True
开发者ID:lpellis,项目名称:Camera-Mouse,代码行数:7,代码来源:CameraMouse.py

示例10: __init__

    def __init__(self, unknown=None):
        self.variables = []
        self.authors = []
        self.author_names = []
        self.essay_names = []
        i=-1

        # Checks if supplied data is a dict
        if isinstance(unknown, dict):
            self.essay_vectors = unknown
        else:
            self.essay_vectors = Main.get_essay_vectors(unknown)

        for author, data in self.essay_vectors.iteritems():
            i += 1
            self.author_names.append(author)
            for essay, data in data.iteritems():
                self.authors.append(i)
                self.variables.append(data)
                self.essay_names.append(essay)

        # Add padding zeros to make vectors uniform length
        max_length = max(map(len, self.variables))
        for i in range(len(self.variables)):
            self.variables[i].extend([0] * (max_length - len(self.variables[i])))

        X = np.array(self.variables) #@UndefinedVariable
        self.y = np.array(self.authors) #@UndefinedVariable
        self.target_names = np.array(self.author_names) #@UndefinedVariable

        self.pca = PCA(n_components=2)
        self.X_r = self.pca.fit(X).transform(X)
开发者ID:,项目名称:,代码行数:32,代码来源:

示例11: show

 def show(self, color, options):
     # scan for options that can override the ctor options
     self.__wantspec = options.get('wantspec', self.__wantspec)
     dbfile = options.get('databasefile', self.__databasefile)
     # load the database file
     colordb = None
     if dbfile <> self.__databasefile:
         colordb = ColorDB.get_colordb(dbfile)
     if not self.__master:
         from Tkinter import Tk
         self.__master = Tk()
     if not self.__pw:
         self.__pw, self.__sb = \
                    Main.build(master = self.__master,
                               initfile = self.__initfile,
                               ignore = self.__ignore)
     else:
         self.__pw.deiconify()
     # convert color
     if colordb:
         self.__sb.set_colordb(colordb)
     else:
         colordb = self.__sb.colordb()
     if color:
         r, g, b = Main.initial_color(color, colordb)
         self.__sb.update_views(r, g, b)
     # reset the canceled flag and run it
     self.__sb.canceled(0)
     Main.run(self.__pw, self.__sb)
     rgbtuple = self.__sb.current_rgb()
     self.__pw.withdraw()
     # check to see if the cancel button was pushed
     if self.__sb.canceled_p():
         return None, None
     # Try to return the color name from the database if there is an exact
     # match, otherwise use the "#rrggbb" spec.  BAW: Forget about color
     # aliases for now, maybe later we should return these too.
     name = None
     if not self.__wantspec:
         try:
             name = colordb.find_byrgb(rgbtuple)[0]
         except ColorDB.BadColor:
             pass
     if name is None:
         name = ColorDB.triplet_to_rrggbb(rgbtuple)
     return rgbtuple, name
开发者ID:0xcc,项目名称:python-read,代码行数:46,代码来源:pyColorChooser.py

示例12: main

def main(args):
    """Then entry point to this program.
    
    Arguments:
    args -- a list of specifications to how the program should be run. The format should be:
    - output_file   -- The file to write the result to
    - markov_order  -- The number of words each generated word uses (must be integer greater than 0)
    - training_file -- This is a varargs argument. Each training_file will be used for data to generate words.
    """
    if len(args) < 2:
        sys.stderr.write("Usage: <markov_order> <training_file> ...")
        return

    try:
        chunk_size = int(args[0])  # the size of each the word chunks that will make up the output
    except ValueError:
        sys.stderr.write("Numerical arguments must be non-negative integers")
        return
    files = args[1:]  # the training files

    # Error Handling
    if chunk_size < 1:
        sys.stderr.write("Markov order must exceed 0")
        return

    """maps tuples of words maps of the words that are preceded by the tuples in the training docs.
    Each map matches the following-word with the number of times it occurs as a following word"""
    bigram_counts = {}

    try:
        for file_name in files:  # for each file passed in, store data from that file in global maps
            process_file(file_name, chunk_size, bigram_counts)
    except IOError:
        print "Invalid file path"
        return
    print "Training data recorded"

    probabilities = {}
    Main.calculate_probabilities(
        bigram_counts, probabilities
    )  # determine probabilities of generating a word given a previous word
    print "Markov probabilities calculated"

    result = produce_text(probabilities, chunk_size)
    print "RESULT: " + result
开发者ID:bryceAebi,项目名称:MarkovRandomText,代码行数:45,代码来源:statement_generator.py

示例13: index

def index():
    form = BookForm(csrf_enabled=False)
    if form.validate_on_submit():
        # Check the password and log the user in
        # [...]
        artist=Main.main(form.book.data)
        return redirect(url_for('index'))
        return redirect(url_for('qwerty'))
    return render_template('index.html', form=form)
开发者ID:GustavoAngulo,项目名称:HackCMU2015,代码行数:9,代码来源:app.py

示例14: write_value

 def write_value(self,value):
     """
     Write a value to the Arduino over Serial.
         :argument value: Value to be written to Arduino
         :type value: string, int, float
         :argument pause: Amount of time spent paused in seconds
         :type pause: int, float
     """
     Interface.choose_print(self.gui, 'arduino', 'Writing "{}"...'.format(value))
     try:
         self.serial.write('{}'.format(value))
         self.serial.readline()
         Interface.choose_print(self.gui, 'arduino', 'Wrote: {}'.format(value))
     except serial.SerialException:
         Interface.choose_print(self.gui,
                                'arduino',
                                'SerialException: WriteFile failed')
         Main.abort_session()
开发者ID:GhoulPoP,项目名称:ProjectScarberry,代码行数:18,代码来源:ArduinoController.py

示例15: find_product_trends

def find_product_trends(database,product_codes):
    
    print("Getting Product Trends...")
    
    Main.fill_values(database)


    for hs,product in product_codes.items():
        # Find all the Long, Medium, and Short term Trends in products
    
#             print (one_year_val)

        five_year_val = Main.getProduct(product, last_year-5)        
        first_year_val= Main.getProduct(product, first_year)
        last_year_val = Main.getProduct(product, last_year)      
        one_year_val  = Main.getProduct(product, last_year-1)
        three_year_val= Main.getProduct(product, last_year-3)

        # Attempts to lower the calculation requirements by not calculating for products
        # that have no values in the data set given
        
        total = first_year_val + last_year_val + one_year_val + five_year_val + three_year_val
        
        if (total == 0):
            continue
                
        if (one_year_val != 0):

            one_year_trend = (last_year_val - one_year_val )/ one_year_val
           
            one_year_label = "%s-%s" % (product,"one_year_trend")
            
            SQL_Handler.insert("product_trends",one_year_label,one_year_trend,Main.database)
          
        if (three_year_val != 0):

            three_year_trend = (last_year_val - three_year_val )/ three_year_val
                      
            three_year_trend_label = "%s-%s" % (product,"three_year_trend")
    
            SQL_Handler.insert("product_trends",three_year_trend_label,three_year_trend,Main.database)
            
        if (five_year_val != 0):

            five_year_trend = (last_year_val - five_year_val )/ five_year_val
          
            five_year_trend_label = "%s-%s" % (product,"five_year_trend")
            
            SQL_Handler.insert("product_trends",five_year_trend_label,five_year_trend,Main.database)
                     
        if (first_year_val != 0):

            long_trend = (last_year_val - first_year_val )/ first_year_val

            long_trend_label = "%s-%s" % (product,"long_trend")

            SQL_Handler.insert("product_trends",long_trend_label,long_trend,Main.database)
开发者ID:wolfwolf123,项目名称:OEC_Validation,代码行数:57,代码来源:Trend_Handler.py


注:本文中的Main类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。