當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。