-
Notifications
You must be signed in to change notification settings - Fork 5
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 tutorial on constructing graph with nodes and interactive widgets #45
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.
Unrelated to these changes: I get
WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).
This is about a setting in conf.py
.
docs/tutorials/nodes-tutorial.ipynb
Outdated
"At the most basic level, a graph will contain a node (white rectangle) that provides the input data,\n", | ||
"and a view (grey ellipse) which will be figure to display the data visually.\n", | ||
"\n", | ||
"![graph](_static/node_graph.png)" |
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.
node_graph.png
does not show up in the docs. I get a warning from Sphinx:
/home/jl/Work/plopp/docs/tutorials/nodes-tutorial.ipynb:: WARNING: image file not readable: tutorials/_static/node_graph.png
The path here needs to be relative to the notebook.
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 re-organised the notebook so that I don't need the png anymore
docs/tutorials/nodes-tutorial.ipynb
Outdated
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"pp.show_graph(a)" |
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.
Looking at the graphs, it would be nice if users could name nodes (e.g. by overriding the id). As it stands, it is pretty difficult to understand what a graph does.
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.
See update. For now, I just went with setting the .name
on the node after it is created.
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig" |
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.
The figures look a bit blurry. Is it possible / feasible to use PDFs instead of PNGs?
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.
Unfortunately not :-(
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 can try to fiddle with the dpi
"source": [ | ||
"When something changes in one of the nodes, all the nodes below it in the graph are notified about the change (the children nodes receive a notification, and they, in turn, notify their own children).\n", | ||
"It is then up to each view to decide whether they are interested in the notification or not (usually, most views are interested in all notifications from parents).\n", | ||
"If they are, they request data from their parent nodes, which in turn request data from their parents, and so on, until the request has reached the top of the graph.\n", |
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.
This was explained earlier. Do we need it twice?
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 made the first explanation shorter so that it feels like the details aren't given twice.
docs/tutorials/nodes-tutorial.ipynb
Outdated
"It is then up to each view to decide whether they are interested in the notification or not (usually, most views are interested in all notifications from parents).\n", | ||
"If they are, they request data from their parent nodes, which in turn request data from their parents, and so on, until the request has reached the top of the graph.\n", | ||
"\n", | ||
"As a result, when the slider is dragged, the smoothing node `c` gets notified and tells the figure that a change has occured.\n", |
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.
Maybe add a note that it doesn't work in the rendered docs and that this is not a bug.
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.
done
docs/tutorials/nodes-tutorial.ipynb
Outdated
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"a = pp.input_node(da)\n", |
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'm not too happy with using single letter names here because it promotes bad practice. It is easy to follow the logic here because the examples are small and self-contained. But I think we should not show anti-patterns in tutorials.
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.
good suggestion. Done
docs/tutorials/nodes-tutorial.ipynb
Outdated
"fig2d = pp.figure2d(c)\n", | ||
"\n", | ||
"# Sum the raw data along the vertical dimension\n", | ||
"d = pp.node(sc.sum, dim='yy')(a)\n", |
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.
Why did the earlier example use partial
to assign sigma
but here, it uses kwargs of node
? I'd stick to the latter in all cases.
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.
Nice catch. Dropping the need for partial
further up, as node
does this for you.
docs/tutorials/nodes-tutorial.ipynb
Outdated
"id": "4b595fcb-02b8-4fa3-be16-3512e65b2c6a", | ||
"metadata": {}, | ||
"source": [ | ||
"Because the slider in only affecting the left part of the graph,\n", |
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.
"Because the slider in only affecting the left part of the graph,\n", | |
"Because the slider only affects the left part of the graph,\n", |
docs/tutorials/nodes-tutorial.ipynb
Outdated
"metadata": {}, | ||
"source": [ | ||
"Because the slider in only affecting the left part of the graph,\n", | ||
"only the orange markers will update when we drag the slider." |
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.
A bit risky to talk about 'the left part of the graph'. The layout might change if the algorithm or image size is tweaked.
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ipw.VBox([slider, fig2d, fig1d])" |
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.
Is it possible to start the slider at a different value than 1? As it stands, the lines look almost identical
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.
Changed to be at 10 when created.
docs/tutorials/nodes-tutorial.ipynb
Outdated
"id": "69510b9d-8bbb-4e7d-8c39-dde70d88b3db", | ||
"metadata": {}, | ||
"source": [ | ||
"We make a node from the checkboxes widge using `widget_node` once again.\n", |
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.
"We make a node from the checkboxes widge using `widget_node` once again.\n", | |
"We make a node from the checkboxes widget using `widget_node` once again.\n", |
docs/tutorials/nodes-tutorial.ipynb
Outdated
"Because the slider only affects the smoothing part of the graph,\n", | ||
"only the orange markers will update when we drag the slider.\n", | ||
"\n", | ||
"## Using `node` as a function decorator\n", |
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 like the section because it adds a little bit of complexity. But the decorator is only a small part of it. Maybe change it to something like 'Multiple view and multiple controls'.
No description provided.