Example of creating an SVG diagram

The ProgramAnaiysis Module creates a SVG diagram with links to demonstrate a function. The left hand side has boxes that rerpresent the input and have links to the input in text form. The central box represents the action or function being done and has a link to the code of the function. The right most boxes represent the output and has a link to the text version of the output. The output can have a

In [1]:
from pyMez.Code.DataHandlers.Translations import S2PV1_to_XmlDataTable
from pyMez.Code.Analysis.ProgramAnalysis import *
Importing pyMez, this should take roughly 30 seconds
Importing Code.DataHandlers.GeneralModels
It took 0.477027 s to import Code.DataHandlers.GeneralModels
Importing Code.DataHandlers.HTMLModels
It took 0.16101 s to import Code.DataHandlers.HTMLModels
Importing Code.DataHandlers.NISTModels
The module smithplot was not found,please put it on the python path
It took 1.044059 s to import Code.DataHandlers.NISTModels
Importing Code.DataHandlers.TouchstoneModels
It took 0.001 s to import Code.DataHandlers.TouchstoneModels
Importing Code.DataHandlers.XMLModels
It took 0.141009 s to import Code.DataHandlers.XMLModels
Importing Code.DataHandlers.ZipModels
It took 0.011 s to import Code.DataHandlers.ZipModels
Importing Code.InstrumentControl.Experiments
It took 3.590206 s to import Code.InstrumentControl.Experiments
Importing Code.InstrumentControl.Instruments
It took 0.001 s to import Code.InstrumentControl.Instruments
Importing Code.Utils.Names
It took 0.0 s to import Code.Utils.Names
It took 5.427311 s to import all of the active modules
C:\Users\sandersa\AppData\Local\Continuum\anaconda3\lib\site-packages\odo\backends\pandas.py:102: FutureWarning: pandas.tslib is deprecated and will be removed in a future version.
You can access NaTType as type(pandas.NaT)
  @convert.register((pd.Timestamp, pd.Timedelta), (pd.tslib.NaTType, type(None)))
In [2]:
# to display this diagram it is good to have a html form first
new_svg=create_svg_black_box_diagram(inputs={"s2p":S2PV1(os.path.join(TESTS_DIRECTORY,"thru.s2p"))},
                                             outputs=["S2P_as_xml"],function=S2PV1_to_XmlDataTable,
                                     output_transformation_function=lambda x: x.to_HTML(os.path.join(TESTS_DIRECTORY,
                                                                                                     '../XSL/S2P_DB_STYLE.xsl')),
                                     output_mime_type="text/html",box_text_ratio=15)

new_html=HTMLBase()
new_html.add_head()
new_html.add_body()
new_html.append_to_body({"tag":"br"})
new_html.append_to_body(new_svg)
new_html.append_to_head({"tag":"style","text":"rect:hover {stroke-width:8;stroke:blue;}"})
In [3]:
# from IPython.display import SVG,HTML
# HTML(str(new_html))
In [4]:
# this shows the html file in your browser
new_html.show()
file://C:/Users/sandersa/AppData/Local/Temp/1/tmpgkqrmd2j.html
In [5]:
# this works for any function
black_box=create_svg_black_box_diagram(inputs={"list_of_strings":["This is one string","This is number two"]},
                                       function=string_list_collapse,outputs=["Collapsed String"])
new_html.append_to_body(black_box)
new_html.show()
file://C:/Users/sandersa/AppData/Local/Temp/1/tmpij459d3_.html