jaclearn.visualize.html_table#

Classes

HTMLTableColumnDesc

HTMLTableVisualizer

A helper class to generate HTML tables.

Class HTMLTableColumnDesc

class HTMLTableColumnDesc[source]#

Bases: _HTMLTableColumnDesc

__add__(value, /)#

Return self+value.

__init__()#
__mul__(value, /)#

Return self*value.

static __new__(_cls, identifier, name, type, css=None, td_css=None)#

Create new instance of _HTMLTableColumnDesc(identifier, name, type, css, td_css)

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)#

Return first index of value.

Raises ValueError if the value is not present.

css#

Alias for field number 3

identifier#

Alias for field number 0

name#

Alias for field number 1

td_css#

Alias for field number 4

type#

Alias for field number 2

Class HTMLTableVisualizer

class HTMLTableVisualizer[source]#

Bases: object

A helper class to generate HTML tables.

Example

>>> vis = HTMLTableVisualizer('<some_dir>', 'Visualization')
>>> with vis.html():
>>>     with vis.table('Table Name', [
>>>         HTMLTableColumnDesc('column1', 'Image', 'image', {'width': '120px'}),
>>>         HTMLTableColumnDesc('column2', 'Result', 'figure' {}),
>>>         HTMLTableColumnDesc('column3', 'Supervision', 'text' {}),
>>>         HTMLTableColumnDesc('column4', 'Prediction', 'code' {'font-size': '12px'})
>>>     ]):
>>>         vis.row(...)
__init__(visdir, title)[source]#
__new__(**kwargs)#
begin_html(force_overwrite=False)[source]#
Parameters:

force_overwrite (bool)

begin_table(name, columns_or_spec_id)[source]#
define_table(columns)[source]#
end_html()[source]#
end_table()[source]#
get_asset_filename(row_identifier, col_identifier, ext)[source]#
get_index_filename()[source]#
html(force_overwrite=False)[source]#
Parameters:

force_overwrite (bool)

row(*args, **kwargs)[source]#
save_figure(figure, row_identifier, col_identifier, ext='png')[source]#
save_image(image, row_identifier, col_identifier, ext='png')[source]#
table(name, columns_or_spec_id)[source]#
FRAMES_JS = '\n<script\n    src="https://code.jquery.com/jquery-3.6.0.slim.min.js"\n    integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI="\n    crossorigin="anonymous"\n></script>\n<script>\nfunction frameMove(elem, offset) {\n    elem = $(elem);\n    window.elem = elem;\n    data = JSON.parse(elem.parent().find(".data").html());\n    index = parseInt(elem.parent().find(".index").val());\n\n    nextIndex = index + offset;\n    if (nextIndex < 0) nextIndex = 0;\n    if (nextIndex >= data.length) nextIndex = data.length - 1;\n\n    elem.parent().find(".index").val(nextIndex);\n    if ("image" in data[nextIndex]) {\n        elem.parent().find(".image").attr("src", data[nextIndex]["image"][0]).attr("alt", data[nextIndex]["image"][1]);\n    } else {\n        elem.parent().find(".text").html(data[nextIndex]["text"]);\n    }\n\n    if ("info" in data[nextIndex]) {\n        elem.parent().find(".info").html("Frame #" + nextIndex.toString() + " :: " + data[nextIndex]["info"]);\n    } else {\n        elem.parent().find(".info").html("Frame #" + nextIndex.toString());\n    }\n}\n</script>\n    '#