Skip to content

Commit 717557e

Browse files
committed
rename npoints to total_points
1 parent b2d13a9 commit 717557e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

adaptive/learner/balancing_learner.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def strategy(self, strategy):
114114

115115
def _ask_and_tell_based_on_loss_improvements(self, n):
116116
selected = [] # tuples ((learner_index, point), loss_improvement)
117-
npoints = [l.npoints + len(l.pending_points) for l in self.learners]
117+
total_points = [l.npoints + len(l.pending_points) for l in self.learners]
118118
for _ in range(n):
119119
to_select = []
120120
for index, learner in enumerate(self.learners):
@@ -125,13 +125,13 @@ def _ask_and_tell_based_on_loss_improvements(self, n):
125125
points, loss_improvements = self._ask_cache[index]
126126
to_select.append(
127127
((index, points[0]),
128-
(loss_improvements[0], -npoints[index]))
128+
(loss_improvements[0], -total_points[index]))
129129
)
130130

131131
# Choose the optimal improvement.
132132
(index, point), (loss_improvement, _) = max(
133133
to_select, key=itemgetter(1))
134-
npoints[index] += 1
134+
total_points[index] += 1
135135
selected.append(((index, point), loss_improvement))
136136
self.tell_pending((index, point))
137137

@@ -140,12 +140,12 @@ def _ask_and_tell_based_on_loss_improvements(self, n):
140140

141141
def _ask_and_tell_based_on_loss(self, n):
142142
selected = [] # tuples ((learner_index, point), loss_improvement)
143-
npoints = [l.npoints + len(l.pending_points) for l in self.learners]
143+
total_points = [l.npoints + len(l.pending_points) for l in self.learners]
144144
for _ in range(n):
145145
losses = self._losses(real=False)
146-
priority = zip(losses, (-n for n in npoints))
146+
priority = zip(losses, (-n for n in total_points))
147147
index = max(enumerate(priority), key=itemgetter(1))[0]
148-
npoints[index] += 1
148+
total_points[index] += 1
149149

150150
# Take the points from the cache
151151
if index not in self._ask_cache:
@@ -159,15 +159,15 @@ def _ask_and_tell_based_on_loss(self, n):
159159

160160
def _ask_and_tell_based_on_npoints(self, n):
161161
selected = [] # tuples ((learner_index, point), loss_improvement)
162-
npoints = [l.npoints + len(l.pending_points) for l in self.learners]
162+
total_points = [l.npoints + len(l.pending_points) for l in self.learners]
163163
n_left = n
164164
while n_left > 0:
165-
index = np.argmin(npoints)
165+
index = np.argmin(total_points)
166166
# Take the points from the cache
167167
if index not in self._ask_cache:
168168
self._ask_cache[index] = self.learners[index].ask(n=1)
169169
points, loss_improvements = self._ask_cache[index]
170-
npoints[index] += 1
170+
total_points[index] += 1
171171
n_left -= 1
172172
selected.append(((index, points[0]), loss_improvements[0]))
173173

0 commit comments

Comments
 (0)