

def print_results(raw_information, configuration, date, cfg, verbose=True):
    working_methods = METHODS[:]
    all_data = {
        
    }
    LINES = ('std', 'max', 'min', 'avg')
    protocols = set()
    for method in METHODS:
        method_data = {
            
        }
        all_data[method] = method_data
        for line in LINES:

            def func_on_results(results):
                return getattr(results, (line + '_call_times'))[method]
            data = {
                
            }
            data['protocols'] = raw_information.keys()
            for protocol in data['protocols']:
                try:
                    (x, y) = raw_information[protocol]
                    y = map(func_on_results, y)
                except KeyError:
                    continue
                except:
                    import traceback
                    traceback.print_exc()
                    continue
                else:
                    protocols.add(protocol)
                    if (not (protocol in method_data)):
                        method_data[protocol] = {
                            
                        }
                    protocol_data = method_data[protocol]
                    protocol_data[line] = (x, y)
    for method in METHODS:
        if (len(all_data[method]) == 0):
            working_methods.remove(method)
    CODE = ('#!/usr/bin/env python\nimport os\nimport math\nimport matplotlib\nif %(backend)r != \'\':\n    matplotlib.use(%(backend)r)\nimport matplotlib.pyplot as plt\n\n%(get_figure_filename)s\n\ndef print_figures():\n    \n    date            = %(date)r\n    working_methods = %(working_methods)r\n    all_data        = %(all_data)s\n\n    sorter = lambda (x1, y1), (x2, y2): cmp(x1, x2)\n\n    for method in working_methods:\n        method_data = all_data[method]\n\n        max_ys = []\n        for protocol in method_data:\n            protocol_data = method_data[protocol]\n            _,  max_y  = zip(*sorted(zip(*protocol_data[\'max\']), sorter))\n            max_ys.append(max(max_y))\n\n        ylim = (0, math.ceil(max(max_ys) + 0.1))\n\n        for protocol in method_data:\n            for with_bounds in True, False:\n                protocol_data = method_data[protocol]\n                fig = plt.figure()\n                ax = fig.add_subplot(111)\n                ax.set_xlabel("Users")\n                ax.set_ylabel("Time (sec)")\n\n\n                max_x,  max_y  = zip(*sorted(zip(*protocol_data[\'max\']), sorter))\n                mean_x, mean_y = zip(*sorted(zip(*protocol_data[\'avg\']), sorter))\n                std_x,  std_y  = zip(*sorted(zip(*protocol_data[\'std\']), sorter))\n                min_x,  min_y  = zip(*sorted(zip(*protocol_data[\'min\']), sorter))\n\n                ax.plot(max_x, max_y, \'r-\')\n                ax.errorbar(mean_x, mean_y, yerr=std_y, fmt=\'g-\')\n                ax.plot(min_x, min_y, \'b-\')\n\n                fname = get_figure_filename(protocol, method, date)\n                if with_bounds:\n                    ax.set_ybound(*ylim)\n                else:\n                    current_bounds = list(ax.get_ybound())\n                    current_bounds[0] = 0\n                    ax.set_ybound(*current_bounds)\n                    fname = os.path.dirname(fname) + os.sep + "without_bounds_" + os.path.basename(fname)\n\n                plt.savefig(fname)\n\nif __name__ == \'__main__\':\n    print_figures()\n    ' % {
        'backend': cfg.MATPLOTLIB_BACKEND,
        'get_figure_filename': GET_FIGURE_FILENAME_CODE,
        'working_methods': working_methods,
        'all_data': json.dumps(all_data, indent=4),
        'date': date,
    })
    generate_figures_script = ('figures%sgenerate_figures_%s.py' % (os.sep, date))
    open(generate_figures_script, 'w').write(CODE)
    print(('Executing %s...' % generate_figures_script))
    os.system(('%s %s' % (sys.executable, generate_figures_script)))
    print('[done]')
    html = generate_html(protocols, configuration, working_methods, date, cfg.SYSTEM, cfg.RUNNING_CONFIGURATION)
    html_filename = ('botclient_%s.html' % date)
    open(html_filename, 'w').write(html)
    if verbose:
        print('HTML file available in', html_filename)
        print(('Finished plotting; %s' % show_time()))
        flush()

dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/admin/bot/graphics.py print_results/original