~tfardet: 1 Bugfix: undirected density, support with/without loops 70 files changed, 128 insertions(+), 85 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~tfardet/nngt-developers/patches/29079/mbox | git am -3Learn more about email & git
From: Tanguy Fardet <tanguyfardet@protonmail.com> --- nngt/__init__.py | 2 +- nngt/analysis/__init__.py | 2 +- nngt/analysis/activity_analysis.py | 2 +- nngt/analysis/bayesian_blocks.py | 2 +- nngt/analysis/clustering.py | 2 +- nngt/analysis/graph_analysis.py | 2 +- nngt/analysis/gt_functions.py | 2 +- nngt/analysis/ig_functions.py | 2 +- nngt/analysis/nngt_functions.py | 2 +- nngt/analysis/nx_functions.py | 2 +- nngt/core/__init__.py | 2 +- nngt/core/connections.py | 2 +- nngt/core/graph.py | 29 +++++++++++++--- nngt/core/graph_interface.py | 2 +- nngt/core/group_structure.py | 2 +- nngt/core/gt_graph.py | 2 +- nngt/core/ig_graph.py | 2 +- nngt/core/networks.py | 2 +- nngt/core/neural_pop_group.py | 2 +- nngt/core/nngt_graph.py | 2 +- nngt/core/nx_graph.py | 2 +- nngt/core/spatial_graph.py | 2 +- nngt/database/__init__.py | 2 +- nngt/database/csv_utils.py | 2 +- nngt/database/db_generation.py | 2 +- nngt/database/db_main.py | 2 +- nngt/database/pickle_field.py | 2 +- nngt/generation/__init__.py | 2 +- nngt/generation/connect_algorithms.py | 2 +- nngt/generation/connectors.py | 2 +- nngt/generation/graph_connectivity.py | 2 +- nngt/generation/mpi_connect.py | 2 +- nngt/generation/rewiring.py | 2 +- nngt/geospatial/__init__.py | 2 +- nngt/geospatial/_cartopy_ne.py | 2 +- nngt/geospatial/countries.py | 2 +- nngt/geospatial/plot.py | 2 +- nngt/io/__init__.py | 2 +- nngt/io/graph_loading.py | 2 +- nngt/io/graph_saving.py | 2 +- nngt/io/io_helpers.py | 2 +- nngt/io/loading_helpers.py | 2 +- nngt/io/saving_helpers.py | 2 +- nngt/lib/__init__.py | 2 +- nngt/lib/_frozendict.py | 2 +- nngt/lib/connect_tools.py | 2 +- nngt/lib/constants.py | 2 +- nngt/lib/converters.py | 2 +- nngt/lib/db_tools.py | 2 +- nngt/lib/decorator.py | 2 +- nngt/lib/errors.py | 2 +- nngt/lib/graph_backends.py | 2 +- nngt/lib/graph_helpers.py | 2 +- nngt/lib/logger.py | 2 +- nngt/lib/nngt_config.py | 2 +- nngt/lib/rng_tools.py | 2 +- nngt/lib/sorting.py | 2 +- nngt/lib/test_functions.py | 2 +- nngt/plot/__init__.py | 2 +- nngt/plot/animations.py | 2 +- nngt/plot/custom_plt.py | 2 +- nngt/plot/hive_helpers.py | 2 +- nngt/plot/plt_networks.py | 2 +- nngt/plot/plt_properties.py | 2 +- nngt/simulation/__init__.py | 2 +- nngt/simulation/nest_activity.py | 2 +- nngt/simulation/nest_graph.py | 2 +- nngt/simulation/nest_plot.py | 2 +- nngt/simulation/nest_utils.py | 2 +- testing/test_basics.py | 48 ++++++++++++++++++++------- 70 files changed, 128 insertions(+), 85 deletions(-) diff --git a/nngt/__init__.py b/nngt/__init__.py index deef9c9..c2206ab 100644 --- a/nngt/__init__.py +++ b/nngt/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/__init__.py b/nngt/analysis/__init__.py index 70fb4f8..917ef86 100755 --- a/nngt/analysis/__init__.py +++ b/nngt/analysis/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/activity_analysis.py b/nngt/analysis/activity_analysis.py index 4da74c0..6df0c12 100755 --- a/nngt/analysis/activity_analysis.py +++ b/nngt/analysis/activity_analysis.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/bayesian_blocks.py b/nngt/analysis/bayesian_blocks.py index 26da06f..e7a3e94 100644 --- a/nngt/analysis/bayesian_blocks.py +++ b/nngt/analysis/bayesian_blocks.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/clustering.py b/nngt/analysis/clustering.py index 72d242d..18df65e 100644 --- a/nngt/analysis/clustering.py +++ b/nngt/analysis/clustering.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/graph_analysis.py b/nngt/analysis/graph_analysis.py index e39e73a..e73fa50 100755 --- a/nngt/analysis/graph_analysis.py +++ b/nngt/analysis/graph_analysis.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/gt_functions.py b/nngt/analysis/gt_functions.py index 8c72de3..bca4063 100644 --- a/nngt/analysis/gt_functions.py +++ b/nngt/analysis/gt_functions.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/ig_functions.py b/nngt/analysis/ig_functions.py index fc619bc..85d19c3 100644 --- a/nngt/analysis/ig_functions.py +++ b/nngt/analysis/ig_functions.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/nngt_functions.py b/nngt/analysis/nngt_functions.py index fb72764..a9da435 100644 --- a/nngt/analysis/nngt_functions.py +++ b/nngt/analysis/nngt_functions.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/analysis/nx_functions.py b/nngt/analysis/nx_functions.py index c17d8b9..a003d3b 100644 --- a/nngt/analysis/nx_functions.py +++ b/nngt/analysis/nx_functions.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/__init__.py b/nngt/core/__init__.py index af8a038..a2b33fb 100755 --- a/nngt/core/__init__.py +++ b/nngt/core/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/connections.py b/nngt/core/connections.py index 7bc5646..004bdd0 100644 --- a/nngt/core/connections.py +++ b/nngt/core/connections.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/graph.py b/nngt/core/graph.py index 718526c..a2be4d3 100644 --- a/nngt/core/graph.py +++ b/nngt/core/graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1239,12 +1239,31 @@ class Graph(nngt.core.GraphObject): raise InvalidArgument( "Unknown attribute class '{}'.".format(attribute_class)) - def get_density(self): + def get_density(self, ignore_loops=True): ''' - Density of the graph: :math:`\\frac{E}{N^2}`, where `E` is the number - of edges and `N` the number of nodes. + Density of the graph. + + Parameters + ---------- + ignore_loops : bool, optional (default: True) + Whether self-loops should be considered. + + Note + ---- + + The density is computed via :math:`(2 - d)\\frac{E}{N(N - 1)}` if + `ignore_loops` is True, or via :math:`\\frac{E}{N(N - 1) / (2 - d) + N}` + if it is False. + `E` is the number of edges, `N` the number of nodes, and `d` is 0 if + the graph is undirected and 1 if it is directed. ''' - return self.edge_nb() / self.node_nb()**2 + E = self.edge_nb() + N = self.node_nb() + + if ignore_loops: + return E / (N * (N - 1) / (2 - self.is_directed()) + N) + + return (2 - self.is_directed()) * E / (N * (N - 1)) def is_weighted(self): ''' Whether the edges have weights ''' diff --git a/nngt/core/graph_interface.py b/nngt/core/graph_interface.py index efd9113..a21e898 100644 --- a/nngt/core/graph_interface.py +++ b/nngt/core/graph_interface.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/group_structure.py b/nngt/core/group_structure.py index 2192874..fd75bd7 100644 --- a/nngt/core/group_structure.py +++ b/nngt/core/group_structure.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/gt_graph.py b/nngt/core/gt_graph.py index 0dbccc9..ea37553 100755 --- a/nngt/core/gt_graph.py +++ b/nngt/core/gt_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/ig_graph.py b/nngt/core/ig_graph.py index 2c681c3..0086da5 100755 --- a/nngt/core/ig_graph.py +++ b/nngt/core/ig_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/networks.py b/nngt/core/networks.py index f008e0d..785ef34 100644 --- a/nngt/core/networks.py +++ b/nngt/core/networks.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/neural_pop_group.py b/nngt/core/neural_pop_group.py index 9218d14..6bb6194 100644 --- a/nngt/core/neural_pop_group.py +++ b/nngt/core/neural_pop_group.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/nngt_graph.py b/nngt/core/nngt_graph.py index 8d0238f..c2a3e45 100644 --- a/nngt/core/nngt_graph.py +++ b/nngt/core/nngt_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/nx_graph.py b/nngt/core/nx_graph.py index 0e69ab7..c052d87 100755 --- a/nngt/core/nx_graph.py +++ b/nngt/core/nx_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/core/spatial_graph.py b/nngt/core/spatial_graph.py index b5e7ed2..69b107b 100644 --- a/nngt/core/spatial_graph.py +++ b/nngt/core/spatial_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/database/__init__.py b/nngt/database/__init__.py index b60a215..f08d7f5 100755 --- a/nngt/database/__init__.py +++ b/nngt/database/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/database/csv_utils.py b/nngt/database/csv_utils.py index 37fd261..08d148f 100644 --- a/nngt/database/csv_utils.py +++ b/nngt/database/csv_utils.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/database/db_generation.py b/nngt/database/db_generation.py index 58e0b07..54d850c 100755 --- a/nngt/database/db_generation.py +++ b/nngt/database/db_generation.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/database/db_main.py b/nngt/database/db_main.py index 558cbe4..13a2630 100755 --- a/nngt/database/db_main.py +++ b/nngt/database/db_main.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/database/pickle_field.py b/nngt/database/pickle_field.py index 6f5197a..3d7224e 100644 --- a/nngt/database/pickle_field.py +++ b/nngt/database/pickle_field.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/__init__.py b/nngt/generation/__init__.py index 7addd7d..0848d62 100755 --- a/nngt/generation/__init__.py +++ b/nngt/generation/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/connect_algorithms.py b/nngt/generation/connect_algorithms.py index 3d6e6ac..da8e9f1 100644 --- a/nngt/generation/connect_algorithms.py +++ b/nngt/generation/connect_algorithms.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/connectors.py b/nngt/generation/connectors.py index 070f058..3729afd 100644 --- a/nngt/generation/connectors.py +++ b/nngt/generation/connectors.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/graph_connectivity.py b/nngt/generation/graph_connectivity.py index b2fffdb..78c1ce4 100755 --- a/nngt/generation/graph_connectivity.py +++ b/nngt/generation/graph_connectivity.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/mpi_connect.py b/nngt/generation/mpi_connect.py index 1e4e582..00e585b 100644 --- a/nngt/generation/mpi_connect.py +++ b/nngt/generation/mpi_connect.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/generation/rewiring.py b/nngt/generation/rewiring.py index a9f3035..8a00c7e 100644 --- a/nngt/generation/rewiring.py +++ b/nngt/generation/rewiring.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/geospatial/__init__.py b/nngt/geospatial/__init__.py index 7295b0f..b5804ed 100644 --- a/nngt/geospatial/__init__.py +++ b/nngt/geospatial/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/geospatial/_cartopy_ne.py b/nngt/geospatial/_cartopy_ne.py index 228f483..bb33cda 100644 --- a/nngt/geospatial/_cartopy_ne.py +++ b/nngt/geospatial/_cartopy_ne.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/geospatial/countries.py b/nngt/geospatial/countries.py index 13ff5f4..3a09984 100644 --- a/nngt/geospatial/countries.py +++ b/nngt/geospatial/countries.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/geospatial/plot.py b/nngt/geospatial/plot.py index abcbb53..b825124 100644 --- a/nngt/geospatial/plot.py +++ b/nngt/geospatial/plot.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/__init__.py b/nngt/io/__init__.py index c2781b7..9b3283a 100755 --- a/nngt/io/__init__.py +++ b/nngt/io/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/graph_loading.py b/nngt/io/graph_loading.py index b03d774..f81e9b2 100755 --- a/nngt/io/graph_loading.py +++ b/nngt/io/graph_loading.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/graph_saving.py b/nngt/io/graph_saving.py index c538936..6b4777c 100755 --- a/nngt/io/graph_saving.py +++ b/nngt/io/graph_saving.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/io_helpers.py b/nngt/io/io_helpers.py index fc015ec..fd9cbe4 100755 --- a/nngt/io/io_helpers.py +++ b/nngt/io/io_helpers.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/loading_helpers.py b/nngt/io/loading_helpers.py index 672a998..21592ad 100755 --- a/nngt/io/loading_helpers.py +++ b/nngt/io/loading_helpers.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/io/saving_helpers.py b/nngt/io/saving_helpers.py index bd6e550..6a9d6d9 100755 --- a/nngt/io/saving_helpers.py +++ b/nngt/io/saving_helpers.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/__init__.py b/nngt/lib/__init__.py index 0ea574a..ae68704 100755 --- a/nngt/lib/__init__.py +++ b/nngt/lib/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/_frozendict.py b/nngt/lib/_frozendict.py index 04dfa9b..d128ea0 100644 --- a/nngt/lib/_frozendict.py +++ b/nngt/lib/_frozendict.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/connect_tools.py b/nngt/lib/connect_tools.py index 5ad5dd0..57714a5 100755 --- a/nngt/lib/connect_tools.py +++ b/nngt/lib/connect_tools.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/constants.py b/nngt/lib/constants.py index 73ddeb2..8a16022 100644 --- a/nngt/lib/constants.py +++ b/nngt/lib/constants.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/converters.py b/nngt/lib/converters.py index 97b6b73..b44112c 100755 --- a/nngt/lib/converters.py +++ b/nngt/lib/converters.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/db_tools.py b/nngt/lib/db_tools.py index 633b4fb..5d6b2a6 100755 --- a/nngt/lib/db_tools.py +++ b/nngt/lib/db_tools.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/decorator.py b/nngt/lib/decorator.py index 3b29e12..3d7ea5f 100644 --- a/nngt/lib/decorator.py +++ b/nngt/lib/decorator.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/errors.py b/nngt/lib/errors.py index 61dbc87..0b908f3 100755 --- a/nngt/lib/errors.py +++ b/nngt/lib/errors.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/graph_backends.py b/nngt/lib/graph_backends.py index 93946c2..403e685 100755 --- a/nngt/lib/graph_backends.py +++ b/nngt/lib/graph_backends.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/graph_helpers.py b/nngt/lib/graph_helpers.py index d730570..6b1d229 100755 --- a/nngt/lib/graph_helpers.py +++ b/nngt/lib/graph_helpers.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/logger.py b/nngt/lib/logger.py index 5482634..2a229ca 100755 --- a/nngt/lib/logger.py +++ b/nngt/lib/logger.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/nngt_config.py b/nngt/lib/nngt_config.py index 444a1ed..8ab6e39 100644 --- a/nngt/lib/nngt_config.py +++ b/nngt/lib/nngt_config.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/rng_tools.py b/nngt/lib/rng_tools.py index 8811c6a..bda24f7 100755 --- a/nngt/lib/rng_tools.py +++ b/nngt/lib/rng_tools.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/sorting.py b/nngt/lib/sorting.py index d42c9b7..c9a7f2c 100755 --- a/nngt/lib/sorting.py +++ b/nngt/lib/sorting.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/lib/test_functions.py b/nngt/lib/test_functions.py index acdc7c7..719f99a 100755 --- a/nngt/lib/test_functions.py +++ b/nngt/lib/test_functions.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/__init__.py b/nngt/plot/__init__.py index 3279883..78467ee 100755 --- a/nngt/plot/__init__.py +++ b/nngt/plot/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/animations.py b/nngt/plot/animations.py index a58bb08..fa70f48 100755 --- a/nngt/plot/animations.py +++ b/nngt/plot/animations.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/custom_plt.py b/nngt/plot/custom_plt.py index 7be3fef..d74e94a 100755 --- a/nngt/plot/custom_plt.py +++ b/nngt/plot/custom_plt.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/hive_helpers.py b/nngt/plot/hive_helpers.py index 5a84394..4302d5b 100755 --- a/nngt/plot/hive_helpers.py +++ b/nngt/plot/hive_helpers.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/plt_networks.py b/nngt/plot/plt_networks.py index 669c995..03e4b4b 100755 --- a/nngt/plot/plt_networks.py +++ b/nngt/plot/plt_networks.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/plot/plt_properties.py b/nngt/plot/plt_properties.py index c294fcc..a332a24 100755 --- a/nngt/plot/plt_properties.py +++ b/nngt/plot/plt_properties.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/simulation/__init__.py b/nngt/simulation/__init__.py index a2c556c..810f9f1 100755 --- a/nngt/simulation/__init__.py +++ b/nngt/simulation/__init__.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/simulation/nest_activity.py b/nngt/simulation/nest_activity.py index 33c6b85..f88be65 100755 --- a/nngt/simulation/nest_activity.py +++ b/nngt/simulation/nest_activity.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/simulation/nest_graph.py b/nngt/simulation/nest_graph.py index 560fee4..04974ba 100755 --- a/nngt/simulation/nest_graph.py +++ b/nngt/simulation/nest_graph.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/simulation/nest_plot.py b/nngt/simulation/nest_plot.py index 892b33e..6aa63d2 100755 --- a/nngt/simulation/nest_plot.py +++ b/nngt/simulation/nest_plot.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/nngt/simulation/nest_utils.py b/nngt/simulation/nest_utils.py index 73307b8..baa6825 100755 --- a/nngt/simulation/nest_utils.py +++ b/nngt/simulation/nest_utils.py @@ -6,7 +6,7 @@ # and reproducible graph analysis: generate and analyze networks with your # favorite graph library (graph-tool/igraph/networkx) on any platform, without # any change to your code. -# Copyright (C) 2015-2021 Tanguy Fardet +# Copyright (C) 2015-2022 Tanguy Fardet # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/testing/test_basics.py b/testing/test_basics.py index 87fd90c..8dad5b8 100755 --- a/testing/test_basics.py +++ b/testing/test_basics.py @@ -816,23 +816,47 @@ def test_to_undirected(): assert np.array_equal(u.adjacency_matrix().todense(), m) +@pytest.mark.mpi_skip +def test_density(): + # directed + num_nodes = 3 + g = nngt.Graph(num_nodes) + + edges = [(0, 1), (1, 2), (2, 0)] + + g.new_edges(edges) + + assert np.isclose(g.get_density(ignore_loops=True), 1/3) + assert np.isclose(g.get_density(ignore_loops=False), 0.5) + + # undirected + g = nngt.Graph(num_nodes, directed=False) + + edges = [(0, 1), (1, 2), (2, 0)] + + g.new_edges(edges) + + assert np.isclose(g.get_density(ignore_loops=True), 0.5) + assert np.isclose(g.get_density(ignore_loops=False), 1) + # ---------- # # Test suite # # ---------- # if __name__ == "__main__": - test_directed_adjacency() - test_undirected_adjacency() - test_config() - test_new_node_attr() - test_graph_copy() - test_degrees_neighbors() - test_get_edges() - test_to_undirected() + # test_directed_adjacency() + # test_undirected_adjacency() + # test_config() + # test_new_node_attr() + # test_graph_copy() + # test_degrees_neighbors() + # test_get_edges() + # test_to_undirected() if not nngt.get_config('mpi'): - test_node_creation() - test_edge_creation() - test_has_edges_edge_id() - test_delete() + # test_node_creation() + # test_edge_creation() + # test_has_edges_edge_id() + # test_delete() + test_density() -- 2.32.0
builds.sr.ht <builds@sr.ht>NNGT/patches/.build.yml: SUCCESS in 27m43s [Bugfix: undirected density, support with/without loops][0] from [~tfardet][1] [0]: https://lists.sr.ht/~tfardet/nngt-developers/patches/29079 [1]: mailto:tanguyfardet@protonmail.com ✓ #688297 SUCCESS NNGT/patches/.build.yml https://builds.sr.ht/~tfardet/job/688297