Lines Matching refs:units
201 def find_best_unit(units, min_value, max_value): argument
203 if max_value <= units[0]:
204 return units[0]
205 for i in range(len(units) - 1):
206 if min_value > units[i] and max_value < units[i + 1]:
207 return units[i]
208 if min_value > units[-1]:
209 return units[-1]
211 for i in range(len(units) - 1):
212 if min_value > units[i] * 0.2 and max_value < units[i + 1]:
213 return units[i]
214 if min_value > units[-1] * 0.2:
215 return units[-1]
217 for i in reversed(range(len(units))):
218 if min_value > units[i]:
219 return units[i]
220 assert min_value <= min(units)
222 return units[0]
229 units = [micro, milli, sec]
232 unit = find_best_unit(units, min_in_table, max_in_table)
242 units = [byte, kb, mb]
245 unit = find_best_unit(units, min_in_table, max_in_table)