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


Python Timer.time_left方法代码示例

本文整理汇总了Python中timer.Timer.time_left方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.time_left方法的具体用法?Python Timer.time_left怎么用?Python Timer.time_left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timer.Timer的用法示例。


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

示例1: solve

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import time_left [as 别名]
 def solve(self, presents_to_place):
     if self.make_timer:
         timer = Timer()
         num_total_presents = len(presents_to_place)
     gc_collect_count = 0
     presents_index = 0
     presents_last_index = len(presents_to_place)
     while 1:
         priority_pick = self.priority_pick
         new_layer = MaxRectSolver(self.width, self.height)
         try:
             presents_index = new_layer.solve(presents_to_place, presents_index, self.scorer, priority_pick)
             self._add_layer(new_layer)
             print("{} more presents".format(presents_last_index - presents_index))
             if presents_index == presents_last_index - 1:
                 break
         except NoFit:
             priority_pick -= 10
             assert priority_pick > 1
         if self.make_timer:
             ratio = presents_index / num_total_presents
             print("Time left: {}; End time: {}".format(timer.time_left(ratio), timer.time_end(ratio)))
     print("Solved with total depth {}".format(self.total_depth))
     if self.make_timer:
         print("Time taken: {}".format(timer.time_taken()))
     if self.gc_collect_cycle:
         gc_collect_count += 1
         if gc_collect_count == self.gc_collect_cycle:
             gc_collect_count = 0
             print("GC collect")
             gc.collect()
开发者ID:Gerenuk,项目名称:Kaggle-Santa,代码行数:33,代码来源:maxrect_layers.py


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