We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8aacefb commit 39d942aCopy full SHA for 39d942a
adaptive/runner.py
@@ -55,7 +55,7 @@
55
56
57
def _key_by_value(dct, value):
58
- return next((k for k, v in dct.items() if v == value), None)
+ return next(k for k, v in dct.items() if v == value)
59
60
61
class BaseRunner(metaclass=abc.ABCMeta):
@@ -248,9 +248,9 @@ def _get_futures(self):
248
fut = self._submit(x)
249
fut.start_time = start_time
250
self.pending_points[fut] = x
251
- i = _key_by_value(self._index_to_point, x) # O(N)
252
- if i is None:
253
- # `x` is not a value in `self._index_to_point`
+ try:
+ i = _key_by_value(self._index_to_point, x) # O(N)
+ except StopIteration: # `x` is not a value in `self._index_to_point`
254
self._i += 1
255
i = self._i
256
self._index_to_point[i] = x
0 commit comments