MCPcopy Index your code
hub / github.com/ddbourgin/numpy-ml / pop

Method pop

numpy_ml/utils/data_structures.py:127–146  ·  view source on GitHub ↗

Remove the item with the largest/smallest (depending on ``self.heap_order``) priority from the queue and return it. Notes ----- In contrast to :meth:`peek`, this operation is `O(log N)`. Returns ------- item : :class:`PQNode` instanc

(self)

Source from the content-addressed store, hash-verified

125 self.pop()
126
127 def pop(self):
128 """
129 Remove the item with the largest/smallest (depending on
130 ``self.heap_order``) priority from the queue and return it.
131
132 Notes
133 -----
134 In contrast to :meth:`peek`, this operation is `O(log N)`.
135
136 Returns
137 -------
138 item : :class:`PQNode` instance or None
139 Item with the largest/smallest priority, depending on
140 ``self.heap_order``.
141 """
142 item = heapq.heappop(self._pq).to_dict()
143 if self.heap_order == "max":
144 item["priority"] = -1 * item["priority"]
145 self._count -= 1
146 return item
147
148 def peek(self):
149 """

Callers 4

pushMethod · 0.95
__init__Method · 0.80
path_existsMethod · 0.80
all_pathsMethod · 0.80

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected