• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.dprint函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: on_session_closed

 def on_session_closed(self, session_path):
         dprint("__Session Closed__")
         #session_path = os.path.basename(session_path)
         if session_path in self.Sessions:
                 self.Sessions[session_path].DisconnectAll()
                 del self.Sessions[session_path]
                 self.emit("session-destroyed", session_path)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:7,代码来源:OdsManager.py


示例2: distance

def distance(frames_src, frames_target):
    '''
    Args:
        frames_src(FeaturePatch): a single FeaturePatch from the source video
        frames_target(FeaturePatch): a single FeaturePatch from a target video from the database

    Returns:
        int: the distance between the given FeaturePatch in optical flow space
    '''

    if type(frames_target) == list:
        utils.dprint("FOUND A LIST IN DISTANCE")
        return sys.float_info.max

    dist = 0
    for i in range(len(frames_target.features)):

        if namespace.FEATURES_ARE_VECTORS and not namespace.WEIGHTED_AVG_DIR:
            # If we stored features as Optical Flow Vector

            if (type(frames_src.features[i]) != list or type(frames_target.features[i])):
                # Something wonky happened with features.
                utils.dprint("Odd feature")
                continue

            # Compute distance
            mag_src = math.sqrt((frames_src.features[i][0] + frames_src.features[i][1])**2)
            mag_target = math.sqrt((frames_target.features[i][0] + frames_target.features[i][1])**2)
            dist += abs((mag_src - mag_target))
        else:
            # If we stored features as magnitudes of optical flow
            dist += abs((frames_src.features[i] - frames_target.features[i]))
    return dist
开发者ID:david-abel,项目名称:soundpound,代码行数:33,代码来源:classify.py


示例3: land

 def land(self):
     utils.dprint("", 'Landing')
     self.at(at_ref, False)
     # TODO: implement check for landed
     self.move(0.0, 0.0, 0.0, 0.0, False)
     self.sleep_time = 1.0
     self.__set_landed(True)
开发者ID:taghof,项目名称:Navigation-for-Robots-with-WIFI-and-CV,代码行数:7,代码来源:controllers.py


示例4: on_session_connected

 def on_session_connected(self, session_path):
         dprint("session_connected")
         #session_path = os.path.basename(session_path)
         if session_path in self.Sessions:
                 session = self.Sessions[session_path]
                 if not session.Connected:
                         session.emit("connected")
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:7,代码来源:OdsManager.py


示例5: solve

def solve(points, tour, currentDist):
    startTime = int(time.time())
    print("points: " + str(len(tour)) + " start tour" + str(tour))
    step = 0
    offset = lambda x: 1 if x == 1 else 0
    while True:
        # The best opt and distance.
        startStepTime = int(time.time())
        bestDist = currentDist
        bestThreeOpt = None
        tries = 0
        for i in range(1, len(tour) - 3):  
            for j in range(i + 1, len(tour) - 2):
                for k in range(j + 2, len(tour) - offset(i)):
                    #print("i: %d, j: %d, j+1: %d, k:%d" % (i, j, j +1, k))
                    tries += 1 
                    threeOpt = getBestThreeOpt(points, tour, currentDist, i, j, k)
                    if threeOpt.getEndDist() < bestDist:
                        bestDist = threeOpt.getEndDist()
                        bestThreeOpt = threeOpt
        step += 1
        utils.dprint("step: " + str(step) + ", tries: " + str(tries) + ", time: " + fpformat.fix(time.time() - startStepTime, 3))
        if bestDist == currentDist:
            # If no more improvement we are at a local minima and are done.
            print("no more improvement")
            break
        # Perform the opt.
        bestThreeOpt.swap();
        currentDist = bestDist
        if  int(time.time()) - startTime > maxTimeToRun:
            # Out of time, return the best we've got.
            print("out of time")
            break
    print("end tour" + str(tour))
    return 0, bestDist, tour
开发者ID:dillstead,项目名称:tsp,代码行数:35,代码来源:threeopt.py


示例6: test_python_thread_calls_to_clr

    def test_python_thread_calls_to_clr(self):
        """Test calls by Python-spawned threads into managed code."""
        # This test is very likely to hang if something is wrong ;)
        import System

        done = []

        def run_thread():
            for i in range(10):
                time.sleep(0.1)
                dprint("thread %s %d" % (thread.get_ident(), i))
                mstr = System.String("thread %s %d" % (thread.get_ident(), i))
                dprint(mstr.ToString())
                done.append(None)
                dprint("thread %s %d done" % (thread.get_ident(), i))

        def start_threads(count):
            for _ in range(count):
                thread_ = threading.Thread(target=run_thread)
                thread_.start()

        start_threads(5)

        while len(done) < 50:
            dprint(len(done))
            time.sleep(0.1)
开发者ID:brudo,项目名称:pythonnet-1,代码行数:26,代码来源:test_thread.py


示例7: main

def main():
    dprint("Opening DB ...")
    conn = sqlite3.connect(DB_PATH)
    c = conn.cursor()
    dprint("Trying to read table: courses ...")
    for row in c.execute('''SELECT * FROM courses'''):
        print row
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:7,代码来源:read_from_db.py


示例8: destroy_server

        def destroy_server(self, pattern="opp"):
                dprint("Destroy %s server" % pattern)
                def on_stopped(server):
                        dprint("server stopped")
                        try:
                                server.Close()
                        except:
                                #this is a workaround for lp:735068
                                dprint("DBus error on ODS server.Close()")
                                #force close locally
                                server.DisconnectAll()

                        gobject.source_remove(timeout)

                def on_closed(server):
                        dprint("server closed")
                        self.emit("server-destroyed", self.Servers[pattern].object_path)
                        del self.Servers[pattern]

                try:
                        s = self.Servers[pattern]
                        s.GHandle("stopped", on_stopped)
                        s.GHandle("closed", on_closed)
                        try:
                                s.Stop()
                        except:
                                #ods probably died
                                gobject.idle_add(on_closed, s)

                        timeout = gobject.timeout_add(1000, on_stopped, s)

                except KeyError:
                        pass
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:33,代码来源:OdsManager.py


示例9: format_table_line

def format_table_line(items, hdg=False):
    '''take the 13 enties in "items" and return them formatted for out table'''
    dprint("*** format_table_line: items passed in (hdg=%s):" % hdg)
    dprint(items)
    # set up an array of heading vs regular format for each column
    line_fmt = [
        ('{:<10s}', '{:<10s}'),
        ('{:^7s}', '{:^7d}'),
        ('{:>9s}', '{:>9.2f}'),
        ('{:>9s}', '{:>9.2f}'),
        ('{:^6s}', '{:^6d}'),
        ('{:^7s}', '{:^7d}'),
        ('{:^10s}', '{:^10d}'),
        ('{:^5s}', '{:^5d}'),
        ('{:^5s}', '{:^5d}'),
        ('{:^5s}', '{:^5d}'),
        ('{:^8s}', '{:^+8d}'),
        ('{:^8s}', '{:^+8d}'),
        ('{:>6s}', '{:>6s}')]
    fmt_idx = 0 if hdg else 1
    for i in range(13):
        dprint("item[%d] (len %d):" % (i, len(str(items[i]))), items[i])
        dprint("format for item: '%s'" % line_fmt[i][fmt_idx])
    l = []
    for i in range(13):
        fmt_str = line_fmt[i][fmt_idx]
        l.append(fmt_str.format(items[i]))
    res = ''.join(l)
    dprint("Returning table line: /%s/" % res)
    return res
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:30,代码来源:report.py


示例10: step

    def step(self,seconds=0.1):
        """ Step function 1) senses, 2) executes all layered resources (which tell "body"
        which actions to engage, then 3) executes simulator for X seconds (defined by 
        'seconds' variable."""

        self.age += 1
        # tell the terminal how old you are
        print "Step %i" % (self.age)
        
        state_1 = [x for x in self.all_resources if x.is_on]
        self.sense() # sense the world which returns perceptions, 
        #print "ALL resources", self.all_resources
        for r in self.all_resources:
            if r.is_on: print "+", r.name

        self.execute_all_resources()
        #self.execute_reactive_resources()
        #self.execute_deliberative_resources()
        #self.execute_reflective_resources()
        state_2 = [x for x in self.all_resources if x.is_on]
        self.turned_on = set(state_2)-set(state_1)
        self.turned_off = set(state_1)-set(state_2)
        for resource in self.turned_on:
            dprint(x.name,"ON: ")
        for resource in self.turned_off:
            dprint(x.name,"OFF: ")
            
        self.env.do('step_simulation',{'seconds':seconds, 'agent':self.name}) # simulator is paused by default, run for X seconds
        time.sleep(seconds+(self.delay*2)) # make sure agent waits as long as simulator
        return True
开发者ID:Joelone,项目名称:IsisWorld,代码行数:30,代码来源:arch.py


示例11: DateChanged

 def DateChanged(self, e):
     dprint("One of our dates has changed!", e)
     if self.DateRangeValid():
         self.results_button.Enable()
         self.SetNormalStatus("")
     else:
         self.results_button.Disable()
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:7,代码来源:report.py


示例12: DateRangeValid

 def DateRangeValid(self):
     '''Is our date range valid?'''
     rd_start = self.start_rdate.GetValue()
     dprint("Date Range Valid: start=", rd_start)
     rd_stop = self.stop_rdate.GetValue()
     dprint("Date Range Valid: stop=", rd_stop)
     return rd_stop > rd_start
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:7,代码来源:report.py


示例13: add_round

def add_round(rnd, rd_list):
    '''Add the specified round and list of round details to the DB'''
    dprint("Adding to DB:", rnd)
    for rd in rd_list:
        dprint(rd)
    db_cmd_exec('''INSERT INTO rounds(num,
                                      course_num,
                                      rdate)
                   VALUES(%d,%d,"%s")''' % \
                (rnd.num,
                 rnd.course_num,
                 rnd.rdate.strftime("%m/%d/%Y")))
    for rd in rd_list:
        if rnd.num != rd.round_num:
            raise Exception("Internal Error: Round Number mismatch!")
        db_cmd_exec('''INSERT INTO round_details(round_num, player_num,
                                                 fstrokes, bstrokes,
                                                 acnt, ecnt, aecnt,
                                                 calc_fscore_numerator,
                                                 calc_fscore_denominator,
                                                 calc_bscore_numerator,
                                                 calc_bscore_denominator,
                                                 calc_oscore_numerator,
                                                 calc_oscore_denominator)
               VALUES(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)''' % \
                    (rd.round_num, rd.player_num,
                     rd.fstrokes, rd.bstrokes,
                     rd.acnt, rd.ecnt, rd.aecnt,
                     rd.calc_fscore.numerator, rd.calc_fscore.denominator,
                     rd.calc_bscore.numerator, rd.calc_bscore.denominator,
                     rd.calc_oscore.numerator, rd.calc_oscore.denominator))
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:31,代码来源:rdb.py


示例14: get_max_round_no

def get_max_round_no():
    #global RoundList
    # try it an alternative way
    rnd_nos = [rnd.num for rnd in RoundList.itervalues()]
    max_rnd_no = max(rnd_nos)
    dprint("Max Round No: %d" % max_rnd_no)
    return max_rnd_no
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:7,代码来源:rdb.py


示例15: OnCommit

 def OnCommit(self, e):
     dprint("OnCommit: %s Round DB requested" % \
            ('Update' if self.for_update else 'Commit'))
     dprint("DB State: edited=%s, calc_done=%s form_up_to_date=%s, " % \
            (self.is_edited, self.calc_done, self.data_from_form_up_to_date))
     # save the date of our current round, since it can
     # change when we get data from the frame
     this_round_rdate_saved = self.this_round.rdate
     if not self.GetDataFromFrameIfNeeded():
         dprint("XXX need to diplay error status here: data invalid!")
         return
     if not self.is_edited:
         raise Exception("Internal Error: Committing non-edited list?")
     if self.for_update:
         # XXX we should check for this round having the date of a round
         # already in the database (not counting this round)
         # NOT YET IMPLEMENTED
         rdb.modify_round(self.this_round, self.round_details)
     else:
         # check for duplicate round
         for rnd in rdb.RoundList.itervalues():
             dprint("Looking at an existing:", rnd)
             if rnd.rdate == this_round_rdate_saved:
                 self.SetErrorStatus("Duplicate Round Date: Change Date")
                 return False
         rdb.add_round(self.this_round, self.round_details)
         self.SetNormalStatus("")
     rdb.commit_db()
     dprint("Updating parent GUI ...")
     pub.sendMessage("ROUND UPDATE", round_no=self.this_round)
     self.is_edited = False
     self.is_committed = True
     self.SetCommitButtonState()
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:33,代码来源:rounds.py


示例16: PreviewText

    def PreviewText(self, lines, doc_name):
        """
        This function displays the preview window for the text with the given header.
        """
        try:
            self.doc_name = doc_name
            self.doc_lines = lines

            #Destructor fix by Peter Milliken --
            print1 = MyPrintout(self.frame, lines=self.doc_lines)
            print2 = MyPrintout(self.frame, lines=self.doc_lines)
            preview = wx.PrintPreview(print1, print2, self.printer_config)
            if not preview.Ok():
                wx.MessageBox("Unable to display preview of document.")
                return
            preview_window = wx.PreviewFrame(preview, self.frame, \
                                             "Print Preview - %s" % doc_name)
            preview_window.Initialize()
            preview_window.SetPosition(self.frame.GetPosition())
            preview_window.SetSize(self.frame.GetSize())
            preview_window.MakeModal(True)
            preview_window.GetControlBar().SetZoomControl(100)
            preview_window.Show(True)
        except Exception, e:
            dprint("oh oh -- something failed:", e)
            wx.MessageBox(GetErrorText())
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:26,代码来源:printer.py


示例17: HasPage

 def HasPage(self, page_num):
     """
     This function is called to determine if the specified page exists.
     """
     res = len(self.GetPageText(page_num))
     dprint("HasPage(%d): returning '%d > 0'" % (page_num, res))
     return res > 0
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:7,代码来源:printer.py


示例18: MyStart

 def MyStart(self, start_rdate, stop_rdate):
     dprint("ScoreResultsFrame:MyStart(%s, %s): entering" % \
            (start_rdate, stop_rdate))
     self.start_rdate = wxdate.wxdt_to_dt(start_rdate)
     self.stop_rdate = wxdate.wxdt_to_dt(stop_rdate)
     dprint("Report on reults from", start_rdate, "to", stop_rdate)
     self.GenerateResultsList()
     self.InitUI()
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:8,代码来源:report.py


示例19: test_simple_callback_to_python

    def test_simple_callback_to_python(self):
        """Test a call to managed code that then calls back into Python."""
        from Python.Test import ThreadTest

        dprint("thread %s SimpleCallBack" % thread.get_ident())
        result = ThreadTest.CallEchoString("spam")
        self.assertTrue(result == "spam")
        dprint("thread %s SimpleCallBack ret" % thread.get_ident())
开发者ID:brudo,项目名称:pythonnet-1,代码行数:8,代码来源:test_thread.py


示例20: AddMoneyRoundResults

 def AddMoneyRoundResults(self, mrd):
     '''
     The second heart of summarizing results: the money
     '''
     dprint("*** Adding in money results for pnum=%d:" % self.pnum, mrd)
     if self.pnum != mrd.player_num:
         raise Exception("Internal Error: Player Number Mismatch")
     self.money_won += mrd.GetMoney()
     dprint("Added $%s, total now $%s" % (mrd.GetMoney(), self.money_won))
开发者ID:gonzoleeman,项目名称:disc-golf-scoring-app,代码行数:9,代码来源:rdb.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.e函数代码示例发布时间:2022-05-26
下一篇:
Python utils.downloadVideo函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap