def categorize(items, prop_func): """ :rtype : dict """ getter = prop_func if callable(prop_func) else lambda x: rget(x, prop_func, None) result = { } for item in items: key = getter(item) if key in result: result[key].append(item) else: result[key] = [item] return result
def categorize(items, prop_func): """ :rtype : dict """ getter = prop_func if callable( prop_func) else lambda x: rget(x, prop_func, None) result = {} for item in items: key = getter(item) if key in result: result[key].append(item) else: result[key] = [item] return result
def export(results, props): result = 'name\t' + '\t'.join(pluck(results, 'name')) + '\n' for p in props: result += p + '\t' + '\t'.join(['%1.3f' % x for x in pluck(results, p)]) + '\n' return result def remove_common_prefixes(items, paths): paths = list(paths) if type(paths) is not list else paths return [x for x in items if x['name'] not in paths] # fetch data and categorize them by version and then by time-frame path measurements = multi_cat(load_data(), [ lambda x: rget(x, '_id.version', None), # lambda x: _get_short_name(rget(x, '_id.path', None)), lambda x: rget(x, '_id.path', None), ]) props = ['d1', 'd2', 'cl'] version_combination = list(get_version_combination(measurements.keys(), history=2)) slow_down_factors = slow_down_factor(measurements, version_combination, props, top=10, limit=10) clipboard_result = '' for va, vb, vab in version_combination: calc_output = export(slow_down_factors[vab], props) print vab print calc_output clipboard_result += calc_output