def generate_table(self, fun):
        """
        Generate a table displaying the functions called by fun and their
        respective running times. This is done using Bokeh's DataTable widget,
        which is based on SlickGrid.
        """
        if fun is None:
            # Generate summary page
            calls = self.cprofile_tree.keys()
        else:
            calls = [function for function in self.cprofile_tree[fun]['calls']]

        self.n_table_elements = len(calls)

        names = [call if type(call) == str else call.co_name for call in calls]

        # List of tuples containing:
        # (id number, name, totaltime, inlinetime, cprofile_key)
        calls = list(zip(range(len(calls)), names,
                         (self.cprofile_tree[x]['totaltime'] for x in calls),
                         (self.cprofile_tree[x]['inlinetime'] for x in calls),
                         calls))

        self.id_dict = {"function" + str(id): cprofile_key for
                        (id, name, time, inlinetime, cprofile_key) in calls}

        # Sort by total time (descending)
        calls.sort(key=lambda x: x[2])
        calls.reverse()

        # Generate bokeh table
        try:
            ids, names, times, inlinetimes = list(zip(*calls))[:-1]
        except ValueError:
            return

        time_plot_multiplier = 100 / max(times)
        plot_inline_times = [time_plot_multiplier * time for time in
                             inlinetimes]
        plot_extra_times = [time_plot_multiplier * (inlinetime - totaltime)
                            for totaltime, inlinetime in zip(times,
                                                             inlinetimes)]

        table_data = dict(ids=ids, names=names, times=times,
                          inlinetimes=inlinetimes,
                          plot_inline_times=plot_inline_times,
                          plot_extra_times=plot_extra_times)

        table_data = ColumnDataSource(table_data)

        time_format = bokeh_tables.NumberFormatter(format='0,0.00000')

        name_template = '<a id="function<%= ids %>"><%- names %></a>'
        name_format = (bokeh_tables.
                       HTMLTemplateFormatter(template=name_template))

        time_plot_template = ('<img src="/nbextensions/iprofiler/red.gif"' +
                              'height="10" width="<%= plot_inline_times%>">' +
                              '<img src="/nbextensions/iprofiler/pink.gif"' +
                              'height="10" width="<%= plot_extra_times %>">')
        time_plot_format = (bokeh_tables.
                            HTMLTemplateFormatter(template=time_plot_template))

        columns = [bokeh_tables.TableColumn(title="Function",
                                            field="names",
                                            formatter=name_format),
                   bokeh_tables.TableColumn(title="Total time (s)",
                                            field="times",
                                            formatter=time_format,
                                            default_sort="descending"),
                   bokeh_tables.TableColumn(title="Inline time (s)",
                                            field="inlinetimes",
                                            formatter=time_format,
                                            default_sort="descending"),
                   bokeh_tables.TableColumn(title="Time plot",
                                            sortable=False,
                                            formatter=time_plot_format)]

        bokeh_table = bokeh_tables.DataTable(source=table_data,
                                             columns=columns,
                                             # Would be nice if width could
                                             # be automatic but this appears
                                             # to be broken in firefox and
                                             # chrome.
                                             width=620,
                                             height='auto',
                                             selectable=False)

        self.value_cache += notebook_div(bokeh_table)
dataset/ETHPy150Open j-towns/iprofiler/iprofiler.py/IProfile.generate_table/swapped operands of `-`