From 139cbbcb54c654bae3e2b6105f2b0c0c3cb39ef0 Mon Sep 17 00:00:00 2001 From: Nicholas Landry Date: Sat, 13 Jan 2024 18:59:12 -0500 Subject: [PATCH 1/2] format notebooks with isort --- HOW_TO_CONTRIBUTE.md | 2 +- .../api/tutorials/In Depth 1 - Drawing nodes.ipynb | 1 + .../tutorials/In Depth 2 - Drawing hyperedges.ipynb | 5 +++-- .../tutorials/In Depth 3 - Drawing DiHypergraphs.ipynb | 5 +++-- .../In Depth 4 - Drawing multilayer-style.ipynb | 5 +++-- .../Tutorial 1 - Basic Hypergraph Functionality.ipynb | 6 ++++-- .../api/tutorials/Tutorial 2 - Read and Write.ipynb | 5 +++-- .../Tutorial 3 - Basic simplicial complex usage.ipynb | 6 ++++-- .../api/tutorials/Tutorial 4 - Generative_Models.ipynb | 6 ++++-- docs/source/api/tutorials/Tutorial 5 - Plotting.ipynb | 6 ++++-- .../tutorials/Tutorial 7 - Directed Hypergraphs.ipynb | 1 + docs/source/api/tutorials/XGI in 15 minutes.ipynb | 5 +++-- docs/source/api/tutorials/XGI in 5 minutes.ipynb | 5 +++-- docs/source/api/tutorials/case_study_zhang2022.ipynb | 2 ++ docs/source/api/tutorials/quickstart.ipynb | 10 ++++++---- .../api/tutorials/simplicial_kuramoto_example.ipynb | 5 +++-- requirements/developer.txt | 3 ++- 17 files changed, 50 insertions(+), 28 deletions(-) diff --git a/HOW_TO_CONTRIBUTE.md b/HOW_TO_CONTRIBUTE.md index 4878be8a1..076596d63 100644 --- a/HOW_TO_CONTRIBUTE.md +++ b/HOW_TO_CONTRIBUTE.md @@ -12,7 +12,7 @@ Please note we have a [code of conduct](/CODE_OF_CONDUCT.md), please follow it i 4. [Optional, but STRONGLY preferred] Include any new method/function in the corresponding docs file. 5. Run `pytest` to verify all unit tests pass. 6. [Optional, but STRONGLY preferred] Run `pylint xgi/ --disable all --enable W0611` and remove any unnecessary dependencies. -7. [Optional, but STRONGLY preferred] Run `isort .` to sort any new import statements. +7. [Optional, but STRONGLY preferred] Run `isort .` to sort any new import statements in the source code and run `nbqa isort docs/source/api/tutorials/*.ipynb` sort any new import statements in the tutorials. 8. [Optional, but STRONGLY preferred] Run `black .` for consistent styling. 9. Update the "Current Version" section of CHANGELOG.md with overview of changes to the interface and add the usernames of all contributors. 10. Submit Pull Request with a list of changes, links to issues that it addresses (if applicable) diff --git a/docs/source/api/tutorials/In Depth 1 - Drawing nodes.ipynb b/docs/source/api/tutorials/In Depth 1 - Drawing nodes.ipynb index 78793bdbc..26b66cca4 100644 --- a/docs/source/api/tutorials/In Depth 1 - Drawing nodes.ipynb +++ b/docs/source/api/tutorials/In Depth 1 - Drawing nodes.ipynb @@ -19,6 +19,7 @@ "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", + "\n", "import xgi" ] }, diff --git a/docs/source/api/tutorials/In Depth 2 - Drawing hyperedges.ipynb b/docs/source/api/tutorials/In Depth 2 - Drawing hyperedges.ipynb index 200b301e0..8555cdc75 100644 --- a/docs/source/api/tutorials/In Depth 2 - Drawing hyperedges.ipynb +++ b/docs/source/api/tutorials/In Depth 2 - Drawing hyperedges.ipynb @@ -23,9 +23,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/In Depth 3 - Drawing DiHypergraphs.ipynb b/docs/source/api/tutorials/In Depth 3 - Drawing DiHypergraphs.ipynb index 8e547cce4..d6de36ae1 100644 --- a/docs/source/api/tutorials/In Depth 3 - Drawing DiHypergraphs.ipynb +++ b/docs/source/api/tutorials/In Depth 3 - Drawing DiHypergraphs.ipynb @@ -23,9 +23,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/In Depth 4 - Drawing multilayer-style.ipynb b/docs/source/api/tutorials/In Depth 4 - Drawing multilayer-style.ipynb index a4d77eb3e..5b6642d4d 100644 --- a/docs/source/api/tutorials/In Depth 4 - Drawing multilayer-style.ipynb +++ b/docs/source/api/tutorials/In Depth 4 - Drawing multilayer-style.ipynb @@ -23,9 +23,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/Tutorial 1 - Basic Hypergraph Functionality.ipynb b/docs/source/api/tutorials/Tutorial 1 - Basic Hypergraph Functionality.ipynb index 2fcc0b06d..fbfe69732 100644 --- a/docs/source/api/tutorials/Tutorial 1 - Basic Hypergraph Functionality.ipynb +++ b/docs/source/api/tutorials/Tutorial 1 - Basic Hypergraph Functionality.ipynb @@ -21,10 +21,12 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", "import random\n", + "\n", + "import numpy as np\n", "import pandas as pd\n", - "import numpy as np" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/Tutorial 2 - Read and Write.ipynb b/docs/source/api/tutorials/Tutorial 2 - Read and Write.ipynb index 89ab061bc..6e186c56b 100644 --- a/docs/source/api/tutorials/Tutorial 2 - Read and Write.ipynb +++ b/docs/source/api/tutorials/Tutorial 2 - Read and Write.ipynb @@ -14,8 +14,9 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", - "import random" + "import random\n", + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/Tutorial 3 - Basic simplicial complex usage.ipynb b/docs/source/api/tutorials/Tutorial 3 - Basic simplicial complex usage.ipynb index ae428d49d..4f949f56d 100644 --- a/docs/source/api/tutorials/Tutorial 3 - Basic simplicial complex usage.ipynb +++ b/docs/source/api/tutorials/Tutorial 3 - Basic simplicial complex usage.ipynb @@ -19,10 +19,12 @@ }, "outputs": [], "source": [ - "import xgi\n", "import random\n", + "\n", + "import numpy as np\n", "import pandas as pd\n", - "import numpy as np" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/Tutorial 4 - Generative_Models.ipynb b/docs/source/api/tutorials/Tutorial 4 - Generative_Models.ipynb index f80726bb6..1b7c1084e 100644 --- a/docs/source/api/tutorials/Tutorial 4 - Generative_Models.ipynb +++ b/docs/source/api/tutorials/Tutorial 4 - Generative_Models.ipynb @@ -20,9 +20,11 @@ }, "outputs": [], "source": [ - "import xgi\n", + "import random\n", + "\n", "import numpy as np\n", - "import random" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/Tutorial 5 - Plotting.ipynb b/docs/source/api/tutorials/Tutorial 5 - Plotting.ipynb index 0617e8107..fd29163a8 100644 --- a/docs/source/api/tutorials/Tutorial 5 - Plotting.ipynb +++ b/docs/source/api/tutorials/Tutorial 5 - Plotting.ipynb @@ -23,10 +23,12 @@ "metadata": {}, "outputs": [], "source": [ - "import matplotlib.pyplot as plt\n", "import itertools\n", - "import numpy as np\n", "import random\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", "import xgi" ] }, diff --git a/docs/source/api/tutorials/Tutorial 7 - Directed Hypergraphs.ipynb b/docs/source/api/tutorials/Tutorial 7 - Directed Hypergraphs.ipynb index 4e0ddaf98..9fc8cb783 100644 --- a/docs/source/api/tutorials/Tutorial 7 - Directed Hypergraphs.ipynb +++ b/docs/source/api/tutorials/Tutorial 7 - Directed Hypergraphs.ipynb @@ -14,6 +14,7 @@ "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", + "\n", "import xgi" ] }, diff --git a/docs/source/api/tutorials/XGI in 15 minutes.ipynb b/docs/source/api/tutorials/XGI in 15 minutes.ipynb index 323c7fe80..f180af269 100644 --- a/docs/source/api/tutorials/XGI in 15 minutes.ipynb +++ b/docs/source/api/tutorials/XGI in 15 minutes.ipynb @@ -17,9 +17,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/XGI in 5 minutes.ipynb b/docs/source/api/tutorials/XGI in 5 minutes.ipynb index fc1f32d5a..46f154fe9 100644 --- a/docs/source/api/tutorials/XGI in 5 minutes.ipynb +++ b/docs/source/api/tutorials/XGI in 5 minutes.ipynb @@ -21,9 +21,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/docs/source/api/tutorials/case_study_zhang2022.ipynb b/docs/source/api/tutorials/case_study_zhang2022.ipynb index 6c98ed57d..62db66bb6 100644 --- a/docs/source/api/tutorials/case_study_zhang2022.ipynb +++ b/docs/source/api/tutorials/case_study_zhang2022.ipynb @@ -46,6 +46,8 @@ "outputs": [], "source": [ "# utility functions to compute the Lyapunov exponents from the Laplacians\n", + "\n", + "\n", "def compute_eigenvalues(H, order, weight, rescale_per_node=True):\n", " \"\"\"Returns the Lyapunov exponents of corresponding to the Laplacian of order d.\n", "\n", diff --git a/docs/source/api/tutorials/quickstart.ipynb b/docs/source/api/tutorials/quickstart.ipynb index 7aed66e0f..89d2df6d6 100644 --- a/docs/source/api/tutorials/quickstart.ipynb +++ b/docs/source/api/tutorials/quickstart.ipynb @@ -26,13 +26,14 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", + "import networkx as nx\n", "import numpy as np\n", "import pandas as pd\n", "from IPython.display import display\n", "from matplotlib.pyplot import cm\n", - "import matplotlib.pyplot as plt\n", - "import networkx as nx" + "\n", + "import xgi" ] }, { @@ -849,10 +850,11 @@ } ], "source": [ - "import xgi\n", "import numpy as np\n", "import pandas as pd\n", "\n", + "import xgi\n", + "\n", "H_stats = xgi.Hypergraph([[1, 2, 3], [2, 3, 4, 5], [3, 4, 5]])\n", "H_stats.degree()" ] diff --git a/docs/source/api/tutorials/simplicial_kuramoto_example.ipynb b/docs/source/api/tutorials/simplicial_kuramoto_example.ipynb index 8f2e043e5..5261ec974 100644 --- a/docs/source/api/tutorials/simplicial_kuramoto_example.ipynb +++ b/docs/source/api/tutorials/simplicial_kuramoto_example.ipynb @@ -14,9 +14,10 @@ "metadata": {}, "outputs": [], "source": [ - "import xgi\n", + "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import matplotlib.pyplot as plt" + "\n", + "import xgi" ] }, { diff --git a/requirements/developer.txt b/requirements/developer.txt index 034ed150c..98cc4706e 100644 --- a/requirements/developer.txt +++ b/requirements/developer.txt @@ -1,4 +1,5 @@ black[jupyter]==22.3.0 pre-commit>=2.12 isort==5.10.1 -pylint>=2.10 \ No newline at end of file +pylint>=2.10 +nbqa \ No newline at end of file From 63362051f59d465a8f2068e37e49ec9014379c0a Mon Sep 17 00:00:00 2001 From: Nicholas Landry Date: Sun, 11 Feb 2024 21:58:46 -0500 Subject: [PATCH 2/2] updated how to contribute --- HOW_TO_CONTRIBUTE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HOW_TO_CONTRIBUTE.md b/HOW_TO_CONTRIBUTE.md index 076596d63..b8a992cc6 100644 --- a/HOW_TO_CONTRIBUTE.md +++ b/HOW_TO_CONTRIBUTE.md @@ -12,7 +12,7 @@ Please note we have a [code of conduct](/CODE_OF_CONDUCT.md), please follow it i 4. [Optional, but STRONGLY preferred] Include any new method/function in the corresponding docs file. 5. Run `pytest` to verify all unit tests pass. 6. [Optional, but STRONGLY preferred] Run `pylint xgi/ --disable all --enable W0611` and remove any unnecessary dependencies. -7. [Optional, but STRONGLY preferred] Run `isort .` to sort any new import statements in the source code and run `nbqa isort docs/source/api/tutorials/*.ipynb` sort any new import statements in the tutorials. +7. [Optional, but STRONGLY preferred] Run `isort .` and `nbqa isort .` to sort any new import statements in the source code and tutorials. 8. [Optional, but STRONGLY preferred] Run `black .` for consistent styling. 9. Update the "Current Version" section of CHANGELOG.md with overview of changes to the interface and add the usernames of all contributors. 10. Submit Pull Request with a list of changes, links to issues that it addresses (if applicable)