@@ -114,7 +114,7 @@ def strategy(self, strategy):
114
114
115
115
def _ask_and_tell_based_on_loss_improvements (self , n ):
116
116
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 ]
118
118
for _ in range (n ):
119
119
to_select = []
120
120
for index , learner in enumerate (self .learners ):
@@ -125,13 +125,13 @@ def _ask_and_tell_based_on_loss_improvements(self, n):
125
125
points , loss_improvements = self ._ask_cache [index ]
126
126
to_select .append (
127
127
((index , points [0 ]),
128
- (loss_improvements [0 ], - npoints [index ]))
128
+ (loss_improvements [0 ], - total_points [index ]))
129
129
)
130
130
131
131
# Choose the optimal improvement.
132
132
(index , point ), (loss_improvement , _ ) = max (
133
133
to_select , key = itemgetter (1 ))
134
- npoints [index ] += 1
134
+ total_points [index ] += 1
135
135
selected .append (((index , point ), loss_improvement ))
136
136
self .tell_pending ((index , point ))
137
137
@@ -140,12 +140,12 @@ def _ask_and_tell_based_on_loss_improvements(self, n):
140
140
141
141
def _ask_and_tell_based_on_loss (self , n ):
142
142
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 ]
144
144
for _ in range (n ):
145
145
losses = self ._losses (real = False )
146
- priority = zip (losses , (- n for n in npoints ))
146
+ priority = zip (losses , (- n for n in total_points ))
147
147
index = max (enumerate (priority ), key = itemgetter (1 ))[0 ]
148
- npoints [index ] += 1
148
+ total_points [index ] += 1
149
149
150
150
# Take the points from the cache
151
151
if index not in self ._ask_cache :
@@ -159,15 +159,15 @@ def _ask_and_tell_based_on_loss(self, n):
159
159
160
160
def _ask_and_tell_based_on_npoints (self , n ):
161
161
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 ]
163
163
n_left = n
164
164
while n_left > 0 :
165
- index = np .argmin (npoints )
165
+ index = np .argmin (total_points )
166
166
# Take the points from the cache
167
167
if index not in self ._ask_cache :
168
168
self ._ask_cache [index ] = self .learners [index ].ask (n = 1 )
169
169
points , loss_improvements = self ._ask_cache [index ]
170
- npoints [index ] += 1
170
+ total_points [index ] += 1
171
171
n_left -= 1
172
172
selected .append (((index , points [0 ]), loss_improvements [0 ]))
173
173
0 commit comments