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

Method peek

numpy_ml/utils/data_structures.py:148–168  ·  view source on GitHub ↗

Return the item with the largest/smallest (depending on ``self.heap_order``) priority *without* removing it from the queue. Notes ----- In contrast to :meth:`pop`, this operation is O(1). Returns ------- item : :class:`PQNode` instan

(self)

Source from the content-addressed store, hash-verified

146 return item
147
148 def peek(self):
149 """
150 Return the item with the largest/smallest (depending on
151 ``self.heap_order``) priority *without* removing it from the queue.
152
153 Notes
154 -----
155 In contrast to :meth:`pop`, this operation is O(1).
156
157 Returns
158 -------
159 item : :class:`PQNode` instance or None
160 Item with the largest/smallest priority, depending on
161 ``self.heap_order``.
162 """
163 item = None
164 if self._count > 0:
165 item = copy(self._pq[0].to_dict())
166 if self.heap_order == "max":
167 item["priority"] = -1 * item["priority"]
168 return item
169
170
171#######################################################################

Callers 1

_knnMethod · 0.80

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected