Skip to content

Fix code formatting of some examples - #7730

Merged
dschult merged 3 commits into
networkx:mainfrom
eriknw:fix_examples
Nov 27, 2024
Merged

dschult merged 3 commits into
networkx:mainfrom
eriknw:fix_examples

Conversation

@eriknw

@eriknw eriknw commented Nov 22, 2024

Copy link
Copy Markdown
Contributor

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @eriknw !

G = nx.soft_random_geometric_graph(50, 0.2)
>>> G = nx.soft_random_geometric_graph(50, 0.2)

Custom Graph:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, just came accross this PR. If I understand correctly, the example for Custom Graph is in the Notes section, a few lines below in the source code.

However, in the doc, the Notes section appears above the Examples section, which makes this example confusing. I think it would be perfect if both examples for Default Graph and Custom Graph could be placed in the same Examples section.

@eriknw eriknw Nov 23, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. It is weird that Examples is at the bottom... below even References. I never gave this thought, but Examples does come at the end with numpydoc style: https://numpydoc.readthedocs.io/en/latest/format.html#examples

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am (as usual) confused. It looks to me like both the Default Graph example and the Custom Graph example appear together in an Examples section after the References section. I see that the Notes section is above both Refernece and Examples. That is, the section order changes between the doc_string in the code and the HTML generated by sphinx using the theme. But both examples are in the same examples section.

Is that different from what you are seeing @yuanx749 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dschult What I feel confusing is that there is only instruction ('Create a soft random...') under Custom Graph, but no code example. (Default Graph has example code.)

My understanding may be wrong. The code snippet in the Notes section could be used as an example for custom graph, but it appears above Examples section due to the section order changes after sphinx rendering.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ahhh.... I understand what you are saying now. :)
Thank you!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed that the Examples section of some of the geometric generators could use cleanup too - @yuanx749 would you want to open a separate PR with proposed updates there?

They can be fixed here as well, but IMO the proposed changes as of dfbead5 are good to go!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rossbar Yes, I think it would be better to update the examples with a separate PR. (I may open one in a couple of days if I have time).

G = nx.thresholded_random_geometric_graph(50, 0.2, 0.1)
>>> G = nx.thresholded_random_geometric_graph(50, 0.2, 0.1)

Custom Graph:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants