-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic routine visualization and update README #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, merge when ready!
README.md
Outdated
|
||
## HQAR format | ||
|
||
Consider the following hierarchical dag a hypothetical quantum program: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it would be good to explain what we mean by "hierarchical" and what "dag" is.
Perhaps we could start this section with sth like:
Important terms we use when talking about HQAR objects are:
- hierarchical graphs – this means that each node of the graph can contain a graph inside it
- DAG – directed acyclic graphs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to explain those concepts in d16ffba, WDYT?
src/hqar/experimental/rendering.py
Outdated
Experimental visualization capabilities for HQAR. | ||
|
||
Currently, the visualizations are done with graphviz, which does not suport | ||
hierarchical structures. Therefore, we have to use a somewhat tricky representation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess "hacky" might be a better word here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1a27cb9 reworded.
src/hqar/experimental/rendering.py
Outdated
# Dictionary of default graph attributes, used for non-leaf nodes | ||
GRAPH_ATTRS = { | ||
"rankdir": "LR", # Draw left to right (default is top to bottom) | ||
"fontname": "Helvetica", # Some font properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this comment is not necessary ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, but to explain myself I had more font properties initially and it served as a header 😂 Fixed in 304db14
* Implement rendering to graphviz DAG * Minor style fixes * Add script for rendering serialized diagram * Rename: hqar.experimental.visualization -> hqar.experimental.rendering * Add flake8-copyright to pre-commit hooks * Move loading of valid test programs to fixture * Fix typo * Add tests for rendering * Add graphviz to dependencies * Add GH action step with graphviz setup * Make mypy ignore graphviz errors * Add good-enough initial README * Expand README * Explain hierarchy and DAG in README * Remove unnecessary comment * List visualization tool as one of features * Reword tricky -> hacky --------- Co-authored-by: Konrad Jałowiecki <kjalowiecki@psiquantum.com>
This adds very basic routine visualization in a form of Graphviz digraphs. Visualizations can be obtained by:
to_graphviz(routine)
function.hqar-render <input-path> <output-path>
CLI tool.The visualization capabilities are placed in
hqar.experimental.rendering
submodule. I decided to use intermediateexperimental
namespace to make the instability of this feature painfully obvious.In addition this PR contains several boy-scout improvements: