Skip to content

Commit d60a88e

Browse files
committed
rename _points to _ask_cache
1 parent d9ceaf7 commit d60a88e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

adaptive/learner/balancing_learner.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, learners, *, cdims=None, strategy='loss_improvements'):
7777
# pickle the whole learner.
7878
self.function = partial(dispatch, [l.function for l in self.learners])
7979

80-
self._points = {}
80+
self._ask_cache = {}
8181
self._loss = {}
8282
self._pending_loss = {}
8383
self._cdims_default = cdims
@@ -122,10 +122,10 @@ def _ask_and_tell_based_on_loss_improvements(self, n):
122122
points_per_learner = []
123123
for index, learner in enumerate(self.learners):
124124
# Take the points from the cache
125-
if index not in self._points:
126-
self._points[index] = learner.ask(
125+
if index not in self._ask_cache:
126+
self._ask_cache[index] = learner.ask(
127127
n=1, tell_pending=False)
128-
points, loss_improvements = self._points[index]
128+
points, loss_improvements = self._ask_cache[index]
129129

130130
priority = (loss_improvements[0], -npoints[index])
131131
improvements_per_learner.append(priority)
@@ -154,9 +154,9 @@ def _ask_and_tell_based_on_loss(self, n):
154154
npoints[index] += 1
155155

156156
# Take the points from the cache
157-
if index not in self._points:
158-
self._points[index] = self.learners[index].ask(n=1)
159-
points, loss_improvements = self._points[index]
157+
if index not in self._ask_cache:
158+
self._ask_cache[index] = self.learners[index].ask(n=1)
159+
points, loss_improvements = self._ask_cache[index]
160160

161161
chosen_points.append((index, points[0]))
162162
chosen_loss_improvements.append(loss_improvements[0])
@@ -171,9 +171,9 @@ def _ask_and_tell_based_on_npoints(self, n):
171171
while n_left > 0:
172172
index = np.argmin(npoints)
173173
# Take the points from the cache
174-
if index not in self._points:
175-
self._points[index] = self.learners[index].ask(n=1)
176-
points, loss_improvements = self._points[index]
174+
if index not in self._ask_cache:
175+
self._ask_cache[index] = self.learners[index].ask(n=1)
176+
points, loss_improvements = self._ask_cache[index]
177177
npoints[index] += 1
178178
n_left -= 1
179179
chosen_points.append((index, points[0]))
@@ -190,14 +190,14 @@ def ask(self, n, tell_pending=True):
190190

191191
def tell(self, x, y):
192192
index, x = x
193-
self._points.pop(index, None)
193+
self._ask_cache.pop(index, None)
194194
self._loss.pop(index, None)
195195
self._pending_loss.pop(index, None)
196196
self.learners[index].tell(x, y)
197197

198198
def tell_pending(self, x):
199199
index, x = x
200-
self._points.pop(index, None)
200+
self._ask_cache.pop(index, None)
201201
self._loss.pop(index, None)
202202
self.learners[index].tell_pending(x)
203203

0 commit comments

Comments
 (0)