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


Python SortedList.discard方法代码示例

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


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

示例1: _WaitingTasksQueue

# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import discard [as 别名]
class _WaitingTasksQueue(object):
    """A FIFO queue of tasks that keeps track of RAM limits.

    This class serves two purposes:
    1) It is a FIFO queue for tasks that also supports fast deletion.
    2) It keeps RAM requirements of all tasks in the queue in sorted order.

    This is necessary for the implementation of worker blocking,
    see ``PrioritingScheduler._getNumberOfBlockedAnyCpuWorkers()``
    for more details.
    """

    def __init__(self):
        self._dict = OrderedDict()
        self._tasks_required_ram = SortedList()

    def __contains__(self, task):
        return task in self._dict

    def __len__(self):
        return len(self._dict)

    def __nonzero__(self):
        return bool(self._dict)

    __bool__ = __nonzero__  # for Python 2/3 compatibility

    def add(self, task):
        self._dict[task] = True
        self._tasks_required_ram.add(task.required_ram_mb)

    def remove(self, task):
        del self._dict[task]
        self._tasks_required_ram.discard(task.required_ram_mb)

    def left(self):
        if self._dict:
            return six.next(six.iteritems(self._dict))[0]
        else:
            return None

    def popleft(self):
        task = self._dict.popitem(False)[0]
        self._tasks_required_ram.discard(task.required_ram_mb)
        return task

    def getTasksRequiredRam(self):
        return self._tasks_required_ram
开发者ID:sio2project,项目名称:sioworkers,代码行数:50,代码来源:prioritizing.py

示例2: test_remove

# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import discard [as 别名]
def test_remove():
    slt = SortedList()

    assert slt.discard(0) == None
    assert len(slt) == 0
    slt._check()

    slt = SortedList([1, 2, 2, 2, 3, 3, 5], load=4)

    slt.remove(2)
    slt._check()

    assert all(tup[0] == tup[1] for tup in zip(slt, [1, 2, 2, 3, 3, 5]))
开发者ID:sbagri,项目名称:sorted_containers,代码行数:15,代码来源:test_coverage_sortedlist.py

示例3: test_discard

# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import discard [as 别名]
def test_discard():
    slt = SortedList()

    assert slt.discard(0) == None
    assert len(slt) == 0
    slt._check()

    slt = SortedList([1, 2, 2, 2, 3, 3, 5])
    slt._reset(4)

    slt.discard(6)
    slt._check()
    slt.discard(4)
    slt._check()
    slt.discard(2)
    slt._check()

    assert all(tup[0] == tup[1] for tup in zip(slt, [1, 2, 2, 3, 3, 5]))
开发者ID:grantjenks,项目名称:sorted_containers,代码行数:20,代码来源:test_coverage_sortedlist.py

示例4: and

# 需要导入模块: from sortedcontainers import SortedList [as 别名]
# 或者: from sortedcontainers.SortedList import discard [as 别名]
         clist.append(ivalue)
         cend=ipos
         #cPass = cPass and (windowHigh-windowLow >= variCutoff)
       else:
         evaluateValues(chrom,cstart,cend,clist,cPass)
         clist = [ivalue]
         cstart = ipos
         cend = ipos
         cPass = not options.debug #and (windowHigh-windowLow >= variCutoff)
     # Increase position in window towards center
     posInWindow += 1
   # Overstepped by 1, reset to center
   posInWindow -= 1
   
 # We are centered
 windowValuesSorted.discard(windowValues.pop(0))
 windowValues.append(value)
 windowValuesSorted.add(value)
 #windowLow,windowMedian,windowHigh = quantileS(windowValuesSorted,[0.25,0.5,0.75])
 windowMedian = medianS(windowValuesSorted)
 # Evaluate adjusted value
 if options.smoother:
   helper = windowValues[max(0,posInWindow-SGF_half_window):posInWindow+SGF_half_window+1]
   ivalue = smoother(helper)-windowMedian
 else:
   ivalue = windowValues[posInWindow]-windowMedian
 ipos = pos-windowSize+posInWindow+1
 if options.debug:
   sys.stdout.write("%s\t%d\t%.1f\t%.1f\t(%d)\n"%(chrom,ipos,ivalue,windowValues[posInWindow],posInWindow))
 #print chrom,ipos,ivalue
 if ivalue > 0:
开发者ID:ernesto-up,项目名称:cfDNA,代码行数:33,代码来源:callPeaks.py


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