-
Notifications
You must be signed in to change notification settings - Fork 58
Fix typos and styling. #226
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
Changes from 1 commit
fcbd1a4
1ad8d98
c164faa
373201e
54a54c0
f02010d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |||||||||
| # | ||||||||||
| # ================================================================================================ | ||||||||||
| """ | ||||||||||
| Tools to visualize Chimera lattices and weighted graph problems on them. | ||||||||||
| Tools to visualize :term:`Chimera` lattices and weighted :term:`graph` problems on them. | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| import networkx as nx | ||||||||||
|
|
@@ -28,33 +28,34 @@ | |||||||||
|
|
||||||||||
|
|
||||||||||
| def chimera_layout(G, scale=1., center=None, dim=2): | ||||||||||
| """Positions the nodes of graph G in a Chimera cross topology. | ||||||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrt this comment, could we delete the phrase "in a Chimera cross topology"?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function creates a Chimera layout that can then be plotted. It could have potentially realized the layout in different ways, in particular, the cross and column layouts shown here. The modifier "in a Chimera cross topology" is saying that the function selected to implement the cross layout.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "in a Chimera cross layout"?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be okay or perhaps something like, "Positions a graph's nodes in a Chimera layout with unit cells as crosses."
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the HTML rendering, it seems to me that the modifier "with unit cells as crosses" is given too much importance at the top-level by being in the one-line descriptions. For someone looking for Chimera graph functions, what's important at the top level is that function |
||||||||||
| """Position the nodes of graph ``G`` in a Chimera cross topology. | ||||||||||
|
||||||||||
|
|
||||||||||
| NumPy (https://scipy.org) is required for this function. | ||||||||||
|
||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| G : NetworkX graph | ||||||||||
| Should be a Chimera graph or a subgraph of a | ||||||||||
| Chimera graph. If every node in G has a `chimera_index` | ||||||||||
| attribute, those are used to place the nodes. Otherwise makes | ||||||||||
| a best-effort attempt to find positions. | ||||||||||
| :term:`Chimera` :term:`graph` or :term:`subgraph` of a | ||||||||||
| Chimera graph. If every node in ``G`` has a ``chimera_index`` | ||||||||||
| attribute, the node position in the ``chimera_index`` | ||||||||||
| attribute is used to place each node. Otherwise, | ||||||||||
| a best-effort attempt is made to find the node positions. | ||||||||||
|
|
||||||||||
| scale : float (default 1.) | ||||||||||
| Scale factor. When scale = 1, all positions fit within [0, 1] | ||||||||||
| Scale factor. If ``scale = 1``, then all positions fit within [0, 1] | ||||||||||
|
||||||||||
| on the x-axis and [-1, 0] on the y-axis. | ||||||||||
|
|
||||||||||
| center : None or array (default None) | ||||||||||
| Coordinates of the top left corner. | ||||||||||
|
|
||||||||||
| dim : int (default 2) | ||||||||||
| Number of dimensions. When dim > 2, all extra dimensions are | ||||||||||
| Number of dimensions. If ``dim > 2``, then all extra dimensions are | ||||||||||
|
||||||||||
| set to 0. | ||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| pos : dict | ||||||||||
| A dictionary of positions keyed by node. | ||||||||||
| Dictionary of positions keyed by node. | ||||||||||
|
|
||||||||||
| Examples | ||||||||||
| -------- | ||||||||||
|
|
@@ -106,13 +107,13 @@ def chimera_layout(G, scale=1., center=None, dim=2): | |||||||||
|
|
||||||||||
|
|
||||||||||
| def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2): | ||||||||||
| """Generates a function that converts Chimera indices to x, y | ||||||||||
| coordinates for a plot. | ||||||||||
| """Generate a function that converts Chimera indices to x- and | ||||||||||
| y-coordinates for a plot. | ||||||||||
|
|
||||||||||
| Parameters | ||||||||||
| ---------- | ||||||||||
| m : int | ||||||||||
| Number of rows in the Chimera lattice. | ||||||||||
| Number of rows in the :term:`Chimera` lattice. | ||||||||||
|
|
||||||||||
| n : int | ||||||||||
| Number of columns in the Chimera lattice. | ||||||||||
|
|
@@ -121,22 +122,21 @@ def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2): | |||||||||
| Size of the shore within each Chimera tile. | ||||||||||
|
|
||||||||||
| scale : float (default 1.) | ||||||||||
| Scale factor. When scale = 1, all positions fit within [0, 1] | ||||||||||
| Scale factor. If ``scale = 1``, then all positions fit within [0, 1] | ||||||||||
| on the x-axis and [-1, 0] on the y-axis. | ||||||||||
|
|
||||||||||
| center : None or array (default None) | ||||||||||
| Coordinates of the top left corner. | ||||||||||
|
|
||||||||||
| dim : int (default 2) | ||||||||||
| Number of dimensions. When dim > 2, all extra dimensions are | ||||||||||
| Number of dimensions. If ``dim > 2``, then all extra dimensions are | ||||||||||
| set to 0. | ||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
| xy_coords : function | ||||||||||
|
||||||||||
| A function that maps a Chimera index (i, j, u, k) in an | ||||||||||
| (m, n, t) Chimera lattice to x,y coordinates such as | ||||||||||
| used by a plot. | ||||||||||
| Function that maps a Chimera index ``(i, j, u, k)`` in an | ||||||||||
| ``(m, n, t)`` Chimera lattice to x- and y-coordinates. | ||||||||||
|
|
||||||||||
| """ | ||||||||||
| import numpy as np | ||||||||||
|
|
@@ -190,30 +190,30 @@ def _xy_coords(i, j, u, k): | |||||||||
|
|
||||||||||
|
|
||||||||||
| def draw_chimera(G, **kwargs): | ||||||||||
| """Draws graph G in a Chimera cross topology. | ||||||||||
| """Draw graph ``G`` in a Chimera cross topology. | ||||||||||
|
|
||||||||||
| If `linear_biases` and/or `quadratic_biases` are provided, these | ||||||||||
| are visualized on the plot. | ||||||||||
| Linear and quadratic biases are visualized on the plot as specified | ||||||||||
|
||||||||||
| Linear and quadratic biases are visualized on the plot as specified | |
| Linear and quadratic biases are visualized on the plot if specified |
The new wording of the intro makes it seem mandatory
Outdated
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 dict of biases associated with each node in ``G`` and of | |
| the form ``{node: bias, ...}``. Each bias is numeric. | |
| Linear biases for all nodes of ``G``, as a dict of form ``{node: bias, ...}``, | |
| where ``bias`` is numeric. |
We prefer to start the description with what the parameter means ("linear biases") rather than the data type ("dict"). The above is more consistent with our docs
Also applies elsewhere below
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.
Does it work with the simpler path networkx.draw_networkx, it will be less fragile to changes in structure than networkx.drawing.nx_pylab.draw_networkx.
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 don't think so. @JoelPasvolsky?
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.
Also don't think so, networkx.drawing.nx_pylab.draw_networkx reference/generated/networkx.drawing.nx_pylab.draw_networkx.html#networkx.drawing.nx_pylab.draw_networkx is the only draw_networkx under py:function in the NetworkX objects.inv file that I see
Outdated
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.
What does ", according to the Chimera layout" add to comprehension 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.
Are you saying that we can delete this phrase because it is in the Chimera layout by context?
Also, can we delete "in a Chimera cross topology" in other places. Also, what is a "cross topology"?
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.
Yes, I don't understand what the "according to layout" clause adds to the preceding clause here. Perhaps there's good intention but insufficiently clear writing behind the existing sentence.
I can't answer the general question of deleting something in other places without knowing what those places say.
For "cross" you might be referring to cross layout drawing as opposed to column layout. Whether or not that info is essential or not, depends on the local context.
Outdated
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.
Do we need this intro paragraph? Why can't this all be specified in the descriptions of the parameters themselves? The intro should be to point out general, crucial, or unintuitive aspects of the function
Outdated
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.
Perhaps it is helpful to use a "the x parameter" for the first usage to call attention that the formatted text is params listed and described here, but three uses adds text with decreasing marginal utility
Outdated
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.
| List of edges which will be used as interactions. | |
| Interactions as a list of edges. |
Outdated
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.
Ambiguous phrasing: it's unclear whether it is saying "part of chains and edges that are" or "... and edges that are"
Outdated
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.
Another reminder that you can drop all these "then"s
Outdated
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 drawing will display these overlaps" --> "the drawing displays these overlaps"
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.
"If the linear_biases or quadratic_biases parameters are specified" --> This function does not have linear_biases or quadratic_biases parameters, at least in the above descriptions.
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.
These were present in the original. Perhaps they are referring to the parameters in draw_chimera? Should we point to draw_chimera?
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 suggest leaving this bit (for all three topographies) alone in this PR because I suspect the current functionality has problems that will be fixed by this PR. Currently, it seems to me that the node_color and edge_color params are not supported:
G = dnx.chimera_graph(2)
embedding = {"N1": [0, 4, 5], "N2": [1, 6, 7]}
dnx.draw_chimera_embedding(G, embedding, show_labels=True, node_color="r")
returns a TypeError: networkx.drawing.nx_pylab.draw() got multiple values for keyword argument 'node_color' error.
In any case the other PR and this change have conflicts so leaving it untouched will save Kelly work.
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.
"If the linear_biases or quadratic_biases parameters are specified" --> This function does not have linear_biases or quadratic_biases parameters, at least in the above descriptions.

Uh oh!
There was an error while loading. Please reload this page.