Commit 77580d4e9e36c7b9eec3098e1cca3e2a5b30db1b
1 parent
3d105012
Prefer lesser numbers for the accelerator value
Showing
1 changed file
with
7 additions
and
3 deletions
... | ... | @@ -240,7 +240,9 @@ def compute_intrs(brokers_data, used_brokers): |
240 | 240 | does not contain ``Default`` entry. |
241 | 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 | 246 | l, r = deepcopy(l), deepcopy(r) |
245 | 247 | if isinstance(l, list) and isinstance(r, list) and len(l) == len(r): |
246 | 248 | lst = [] |
... | ... | @@ -251,13 +253,15 @@ def compute_intrs(brokers_data, used_brokers): |
251 | 253 | if l == r: |
252 | 254 | return l |
253 | 255 | if l > r: |
254 | - return l | |
256 | + return l if prefer_greater_numbers else r | |
255 | 257 | if l < r: |
256 | - return r | |
258 | + return r if prefer_greater_numbers else l | |
257 | 259 | elif isinstance(l, dict) and isinstance(r, dict): |
258 | 260 | for k, v in r.iteritems(): |
259 | 261 | if k not in l.keys(): |
260 | 262 | l[k] = v |
263 | + elif k in keys_to_prefer_lesser: | |
264 | + l[k] = recur(l[k], v, prefer_greater_numbers=False) | |
261 | 265 | else: |
262 | 266 | l[k] = recur(l[k], v) |
263 | 267 | return l | ... | ... |
Please
register
or
login
to post a comment