modularitypruning 1.4.1__tar.gz → 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/PKG-INFO +9 -8
  2. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/modularitypruning.egg-info/PKG-INFO +9 -8
  3. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/modularitypruning.egg-info/SOURCES.txt +1 -1
  4. modularitypruning-1.5.1/pyproject.toml +48 -0
  5. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_monolayer_parameter_estimation.py +2 -2
  6. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_temporal_multilevel_parameter_estimation.py +52 -15
  7. modularitypruning-1.4.1/setup.py +0 -39
  8. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/LICENSE +0 -0
  9. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/README.md +0 -0
  10. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/modularitypruning.egg-info/dependency_links.txt +0 -0
  11. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/modularitypruning.egg-info/requires.txt +0 -0
  12. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/modularitypruning.egg-info/top_level.txt +0 -0
  13. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/setup.cfg +0 -0
  14. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_champ_coefficients_2D.py +0 -0
  15. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_champ_coefficients_3D.py +0 -0
  16. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_champ_usage_2D.py +0 -0
  17. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_champ_usage_3D.py +0 -0
  18. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_deprecated_louvain_names.py +0 -0
  19. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_documentation_examples.py +0 -0
  20. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_multiplex_parameter_estimation.py +0 -0
  21. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/tests/test_parallel_leiden_performance.py +0 -0
  22. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/__init__.py +0 -0
  23. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/champ_utilities.py +0 -0
  24. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/leiden_utilities.py +0 -0
  25. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/louvain_utilities.py +0 -0
  26. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/parameter_estimation.py +0 -0
  27. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/parameter_estimation_utilities.py +0 -0
  28. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/partition_utilities.py +0 -0
  29. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/plotting.py +0 -0
  30. {modularitypruning-1.4.1 → modularitypruning-1.5.1}/utilities/progress.py +0 -0
@@ -1,21 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: modularitypruning
3
- Version: 1.4.1
3
+ Version: 1.5.1
4
4
  Summary: Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.
5
- Home-page: https://github.com/ragibson/ModularityPruning
6
- Author: Ryan Gibson
7
- Author-email: ryan.alex.gibson@gmail.com
5
+ Author-email: Ryan Gibson <ryan.alex.gibson@gmail.com>
6
+ License-Expression: MIT
8
7
  Classifier: Development Status :: 5 - Production/Stable
9
8
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
10
9
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.8
12
10
  Classifier: Programming Language :: Python :: 3.9
13
11
  Classifier: Programming Language :: Python :: 3.10
14
12
  Classifier: Programming Language :: Python :: 3.11
15
13
  Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
16
17
  Classifier: Programming Language :: Python :: 3 :: Only
17
- Classifier: License :: OSI Approved :: MIT License
18
- Requires-Python: >=3.8, <4
18
+ Requires-Python: >=3.9
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: leidenalg
@@ -27,6 +27,7 @@ Requires-Dist: scikit-learn
27
27
  Requires-Dist: scipy>=1.7
28
28
  Requires-Dist: seaborn
29
29
  Requires-Dist: tqdm
30
+ Dynamic: license-file
30
31
 
31
32
  # ModularityPruning
32
33
 
@@ -1,21 +1,21 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: modularitypruning
3
- Version: 1.4.1
3
+ Version: 1.5.1
4
4
  Summary: Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference.
5
- Home-page: https://github.com/ragibson/ModularityPruning
6
- Author: Ryan Gibson
7
- Author-email: ryan.alex.gibson@gmail.com
5
+ Author-email: Ryan Gibson <ryan.alex.gibson@gmail.com>
6
+ License-Expression: MIT
8
7
  Classifier: Development Status :: 5 - Production/Stable
9
8
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
10
9
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.8
12
10
  Classifier: Programming Language :: Python :: 3.9
13
11
  Classifier: Programming Language :: Python :: 3.10
14
12
  Classifier: Programming Language :: Python :: 3.11
15
13
  Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Programming Language :: Python :: 3.15
16
17
  Classifier: Programming Language :: Python :: 3 :: Only
17
- Classifier: License :: OSI Approved :: MIT License
18
- Requires-Python: >=3.8, <4
18
+ Requires-Python: >=3.9
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: leidenalg
@@ -27,6 +27,7 @@ Requires-Dist: scikit-learn
27
27
  Requires-Dist: scipy>=1.7
28
28
  Requires-Dist: seaborn
29
29
  Requires-Dist: tqdm
30
+ Dynamic: license-file
30
31
 
31
32
  # ModularityPruning
32
33
 
@@ -1,6 +1,6 @@
1
1
  LICENSE
2
2
  README.md
3
- setup.py
3
+ pyproject.toml
4
4
  modularitypruning.egg-info/PKG-INFO
5
5
  modularitypruning.egg-info/SOURCES.txt
6
6
  modularitypruning.egg-info/dependency_links.txt
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 75.3.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "modularitypruning"
7
+ version = "1.5.1"
8
+ description = "Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Ryan Gibson", email = "ryan.alex.gibson@gmail.com" }
14
+ ]
15
+
16
+ classifiers = [
17
+ "Development Status :: 5 - Production/Stable",
18
+ "Topic :: Scientific/Engineering :: Information Analysis",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Programming Language :: Python :: 3.15",
27
+ "Programming Language :: Python :: 3 :: Only"
28
+ ]
29
+ dependencies = [
30
+ "leidenalg",
31
+ "matplotlib",
32
+ "numpy",
33
+ "psutil",
34
+ "igraph",
35
+ "scikit-learn",
36
+ "scipy>=1.7",
37
+ "seaborn",
38
+ "tqdm"
39
+ ]
40
+
41
+ [tool.setuptools]
42
+ packages = ["modularitypruning"]
43
+
44
+ [tool.setuptools.package-dir]
45
+ modularitypruning = "utilities"
46
+
47
+ [tool.autopep8]
48
+ max_line_length = 120
@@ -21,11 +21,11 @@ class TestMonolayerParameterEstimation(unittest.TestCase):
21
21
 
22
22
  for q in range(3, 15):
23
23
  community_sizes = [250] * q # q equally sized groups of 250 nodes
24
- n = 250 * q
24
+ n = sum(community_sizes)
25
25
  p_in = 16 * n / (q * 250 * 249) # ~16 in-edges per node
26
26
  p_out = 8 * n / (q * (q - 1) * 250 * 250) # ~8 out-edges per node to each community
27
27
  pref_matrix = [[p_in if i == j else p_out for j in range(q)] for i in range(q)]
28
- G = ig.Graph.SBM(n, pref_matrix, community_sizes)
28
+ G = ig.Graph.SBM(pref_matrix, community_sizes)
29
29
 
30
30
  # compute "ground truth" gamma estimate
31
31
  k = mean(all_degrees(G))
@@ -27,7 +27,7 @@ class TestTemporalAndMultilevelParameterEstimation(unittest.TestCase):
27
27
  return G_intralayer, G_interlayer, layer_membership
28
28
 
29
29
  def assert_temporal_SBM_correct_convergence(self, first_layer_membership, copying_probability=0.75, num_layers=25,
30
- p_in=0.25, p_out=0.05):
30
+ p_in=0.25, p_out=0.05, tolerance=0.1):
31
31
  K = num_communities(first_layer_membership)
32
32
  G_intralayer, G_interlayer, layer_membership = self.generate_temporal_SBM(copying_probability, p_in, p_out,
33
33
  first_layer_membership,
@@ -49,41 +49,78 @@ class TestTemporalAndMultilevelParameterEstimation(unittest.TestCase):
49
49
  model='temporal')
50
50
 
51
51
  # check we converged close to the ground truth "correct" values
52
- self.assertLess(abs(true_gamma - gamma), 0.05)
53
- self.assertLess(abs(true_omega - omega), 0.1)
52
+ self.assertLess(abs(true_gamma - gamma), tolerance)
53
+ self.assertLess(abs(true_omega - omega), tolerance)
54
54
 
55
55
  # check multilevel parameter estimation as well
56
56
  # we never use this model, but it is a slight generalization of the temporal one
57
57
  gamma, omega, _ = iterative_multilayer_resolution_parameter_estimation(G_intralayer, G_interlayer,
58
58
  layer_membership, gamma=1.0, omega=1.0,
59
59
  model='multilevel')
60
- self.assertLess(abs(true_gamma - gamma), 0.05)
61
- self.assertLess(abs(true_omega - omega), 0.1)
60
+ self.assertLess(abs(true_gamma - gamma), tolerance)
61
+ self.assertLess(abs(true_omega - omega), tolerance)
62
+
63
+ def retry_test_across_graph_sizes(self, test_fn, sizes=[50, 100, 250, 500], retries_per_size=3):
64
+ """
65
+ Rerun randomized tests of asymptotic convergence across increasingly larger graph sizes until one succeeds.
66
+
67
+ This improves the performance of the test suite by automatically using smaller graphs for "easier" tests.
68
+ """
69
+ last_error = None
70
+ for n in sizes:
71
+ for _ in range(retries_per_size):
72
+ try:
73
+ test_fn(n)
74
+ return
75
+ except Exception as e:
76
+ last_error = e
77
+ if not isinstance(e, AssertionError):
78
+ # test failed in unusual way (perhaps keyboard interrupt?), raising immediately
79
+ raise e
80
+ raise last_error
62
81
 
63
82
  def test_temporal_SBM_correct_convergence_varying_copying_probabilty(self):
64
83
  for eta in [0.25, 0.5, 0.75, 0.9]:
65
- membership = generate_random_partition(num_nodes=200, K=2)
66
- self.assert_temporal_SBM_correct_convergence(copying_probability=eta, first_layer_membership=membership)
84
+ self.retry_test_across_graph_sizes(
85
+ test_fn=lambda n: self.assert_temporal_SBM_correct_convergence(
86
+ copying_probability=eta,
87
+ first_layer_membership=generate_random_partition(num_nodes=n, K=2)
88
+ )
89
+ )
67
90
 
68
91
  def test_temporal_SBM_correct_convergence_varying_p_in(self):
69
92
  for p_in in [0.5, 0.4, 0.3, 0.2]:
70
- membership = generate_random_partition(num_nodes=100, K=2)
71
- self.assert_temporal_SBM_correct_convergence(p_in=p_in, p_out=0.025, first_layer_membership=membership)
93
+ self.retry_test_across_graph_sizes(
94
+ test_fn=lambda n: self.assert_temporal_SBM_correct_convergence(
95
+ p_in=p_in, p_out=0.025,
96
+ first_layer_membership=generate_random_partition(num_nodes=n, K=2)
97
+ )
98
+ )
72
99
 
73
100
  def test_temporal_SBM_correct_convergence_varying_p_out(self):
74
101
  for p_out in [0.05, 0.04, 0.03, 0.02]:
75
- membership = generate_random_partition(num_nodes=100, K=2)
76
- self.assert_temporal_SBM_correct_convergence(p_out=p_out, first_layer_membership=membership)
102
+ self.retry_test_across_graph_sizes(
103
+ test_fn=lambda n: self.assert_temporal_SBM_correct_convergence(
104
+ p_out=p_out, first_layer_membership=generate_random_partition(num_nodes=n, K=2)
105
+ )
106
+ )
77
107
 
78
108
  def test_temporal_SBM_correct_convergence_varying_num_communities(self):
79
109
  for K in [2, 3, 4, 5]:
80
- membership = generate_random_partition(num_nodes=500, K=K)
81
- self.assert_temporal_SBM_correct_convergence(first_layer_membership=membership)
110
+ self.retry_test_across_graph_sizes(
111
+ test_fn=lambda n: self.assert_temporal_SBM_correct_convergence(
112
+ first_layer_membership=generate_random_partition(num_nodes=n, K=K)
113
+ )
114
+ )
82
115
 
83
116
  def test_temporal_SBM_correct_convergence_varying_num_layers(self):
84
117
  for num_layers in [20, 30, 40]:
85
- membership = generate_random_partition(num_nodes=100, K=2)
86
- self.assert_temporal_SBM_correct_convergence(first_layer_membership=membership, num_layers=num_layers)
118
+ self.retry_test_across_graph_sizes(
119
+ test_fn=lambda n: self.assert_temporal_SBM_correct_convergence(
120
+ num_layers=num_layers,
121
+ first_layer_membership=generate_random_partition(num_nodes=n, K=2)
122
+ )
123
+ )
87
124
 
88
125
  def test_directed_consistency_temporal_SBM_leiden(self):
89
126
  """Test parameter estimate consistency on a temporal SBM when the intralayer edges are directed."""
@@ -1,39 +0,0 @@
1
- import os
2
-
3
- from setuptools import setup
4
-
5
- here = os.path.abspath(os.path.dirname(__file__))
6
-
7
- # Get the long description from the README file
8
- with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
9
- long_description = f.read()
10
-
11
- setup(
12
- name='modularitypruning',
13
- version='1.4.1',
14
- package_dir={'modularitypruning': 'utilities'},
15
- packages=['modularitypruning'],
16
- url='https://github.com/ragibson/ModularityPruning',
17
- license='',
18
- author='Ryan Gibson',
19
- author_email='ryan.alex.gibson@gmail.com',
20
- description='Pruning tool to identify small subsets of network partitions that are '
21
- 'significant from the perspective of stochastic block model inference.',
22
- long_description=long_description,
23
- long_description_content_type='text/markdown',
24
- classifiers=[
25
- 'Development Status :: 5 - Production/Stable',
26
- 'Topic :: Scientific/Engineering :: Information Analysis',
27
- 'Programming Language :: Python :: 3',
28
- 'Programming Language :: Python :: 3.8',
29
- 'Programming Language :: Python :: 3.9',
30
- 'Programming Language :: Python :: 3.10',
31
- 'Programming Language :: Python :: 3.11',
32
- 'Programming Language :: Python :: 3.12',
33
- 'Programming Language :: Python :: 3 :: Only',
34
- 'License :: OSI Approved :: MIT License'
35
- ],
36
- python_requires='>=3.8, <4',
37
- install_requires=['leidenalg', 'matplotlib', "numpy", 'psutil', 'igraph',
38
- "scikit-learn", "scipy>=1.7", 'seaborn', 'tqdm']
39
- )