Skip to content
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

Fixed docstrings for graph relabeling and sublattice mapping functionality missing from reference documentation. #237

Closed
wants to merge 3 commits into from

Conversation

qwriter
Copy link
Contributor

@qwriter qwriter commented May 25, 2024

Also, edited those docstrings.

This is the fix for issue #234.

Copy link

codecov bot commented May 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.81%. Comparing base (0b9682b) to head (244713a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #237   +/-   ##
=======================================
  Coverage   75.81%   75.81%           
=======================================
  Files          31       31           
  Lines        2171     2171           
=======================================
  Hits         1646     1646           
  Misses        525      525           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@randomir randomir requested a review from JoelPasvolsky May 27, 2024 09:59
Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of general comments:

  1. Please make all PRs on a new branch, not on main
  2. I made some comments on the first docstrings that apply to the rest as well, so I did not repeat them for all: these are about the use of the descriptive mode versus command for the first line, the use of back ticks for parameter references, and the Notes sections.

@@ -252,7 +252,7 @@ def checkadd(v, q):


def find_chimera_indices(G):
"""Attempts to determine the Chimera indices of the nodes in graph G.
"""Attempt to determine the Chimera indices of the nodes in graph G.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dwave_networkx package is the one exception we have to the standard PEP "prescribes the function or method’s effect as a command" to be consistent with NetworkX (although it seems to me that NetworkX is now more compliant with PEP than it was in the past).

For internal consistency we should keep using the descriptive mode for the first line until a time when/if we convert all the docstrings

@@ -496,7 +496,7 @@ def iter_linear_to_chimera_pairs(self, plist):
return self._pair_repack(self.iter_linear_to_chimera, plist)

def graph_to_linear(self, g):
"""Return a copy of the graph g relabeled to have linear indices"""
"""Return a copy of the graph `g` relabeled to have linear indices."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Return a copy of the graph `g` relabeled to have linear indices."""
"""Returns a copy of the graph ``g`` relabeled to have linear indices."""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should really have an Args section with a description of the parameter

@@ -515,7 +515,7 @@ def graph_to_linear(self, g):
)

def graph_to_chimera(self, g):
"""Return a copy of the graph g relabeled to have chimera coordinates"""
"""Return a copy of the graph `g` relabeled to have Chimera coordinates."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments: "Returns" and "g"

@@ -545,7 +545,7 @@ def __missing__(self, key):
_chimera_coordinates_cache = __chimera_coordinates_cache_dict()

def linear_to_chimera(r, m, n=None, t=None):
"""Convert the linear index `r` into a chimera index.
"""Convert the linear index `r` into a Chimera index.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments: "Converts" and "r"

@@ -545,7 +545,7 @@ def __missing__(self, key):
_chimera_coordinates_cache = __chimera_coordinates_cache_dict()

def linear_to_chimera(r, m, n=None, t=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function not documented anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate? linear_to_chimera does have a docstring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a linear_to_chimera method of chimera_coordinates defined on line 406 and a function linear_to_chimera defined on line 547, but I see only the first documented on line 40 of utilities.rst

set of sublattice mappings would take those isomorphisms into account; we do
not undertake that complexity here.

"""Yield mappings from a Chimera graph into a larger Chimera graph.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about internal consistency

target : NetworkX Graph
The Chimera graph that nodes are input from
The Chimera graph that nodes are output to.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

is stored in ``mapping.offset``, which can be collected and passed
into ``offset_list`` in a later session.

Notes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of using a different section to structure long descriptive content but these docstrings are now inconsistent with the rest of the documentation: the majority of docstrings use the Notes section for minor comments; see for example maximum_independent_set

@arcondello
Copy link
Member

Closing as redundant to #238

@arcondello arcondello closed this Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants