@@ -146,6 +146,7 @@ def _run_configs(self, xs, check_restrictions=True):
146146 batch_keys = [] # The keys of the configs to run
147147 pending_indices_by_key = dict () # Maps key => where to store result in `final_results`
148148 final_results = [] # List returned to the user
149+ legal_indices = [] # Indices in `final_results` that are legal
149150
150151 # Loop over all configurations. For each configurations there are four cases:
151152 # 1. The configuration is invalid, we can skip it
@@ -166,6 +167,7 @@ def _run_configs(self, xs, check_restrictions=True):
166167 # 2. Attempt to retrieve from `unique_results`
167168 elif key in self .unique_results :
168169 result = dict (self .unique_results [key ])
170+ legal_indices .append (len (final_results ))
169171 final_results .append (result )
170172
171173 # 3. We have already seen this config in the current batch
@@ -190,6 +192,7 @@ def _run_configs(self, xs, check_restrictions=True):
190192
191193 # set in the results array
192194 for index in pending_indices_by_key [key ]:
195+ legal_indices .append (index )
193196 final_results [index ] = dict (result )
194197
195198 # Disable the timings. Only the first result must get these.
@@ -200,10 +203,9 @@ def _run_configs(self, xs, check_restrictions=True):
200203 # Put result in `unique_results`
201204 self .unique_results [key ] = result
202205
203- for result in final_results :
204- # Skip if None. Result is missing if runner exhausted the budget
205- if result is not None :
206- self .results .append (result )
206+ # Only things in `legal_indices` are valid results
207+ for index in sorted (legal_indices ):
208+ self .results .append (result )
207209
208210 # upon returning from this function control will be given back to the strategy, so reset the start time
209211 self .runner .last_strategy_start_time = perf_counter ()
0 commit comments