Commit 77580d4e9e36c7b9eec3098e1cca3e2a5b30db1b

Authored by kosaniak
1 parent 3d105012

Prefer lesser numbers for the accelerator value

@@ -240,7 +240,9 @@ def compute_intrs(brokers_data, used_brokers): @@ -240,7 +240,9 @@ def compute_intrs(brokers_data, used_brokers):
240 does not contain ``Default`` entry. 240 does not contain ``Default`` entry.
241 Using `load_data_from` with ``mode='brokers'`` is recommended. 241 Using `load_data_from` with ``mode='brokers'`` is recommended.
242 """ 242 """
243 - def recur(l, r): 243 + keys_to_prefer_lesser = ('accelerator',)
  244 +
  245 + def recur(l, r, prefer_greater_numbers=True):
244 l, r = deepcopy(l), deepcopy(r) 246 l, r = deepcopy(l), deepcopy(r)
245 if isinstance(l, list) and isinstance(r, list) and len(l) == len(r): 247 if isinstance(l, list) and isinstance(r, list) and len(l) == len(r):
246 lst = [] 248 lst = []
@@ -251,13 +253,15 @@ def compute_intrs(brokers_data, used_brokers): @@ -251,13 +253,15 @@ def compute_intrs(brokers_data, used_brokers):
251 if l == r: 253 if l == r:
252 return l 254 return l
253 if l > r: 255 if l > r:
254 - return l 256 + return l if prefer_greater_numbers else r
255 if l < r: 257 if l < r:
256 - return r 258 + return r if prefer_greater_numbers else l
257 elif isinstance(l, dict) and isinstance(r, dict): 259 elif isinstance(l, dict) and isinstance(r, dict):
258 for k, v in r.iteritems(): 260 for k, v in r.iteritems():
259 if k not in l.keys(): 261 if k not in l.keys():
260 l[k] = v 262 l[k] = v
  263 + elif k in keys_to_prefer_lesser:
  264 + l[k] = recur(l[k], v, prefer_greater_numbers=False)
261 else: 265 else:
262 l[k] = recur(l[k], v) 266 l[k] = recur(l[k], v)
263 return l 267 return l
Please register or login to post a comment