@@ -105,7 +105,7 @@ def __init__(
105105 # Naively we would make 'function' a method, but this causes problems
106106 # when using executors from 'concurrent.futures' because we have to
107107 # pickle the whole learner.
108- self .function = partial (dispatch , [l .function for l in self .learners ]) # type: ignore
108+ self .function = partial (dispatch , [lrn .function for lrn in self .learners ]) # type: ignore
109109
110110 self ._ask_cache = {}
111111 self ._loss = {}
@@ -130,25 +130,25 @@ def new(self) -> BalancingLearner:
130130 @property
131131 def data (self ) -> dict [tuple [int , Any ], Any ]:
132132 data = {}
133- for i , l in enumerate (self .learners ):
134- data .update ({(i , p ): v for p , v in l .data .items ()})
133+ for i , lrn in enumerate (self .learners ):
134+ data .update ({(i , p ): v for p , v in lrn .data .items ()})
135135 return data
136136
137137 @property
138138 def pending_points (self ) -> set [tuple [int , Any ]]:
139139 pending_points = set ()
140- for i , l in enumerate (self .learners ):
141- pending_points .update ({(i , p ) for p in l .pending_points })
140+ for i , lrn in enumerate (self .learners ):
141+ pending_points .update ({(i , p ) for p in lrn .pending_points })
142142 return pending_points
143143
144144 @property
145145 def npoints (self ) -> int :
146- return sum (l .npoints for l in self .learners )
146+ return sum (lrn .npoints for lrn in self .learners )
147147
148148 @property
149149 def nsamples (self ):
150150 if hasattr (self .learners [0 ], "nsamples" ):
151- return sum (l .nsamples for l in self .learners )
151+ return sum (lrn .nsamples for lrn in self .learners )
152152 else :
153153 raise AttributeError (
154154 f"{ type (self .learners [0 ])} as no attribute called `nsamples`."
@@ -187,7 +187,7 @@ def _ask_and_tell_based_on_loss_improvements(
187187 self , n : int
188188 ) -> tuple [list [tuple [int , Any ]], list [float ]]:
189189 selected = [] # tuples ((learner_index, point), loss_improvement)
190- total_points = [l .npoints + len (l .pending_points ) for l in self .learners ]
190+ total_points = [lrn .npoints + len (lrn .pending_points ) for lrn in self .learners ]
191191 for _ in range (n ):
192192 to_select = []
193193 for index , learner in enumerate (self .learners ):
@@ -212,7 +212,7 @@ def _ask_and_tell_based_on_loss(
212212 self , n : int
213213 ) -> tuple [list [tuple [int , Any ]], list [float ]]:
214214 selected = [] # tuples ((learner_index, point), loss_improvement)
215- total_points = [l .npoints + len (l .pending_points ) for l in self .learners ]
215+ total_points = [lrn .npoints + len (lrn .pending_points ) for lrn in self .learners ]
216216 for _ in range (n ):
217217 losses = self ._losses (real = False )
218218 index , _ = max (
@@ -235,7 +235,7 @@ def _ask_and_tell_based_on_npoints(
235235 self , n : numbers .Integral
236236 ) -> tuple [list [tuple [numbers .Integral , Any ]], list [float ]]:
237237 selected = [] # tuples ((learner_index, point), loss_improvement)
238- total_points = [l .npoints + len (l .pending_points ) for l in self .learners ]
238+ total_points = [lrn .npoints + len (lrn .pending_points ) for lrn in self .learners ]
239239 for _ in range (n ):
240240 index = np .argmin (total_points )
241241 # Take the points from the cache
@@ -356,7 +356,9 @@ def plot(
356356 keys , values_list = cdims
357357 cdims = [dict (zip (keys , values )) for values in values_list ]
358358
359- mapping = {tuple (_cdims .values ()): l for l , _cdims in zip (self .learners , cdims )}
359+ mapping = {
360+ tuple (_cdims .values ()): lrn for lrn , _cdims in zip (self .learners , cdims )
361+ }
360362
361363 d = defaultdict (list )
362364 for _cdims in cdims :
@@ -526,11 +528,11 @@ def save(
526528 >>> learner.save(combo_fname) # use 'load' in the same way
527529 """
528530 if isinstance (fname , Iterable ):
529- for l , _fname in zip (self .learners , fname ):
530- l .save (_fname , compress = compress )
531+ for lrn , _fname in zip (self .learners , fname ):
532+ lrn .save (_fname , compress = compress )
531533 else :
532- for l in self .learners :
533- l .save (fname (l ), compress = compress )
534+ for lrn in self .learners :
535+ lrn .save (fname (lrn ), compress = compress )
534536
535537 def load (
536538 self ,
@@ -554,18 +556,18 @@ def load(
554556 See the example in the `BalancingLearner.save` doc-string.
555557 """
556558 if isinstance (fname , Iterable ):
557- for l , _fname in zip (self .learners , fname ):
558- l .load (_fname , compress = compress )
559+ for lrn , _fname in zip (self .learners , fname ):
560+ lrn .load (_fname , compress = compress )
559561 else :
560- for l in self .learners :
561- l .load (fname (l ), compress = compress )
562+ for lrn in self .learners :
563+ lrn .load (fname (lrn ), compress = compress )
562564
563565 def _get_data (self ) -> list [Any ]:
564- return [l ._get_data () for l in self .learners ]
566+ return [lrn ._get_data () for lrn in self .learners ]
565567
566568 def _set_data (self , data : list [Any ]):
567- for l , _data in zip (self .learners , data ):
568- l ._set_data (_data )
569+ for lrn , _data in zip (self .learners , data ):
570+ lrn ._set_data (_data )
569571
570572 def __getstate__ (self ) -> tuple [list [BaseLearner ], CDIMS_TYPE , STRATEGY_TYPE ]:
571573 return (
0 commit comments