def test_write_dashboard2(): # with text, graphics (encoded and linked), tables, and links
filename1 = abspath(join(testdir, 'test_write_dashboard2_linked_graphics.html.html'))
filename2 = abspath(join(testdir, 'test_write_dashboard2_encoded_graphics.html.html'))
graphics_filename = abspath(join(testdir, 'dashboard_graphic.png'))
if isfile(filename1):
os.remove(filename1)
if isfile(filename2):
os.remove(filename2)
if isfile(graphics_filename):
os.remove(graphics_filename)
plt.figure()
plt.plot([1, 2, 3],[1, 2, 3])
plt.savefig(graphics_filename, format='png')
plt.close()
column_names = ['loc1', 'loc2']
row_names = ['sys1', 'sys2']
content = {}
content[('sys1', 'loc1')] = {'text': 'sys1-loc1 text',
'graphics': [graphics_filename],
'link': {'Google': 'https://www.google.com', 'Pecos': 'http://pecos.readthedocs.io'} }
content[('sys1', 'loc2')] = {'text': 'sys1-loc2 text',
'table': pd.DataFrame({'sys1': [1,2,3]}).to_html()}
content[('sys2', 'loc1')] = {'text': 'sys2-loc1 text',
'graphics': [graphics_filename],
'link': {'Google': 'https://www.google.com', 'Pecos': 'http://pecos.readthedocs.io'} }
content[('sys2', 'loc2')] = {'text': 'sys2-loc2 text',
'table': pd.DataFrame({'sys2': [2,4,6]}).to_html()}
pecos.io.write_dashboard(filename1, column_names, row_names, content, encode=False)
assert_true(isfile(filename1))
pecos.io.write_dashboard(filename2, column_names, row_names, content, encode=True)
assert_true(isfile(filename2))
评论列表
文章目录