From 616c2df0bb29c409ced46a7736f9160c2b8b245f Mon Sep 17 00:00:00 2001 From: paupb Date: Sun, 13 Nov 2022 01:00:13 -0300 Subject: [PATCH 01/13] Add warning in community doc --- networkx/algorithms/community/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/networkx/algorithms/community/__init__.py b/networkx/algorithms/community/__init__.py index 9aea4054d9d..bfca2756972 100644 --- a/networkx/algorithms/community/__init__.py +++ b/networkx/algorithms/community/__init__.py @@ -1,9 +1,10 @@ """Functions for computing and measuring community structure. -The functions in this class are not imported into the top-level -:mod:`networkx` namespace. You can access these functions by importing -the :mod:`networkx.algorithms.community` module, then accessing the -functions as attributes of ``community``. For example:: +.. warning:: The functions in this class are not imported into the top-level +:mod:`networkx` namespace. + +They can be imported using the :mod:`networkx.algorithms.community` module, +then accessing the functions as attributes of ``community``. For example:: >>> from networkx.algorithms import community >>> G = nx.barbell_graph(5, 1) From 379da2d845addfc3b288d2c0f8dd49b7170e5600 Mon Sep 17 00:00:00 2001 From: paupb Date: Sun, 8 Jan 2023 12:21:03 -0300 Subject: [PATCH 02/13] fix unwanted change --- networkx/algorithms/community/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/networkx/algorithms/community/__init__.py b/networkx/algorithms/community/__init__.py index bfca2756972..9aea4054d9d 100644 --- a/networkx/algorithms/community/__init__.py +++ b/networkx/algorithms/community/__init__.py @@ -1,10 +1,9 @@ """Functions for computing and measuring community structure. -.. warning:: The functions in this class are not imported into the top-level -:mod:`networkx` namespace. - -They can be imported using the :mod:`networkx.algorithms.community` module, -then accessing the functions as attributes of ``community``. For example:: +The functions in this class are not imported into the top-level +:mod:`networkx` namespace. You can access these functions by importing +the :mod:`networkx.algorithms.community` module, then accessing the +functions as attributes of ``community``. For example:: >>> from networkx.algorithms import community >>> G = nx.barbell_graph(5, 1) From e5223cfa57b59cf0922d37749addba48b1cdb9a7 Mon Sep 17 00:00:00 2001 From: paupb Date: Thu, 2 Feb 2023 17:08:58 -0300 Subject: [PATCH 03/13] Test setup and first plotting example --- doc/conf.py | 1 + networkx/generators/classic.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 0a25320b16e..e3e34d1619b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -24,6 +24,7 @@ "nb2plots", "texext", "numpydoc", + "matplotlib.sphinxext.plot_directive", ] # https://github.com/sphinx-gallery/sphinx-gallery diff --git a/networkx/generators/classic.py b/networkx/generators/classic.py index 3fff105f1e1..606df2dc75e 100644 --- a/networkx/generators/classic.py +++ b/networkx/generators/classic.py @@ -250,6 +250,11 @@ def complete_graph(n, create_using=None): A complete graph on `n` nodes means that all pairs of distinct nodes have an edge connecting them. + .. plot:: + A plotting example: + >>> import networkx as nx + >>> nx.draw(nx.complete_graph(5)) + Parameters ---------- n : int or iterable container of nodes From e332b0972705edb7df83c482c8c34b5ddc33993d Mon Sep 17 00:00:00 2001 From: paupb Date: Thu, 2 Feb 2023 20:36:52 -0300 Subject: [PATCH 04/13] Add setup conf to make examples work --- doc/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index e3e34d1619b..69fd2cedc16 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -241,6 +241,9 @@ numpydoc_show_class_members = False +# Make numpydoc to generate plots for example sections +numpydoc_use_plots = True + def setup(app): app.add_css_file("custom.css") From 514f29e302257d2b30ab7ffaa21137182302bf08 Mon Sep 17 00:00:00 2001 From: paupb Date: Thu, 2 Feb 2023 21:01:10 -0300 Subject: [PATCH 05/13] More set up related code in conf.py --- doc/conf.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 69fd2cedc16..105e0177b6b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -244,6 +244,35 @@ # Make numpydoc to generate plots for example sections numpydoc_use_plots = True +# Plots conf +plot_pre_code = """ +import networkx as nx +np.random.seed(0) +""" + +plot_include_source = True +plot_formats = [("png", 100), "pdf"] + +import math + +phi = (math.sqrt(5) + 1) / 2 + +plot_rcparams = { + "font.size": 8, + "axes.titlesize": 8, + "axes.labelsize": 8, + "xtick.labelsize": 8, + "ytick.labelsize": 8, + "legend.fontsize": 8, + "figure.figsize": (3 * phi, 3), + "figure.subplot.bottom": 0.2, + "figure.subplot.left": 0.2, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.85, + "figure.subplot.wspace": 0.4, + "text.usetex": False, +} + def setup(app): app.add_css_file("custom.css") From d57b7875fb269f9728ba1307e666b2754ad5b4d3 Mon Sep 17 00:00:00 2001 From: paupb Date: Fri, 3 Feb 2023 20:42:08 -0300 Subject: [PATCH 06/13] Test if setup works --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index 105e0177b6b..4c141e10b1f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -25,6 +25,7 @@ "texext", "numpydoc", "matplotlib.sphinxext.plot_directive", + "numpydoc.plot_directives", ] # https://github.com/sphinx-gallery/sphinx-gallery From 0ab05914caa84f86b9b51794ec0021ffbfc9a88b Mon Sep 17 00:00:00 2001 From: paupb Date: Mon, 6 Feb 2023 18:03:08 -0300 Subject: [PATCH 07/13] use only numpydoc and test set up --- doc/conf.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 4c141e10b1f..56161e7921c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -24,8 +24,6 @@ "nb2plots", "texext", "numpydoc", - "matplotlib.sphinxext.plot_directive", - "numpydoc.plot_directives", ] # https://github.com/sphinx-gallery/sphinx-gallery @@ -245,35 +243,6 @@ # Make numpydoc to generate plots for example sections numpydoc_use_plots = True -# Plots conf -plot_pre_code = """ -import networkx as nx -np.random.seed(0) -""" - -plot_include_source = True -plot_formats = [("png", 100), "pdf"] - -import math - -phi = (math.sqrt(5) + 1) / 2 - -plot_rcparams = { - "font.size": 8, - "axes.titlesize": 8, - "axes.labelsize": 8, - "xtick.labelsize": 8, - "ytick.labelsize": 8, - "legend.fontsize": 8, - "figure.figsize": (3 * phi, 3), - "figure.subplot.bottom": 0.2, - "figure.subplot.left": 0.2, - "figure.subplot.right": 0.9, - "figure.subplot.top": 0.85, - "figure.subplot.wspace": 0.4, - "text.usetex": False, -} - def setup(app): app.add_css_file("custom.css") From 080d6e11eab2f3696351ba1cba0a9ea78240bb5c Mon Sep 17 00:00:00 2001 From: paupb Date: Mon, 6 Feb 2023 19:38:28 -0300 Subject: [PATCH 08/13] Test new conf --- doc/conf.py | 29 +++++++++++++++++++++++++++++ networkx/generators/classic.py | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 56161e7921c..887663a3b22 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -24,6 +24,8 @@ "nb2plots", "texext", "numpydoc", + "IPython.sphinxext.ipython_directive", + "matplotlib.sphinxext.plot_directive", ] # https://github.com/sphinx-gallery/sphinx-gallery @@ -243,6 +245,33 @@ # Make numpydoc to generate plots for example sections numpydoc_use_plots = True +plot_pre_code = """ +import numpy as np +np.random.seed(0) +""" +plot_include_source = True +plot_formats = [("png", 100), "pdf"] + +import math + +phi = (math.sqrt(5) + 1) / 2 + +plot_rcparams = { + "font.size": 8, + "axes.titlesize": 8, + "axes.labelsize": 8, + "xtick.labelsize": 8, + "ytick.labelsize": 8, + "legend.fontsize": 8, + "figure.figsize": (3 * phi, 3), + "figure.subplot.bottom": 0.2, + "figure.subplot.left": 0.2, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.85, + "figure.subplot.wspace": 0.4, + "text.usetex": False, +} + def setup(app): app.add_css_file("custom.css") diff --git a/networkx/generators/classic.py b/networkx/generators/classic.py index 606df2dc75e..e660a0b1b92 100644 --- a/networkx/generators/classic.py +++ b/networkx/generators/classic.py @@ -251,10 +251,11 @@ def complete_graph(n, create_using=None): of distinct nodes have an edge connecting them. .. plot:: - A plotting example: + >>> import networkx as nx >>> nx.draw(nx.complete_graph(5)) + Parameters ---------- n : int or iterable container of nodes From 1a4f2625e2521ec1e49bfdab5a020e1a94f7b2c7 Mon Sep 17 00:00:00 2001 From: paupb Date: Mon, 6 Feb 2023 20:16:56 -0300 Subject: [PATCH 09/13] add import networkx as part of pre-code and comment source options --- doc/conf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 887663a3b22..a2c20eb4375 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -246,11 +246,12 @@ numpydoc_use_plots = True plot_pre_code = """ -import numpy as np +import networkx as nx np.random.seed(0) """ -plot_include_source = True -plot_formats = [("png", 100), "pdf"] + +# plot_include_source = True +# plot_formats = [("png", 100), "pdf"] import math From 513bce6c983228035a260ad5bc39b774ea71e66d Mon Sep 17 00:00:00 2001 From: paupb Date: Mon, 6 Feb 2023 21:36:37 -0300 Subject: [PATCH 10/13] fix conf --- doc/conf.py | 4 ++-- networkx/generators/classic.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index a2c20eb4375..e1fc54c1d47 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -250,8 +250,8 @@ np.random.seed(0) """ -# plot_include_source = True -# plot_formats = [("png", 100), "pdf"] +plot_include_source = True +plot_formats = [("png", 100), "pdf"] import math diff --git a/networkx/generators/classic.py b/networkx/generators/classic.py index e660a0b1b92..f95dfb624cf 100644 --- a/networkx/generators/classic.py +++ b/networkx/generators/classic.py @@ -252,7 +252,6 @@ def complete_graph(n, create_using=None): .. plot:: - >>> import networkx as nx >>> nx.draw(nx.complete_graph(5)) From b944551396a28c2337551750d0815d986003e838 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 6 Feb 2023 21:53:39 -0800 Subject: [PATCH 11/13] Try minimal configuration. --- doc/conf.py | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index e1fc54c1d47..09bdca48a69 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -241,38 +241,12 @@ default_role = "obj" numpydoc_show_class_members = False - -# Make numpydoc to generate plots for example sections -numpydoc_use_plots = True +numpydoc_use_plots = True # Generate plots for example sections plot_pre_code = """ import networkx as nx -np.random.seed(0) """ -plot_include_source = True -plot_formats = [("png", 100), "pdf"] - -import math - -phi = (math.sqrt(5) + 1) / 2 - -plot_rcparams = { - "font.size": 8, - "axes.titlesize": 8, - "axes.labelsize": 8, - "xtick.labelsize": 8, - "ytick.labelsize": 8, - "legend.fontsize": 8, - "figure.figsize": (3 * phi, 3), - "figure.subplot.bottom": 0.2, - "figure.subplot.left": 0.2, - "figure.subplot.right": 0.9, - "figure.subplot.top": 0.85, - "figure.subplot.wspace": 0.4, - "text.usetex": False, -} - def setup(app): app.add_css_file("custom.css") From aa4048c0b69fc455d6e2a50dd5694c138a64eb14 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 6 Feb 2023 23:09:45 -0800 Subject: [PATCH 12/13] Revert "Try minimal configuration." This reverts commit b944551396a28c2337551750d0815d986003e838. --- doc/conf.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 09bdca48a69..e1fc54c1d47 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -241,12 +241,38 @@ default_role = "obj" numpydoc_show_class_members = False -numpydoc_use_plots = True # Generate plots for example sections + +# Make numpydoc to generate plots for example sections +numpydoc_use_plots = True plot_pre_code = """ import networkx as nx +np.random.seed(0) """ +plot_include_source = True +plot_formats = [("png", 100), "pdf"] + +import math + +phi = (math.sqrt(5) + 1) / 2 + +plot_rcparams = { + "font.size": 8, + "axes.titlesize": 8, + "axes.labelsize": 8, + "xtick.labelsize": 8, + "ytick.labelsize": 8, + "legend.fontsize": 8, + "figure.figsize": (3 * phi, 3), + "figure.subplot.bottom": 0.2, + "figure.subplot.left": 0.2, + "figure.subplot.right": 0.9, + "figure.subplot.top": 0.85, + "figure.subplot.wspace": 0.4, + "text.usetex": False, +} + def setup(app): app.add_css_file("custom.css") From 73cffb5fc131f369609ea46bfee3f40a0bdf4608 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Mon, 6 Feb 2023 23:26:57 -0800 Subject: [PATCH 13/13] Plotting in Examples section. --- doc/conf.py | 1 - networkx/generators/classic.py | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index e1fc54c1d47..2f0abd428ac 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -247,7 +247,6 @@ plot_pre_code = """ import networkx as nx -np.random.seed(0) """ plot_include_source = True diff --git a/networkx/generators/classic.py b/networkx/generators/classic.py index f95dfb624cf..4815dd448fb 100644 --- a/networkx/generators/classic.py +++ b/networkx/generators/classic.py @@ -250,11 +250,6 @@ def complete_graph(n, create_using=None): A complete graph on `n` nodes means that all pairs of distinct nodes have an edge connecting them. - .. plot:: - - >>> nx.draw(nx.complete_graph(5)) - - Parameters ---------- n : int or iterable container of nodes @@ -279,6 +274,12 @@ def complete_graph(n, create_using=None): >>> G.is_directed() True + $K_5$ with a circular layout + + >>> import matplotlib.pyplot as plt + >>> G = nx.complete_graph(5) + >>> nx.draw_circular(G) + >>> plt.show(); """ _, nodes = n G = empty_graph(nodes, create_using)