qiskit/tools/jupyter/backend_monitor.py
def gates_tab(backend):
    """The multiple qubit gate error widget.

    Args:
        backend (IBMQbackend): The backend.

    Returns:
        VBox: A VBox widget.
    """
    config = backend.configuration().to_dict()
    props = backend.properties().to_dict()

    multi_qubit_gates = props['gates'][3*config['n_qubits']:]

    header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>"
    header_html = header_html.format(key='last_update_date',
                                     value=props['last_update_date'])

    update_date_widget = widgets.HTML(value=header_html,
                                      layout=widgets.Layout(grid_area='top'))

    gate_html = "<table>"
    gate_html += """<style>
table {
    border-collapse: collapse;
    width: auto;
}

th, td {
    text-align: left;
    padding: 8px;
}

tr:nth-child(even) {background-color: #f6f6f6;};
</style>"""

    gate_html += "<tr><th></th><th>Type</th><th>Gate error</th></tr>"
    gate_footer = "</table>"

    # Split gates into two columns
    left_num = math.ceil(len(multi_qubit_gates)/3)
    mid_num = math.ceil((len(multi_qubit_gates)-left_num)/2)

    left_table = gate_html

    for qub in range(left_num):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        left_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        left_table += "</td><td>%s</td><td>%s</td></tr>"
        left_table = left_table % (name, ttype, error)
    left_table += gate_footer

    middle_table = gate_html

    for qub in range(left_num, left_num+mid_num):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        middle_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        middle_table += "</td><td>%s</td><td>%s</td></tr>"
        middle_table = middle_table % (name, ttype, error)
    middle_table += gate_footer

    right_table = gate_html

    for qub in range(left_num+mid_num, len(multi_qubit_gates)):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        right_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        right_table += "</td><td>%s</td><td>%s</td></tr>"
        right_table = right_table % (name, ttype, error)
    right_table += gate_footer

    left_table_widget = widgets.HTML(value=left_table,
                                     layout=widgets.Layout(grid_area='left'))
    middle_table_widget = widgets.HTML(value=middle_table,
                                       layout=widgets.Layout(grid_area='middle'))
    right_table_widget = widgets.HTML(value=right_table,
                                      layout=widgets.Layout(grid_area='right'))

    grid = widgets.GridBox(children=[update_date_widget,
                                     left_table_widget,
                                     middle_table_widget,
                                     right_table_widget],
                           layout=widgets.Layout(
                               grid_template_rows='auto auto',
                               grid_template_columns='33% 33% 33%',
                               grid_template_areas='''
                                                   "top top top"
                                                   "left middle right"
                                                   ''',
                               grid_gap='0px 0px'))

    return grid
def gates_tab(backend):
    """The multiple qubit gate error widget.

    Args:
        backend (IBMQbackend): The backend.

    Returns:
        VBox: A VBox widget.
    """
    config = backend.configuration().to_dict()
    props = backend.properties().to_dict()

    multi_qubit_gates = props['gates'][3*config['n_qubits']:]

    header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>"
    header_html = header_html.format(key='last_update_date',
                                     value=props['last_update_date'])

    update_date_widget = widgets.HTML(value=header_html,
                                      layout=widgets.Layout(grid_area='top'))

    gate_html = "<table>"
    gate_html += """<style>
table {
    border-collapse: collapse;
    width: auto;
}

th, td {
    text-align: left;
    padding: 8px;
}

tr:nth-child(even) {background-color: #f6f6f6;};
</style>"""

    gate_html += "<tr><th></th><th>Type</th><th>Gate error</th></tr>"
    gate_footer = "</table>"

    # Split gates into two columns
    left_num = math.ceil(len(multi_qubit_gates)/3)
    mid_num = math.ceil((len(multi_qubit_gates)-left_num)/2)

    left_table = gate_html

    for qub in range(left_num):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        left_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        left_table += "</td><td>%s</td><td>%s</td></tr>"
        left_table = left_table % (name, ttype, error)
    left_table += gate_footer

    middle_table = gate_html

    for qub in range(left_num, left_num+mid_num):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        middle_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        middle_table += "</td><td>%s</td><td>%s</td></tr>"
        middle_table = middle_table % (name, ttype, error)
    middle_table += gate_footer

    right_table = gate_html

    for qub in range(left_num+mid_num, len(multi_qubit_gates)):
        gate = multi_qubit_gates[qub]
        name = gate['name']
        ttype = gate['gate']
        error = round(gate['parameters'][0]['value'], 5)

        right_table += "<tr><td><font style='font-weight:bold'>%s</font>"
        right_table += "</td><td>%s</td><td>%s</td></tr>"
        right_table = right_table % (name, ttype, error)
    right_table += gate_footer

    left_table_widget = widgets.HTML(value=left_table,
                                     layout=widgets.Layout(grid_area='left'))
    middle_table_widget = widgets.HTML(value=middle_table,
                                       layout=widgets.Layout(grid_area='middle'))
    right_table_widget = widgets.HTML(value=right_table,
                                      layout=widgets.Layout(grid_area='right'))

    grid = widgets.GridBox(children=[update_date_widget,
                                     left_table_widget,
                                     middle_table_widget,
                                     right_table_widget],
                           layout=widgets.Layout(
                               grid_template_rows='auto auto',
                               grid_template_columns='33% 33% 33%',
                               grid_template_areas='''
                                                   "top top top"
                                                   "left middle right"
                                                   ''',
                               grid_gap='0px 0px'))

    return grid
def gates_tab ( backend ) : config = backend . configuration ( ) . to_dict ( ) props = backend . properties ( ) . to_dict ( ) multi_qubit_gates = props [ 'gates' ] [ 3 * config [ 'n_qubits' ] : ] header_html = "<div><font style='font-weight:bold'>{key}</font>: {value}</div>" header_html = header_html . format ( key = 'last_update_date' , value = props [ 'last_update_date' ] ) update_date_widget = widgets . HTML ( value = header_html , layout = widgets . Layout ( grid_area = 'top' ) ) gate_html = "<table>" gate_html += """<style>
table {
    border-collapse: collapse;
    width: auto;
}

th, td {
    text-align: left;
    padding: 8px;
}

tr:nth-child(even) {background-color: #f6f6f6;};
</style>""" gate_html += "<tr><th></th><th>Type</th><th>Gate error</th></tr>" gate_footer = "</table>" # Split gates into two columns left_num = math . ceil ( len ( multi_qubit_gates ) / 3 ) mid_num = math . ceil ( ( len ( multi_qubit_gates ) - left_num ) / 2 ) left_table = gate_html for qub in range ( left_num ) : gate = multi_qubit_gates [ qub ] name = gate [ 'name' ] ttype = gate [ 'gate' ] error = round ( gate [ 'parameters' ] [ 0 ] [ 'value' ] , 5 ) left_table += "<tr><td><font style='font-weight:bold'>%s</font>" left_table += "</td><td>%s</td><td>%s</td></tr>" left_table = left_table % ( name , ttype , error ) left_table += gate_footer middle_table = gate_html for qub in range ( left_num , left_num + mid_num ) : gate = multi_qubit_gates [ qub ] name = gate [ 'name' ] ttype = gate [ 'gate' ] error = round ( gate [ 'parameters' ] [ 0 ] [ 'value' ] , 5 ) middle_table += "<tr><td><font style='font-weight:bold'>%s</font>" middle_table += "</td><td>%s</td><td>%s</td></tr>" middle_table = middle_table % ( name , ttype , error ) middle_table += gate_footer right_table = gate_html for qub in range ( left_num + mid_num , len ( multi_qubit_gates ) ) : gate = multi_qubit_gates [ qub ] name = gate [ 'name' ] ttype = gate [ 'gate' ] error = round ( gate [ 'parameters' ] [ 0 ] [ 'value' ] , 5 ) right_table += "<tr><td><font style='font-weight:bold'>%s</font>" right_table += "</td><td>%s</td><td>%s</td></tr>" right_table = right_table % ( name , ttype , error ) right_table += gate_footer left_table_widget = widgets . HTML ( value = left_table , layout = widgets . Layout ( grid_area = 'left' ) ) middle_table_widget = widgets . HTML ( value = middle_table , layout = widgets . Layout ( grid_area = 'middle' ) ) right_table_widget = widgets . HTML ( value = right_table , layout = widgets . Layout ( grid_area = 'right' ) ) grid = widgets . GridBox ( children = [ update_date_widget , left_table_widget , middle_table_widget , right_table_widget ] , layout = widgets . Layout ( grid_template_rows = 'auto auto' , grid_template_columns = '33% 33% 33%' , grid_template_areas = '''
                                                   "top top top"
                                                   "left middle right"
                                                   ''' , grid_gap = '0px 0px' ) ) return grid
The multiple qubit gate error widget.

    Args:
        backend (IBMQbackend): The backend.

    Returns:
        VBox: A VBox widget.
The multiple qubit gate error widget .