pygsti.report.html

Routines for converting python objects to HTML.

Parallel rountines as latex.py has for latex conversion.

Module Contents

Functions

table(custom_headings, col_headings_formatted, rows, spec)

Create an HTML table

cell(data, label, spec)

Format the cell of an HTML table

list(l, specs)

Convert a list to html.

vector(v, specs)

Convert a 1D numpy array to html.

matrix(m, specs)

Convert a 2D numpy array to html.

value(el, specs, mathmode=False)

Convert a floating point or complex value to html.

escaped(txt, specs)

Escape txt so it is html safe.

pygsti.report.html.table(custom_headings, col_headings_formatted, rows, spec)

Create an HTML table

Parameters
  • custom_headings (None, dict) – optional dictionary of custom table headings

  • col_headings_formatted (list) – formatted column headings

  • rows (list of lists of cell-strings) – Data in the table, pre-formatted

  • spec (dict) – options for the formatter

Returns

dict (contains keys ‘html’ and ‘js’, which correspond to a html and js strings representing the table)

pygsti.report.html.cell(data, label, spec)

Format the cell of an HTML table

Parameters
  • data (string) – string representation of cell content

  • label (string) – optional cell label, used for tooltips

  • spec (dict) – options for the formatters

Returns

string

pygsti.report.html.list(l, specs)

Convert a list to html.

Parameters
  • l (list) – list to convert into HTML. sub-items pre formatted

  • specs (dictionary) – Dictionary of user-specified and default parameters to formatting

Returns

string – html string for l.

pygsti.report.html.vector(v, specs)

Convert a 1D numpy array to html.

Parameters
  • v (numpy array) – 1D array to convert into HTML.

  • specs (dictionary) – Dictionary of user-specified and default parameters to formatting

Returns

string – html string for v.

pygsti.report.html.matrix(m, specs)

Convert a 2D numpy array to html.

Parameters
  • m (numpy array) – 2D array to convert into HTML.

  • specs (dictionary) – Dictionary of user-specified and default parameters to formatting

Returns

string – html string for m.

pygsti.report.html.value(el, specs, mathmode=False)

Convert a floating point or complex value to html.

Parameters
  • el (float or complex) – Value to convert into HTML.

  • specs (dictionary) – Dictionary of user-specified and default parameters to formatting

  • mathmode (bool, optional) – Whether this routine should generate HTML for use within a math-rendered HTML element (rather than a normal plain-HTML one). So when set to True output is essentially the same as latex format.

Returns

string – html string for el.

pygsti.report.html.escaped(txt, specs)

Escape txt so it is html safe.

Parameters
  • txt (string) – value to escape

  • specs (dictionary) – Dictionary of user-specified and default parameters to formatting

Returns

string