risk-network 0.0.14b0__py3-none-any.whl → 0.0.14b2__py3-none-any.whl

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.
risk/__init__.py CHANGED
@@ -8,4 +8,4 @@ RISK: Regional Inference of Significant Kinships
8
8
  from ._risk import RISK
9
9
 
10
10
  __all__ = ["RISK"]
11
- __version__ = "0.0.14-beta.0"
11
+ __version__ = "0.0.14-beta.2"
@@ -29,9 +29,6 @@ class NeighborhoodsAPI:
29
29
  The NeighborhoodsAPI class provides methods to load neighborhood results from statistical tests.
30
30
  """
31
31
 
32
- def __init__(self) -> None:
33
- pass
34
-
35
32
  def load_neighborhoods_binom(
36
33
  self,
37
34
  network: nx.Graph,
@@ -27,9 +27,6 @@ class GraphAPI:
27
27
  The GraphAPI class provides methods to load and process network graphs, annotations, and neighborhoods.
28
28
  """
29
29
 
30
- def __init__(self) -> None:
31
- pass
32
-
33
30
  def load_graph(
34
31
  self,
35
32
  network: nx.Graph,
risk/_network/_io.py CHANGED
@@ -24,24 +24,6 @@ class NetworkAPI:
24
24
  Delegates to the NetworkIO worker class for actual I/O and processing.
25
25
  """
26
26
 
27
- def __init__(
28
- self,
29
- compute_sphere: bool = True,
30
- surface_depth: float = 0.0,
31
- min_edges_per_node: int = 0,
32
- ):
33
- """
34
- Initialize the NetworkAPI.
35
-
36
- Args:
37
- compute_sphere (bool): Whether to map nodes to a sphere. Defaults to True.
38
- surface_depth (float): Surface depth for the sphere. Defaults to 0.0.
39
- min_edges_per_node (int): Minimum number of edges per node. Defaults to 0.
40
- """
41
- self.compute_sphere = compute_sphere
42
- self.surface_depth = surface_depth
43
- self.min_edges_per_node = min_edges_per_node
44
-
45
27
  def load_network_gpickle(
46
28
  self,
47
29
  filepath: str,
@@ -182,7 +164,7 @@ class NetworkIO:
182
164
  Args:
183
165
  compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
184
166
  surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
185
- min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
167
+ min_edges_per_node (int, optional): Minimum number of edges per node (k-core threshold). Defaults to 0.
186
168
  """
187
169
  self.compute_sphere = compute_sphere
188
170
  self.surface_depth = surface_depth
@@ -458,20 +440,14 @@ class NetworkIO:
458
440
  num_initial_edges = G.number_of_edges()
459
441
  # Remove self-loops to ensure correct edge count
460
442
  G.remove_edges_from(nx.selfloop_edges(G))
461
- # Iteratively remove nodes with fewer edges than the threshold
462
- while True:
463
- nodes_to_remove = [
464
- node
465
- for node, degree in dict(G.degree()).items()
466
- if degree < self.min_edges_per_node
467
- ]
468
- if not nodes_to_remove:
469
- break # Exit loop if no nodes meet the condition
470
- G.remove_nodes_from(nodes_to_remove)
471
-
472
- # Remove isolated nodes
473
- isolates = list(nx.isolates(G))
474
- G.remove_nodes_from(isolates)
443
+ # Apply canonical node k-core pruning if requested
444
+ if self.min_edges_per_node > 0:
445
+ # networkx.k_core returns a subgraph; to preserve in-place behavior, copy back
446
+ core = nx.k_core(G, k=self.min_edges_per_node)
447
+ # Rebuild G in-place to keep external references valid
448
+ G.clear()
449
+ G.add_nodes_from(core.nodes(data=True))
450
+ G.add_edges_from(core.edges(data=True))
475
451
 
476
452
  # Log the number of nodes and edges before and after cleaning
477
453
  num_final_nodes = G.number_of_nodes()
@@ -19,9 +19,6 @@ class PlotterAPI:
19
19
  The PlotterAPI class provides methods to load and configure Plotter objects for plotting network graphs.
20
20
  """
21
21
 
22
- def __init__(self) -> None:
23
- pass
24
-
25
22
  def load_plotter(
26
23
  self,
27
24
  graph: Graph,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: risk-network
3
- Version: 0.0.14b0
3
+ Version: 0.0.14b2
4
4
  Summary: A Python package for scalable network analysis and high-quality visualization.
5
5
  Author-email: Ira Horecka <ira89@icloud.com>
6
6
  License: GPL-3.0-or-later
@@ -1,4 +1,4 @@
1
- risk/__init__.py,sha256=4gUMRlMdNJ2feLptoxyeWymcTnqlyoExMrazTwzyfrs,143
1
+ risk/__init__.py,sha256=Kit6ilMaj_3F16dnLJ_Dd7fE5jeZGmNqur97zzK7CRI,143
2
2
  risk/_risk.py,sha256=VULCdM41BlWKM1ou4Qc579ffZ9dMZkfhAwKYgbaEeKM,1054
3
3
  risk/_annotation/__init__.py,sha256=zr7w1DHkmvrkKFGKdPhrcvZHV-xsfd5TZOaWtFiP4Dc,164
4
4
  risk/_annotation/_annotation.py,sha256=03vcnkdi4HGH5UUyokUyOdyyjXOLoKSmLFuK7VAl41c,15174
@@ -8,7 +8,7 @@ risk/_log/__init__.py,sha256=LX6BsfcGOH0RbAdQaUmIU-LVMmArDdKwn0jFtj45FYo,205
8
8
  risk/_log/_console.py,sha256=1jSFzY3w0-vVqIBCgc-IhyJPNT6vRg8GSGxhyw_D9MI,4653
9
9
  risk/_log/_parameters.py,sha256=8FkeeBtULDFVw3UijLArK-G3OIjy6YXyRXmPPckK7fU,5893
10
10
  risk/_neighborhoods/__init__.py,sha256=eKwjpEUKSUmAirRZ_qPTVF7MLkvhCn_fulPVq158wM8,185
11
- risk/_neighborhoods/_api.py,sha256=6vt25y38wSvEhMvNxy9Rl-CrQc9ARSuvGwexWagg5z0,23344
11
+ risk/_neighborhoods/_api.py,sha256=s1f4d_nEPWc66KDmOUUpRNXzp6dfoevw45ewOg9eMNo,23298
12
12
  risk/_neighborhoods/_community.py,sha256=Tr-EHO91EWbMmNr_z21UCngiqWOlWIqcjwBig_VXI8c,17850
13
13
  risk/_neighborhoods/_domains.py,sha256=He8G2-E9-yYQB8ChUtMFr51HVlfRj5EaxGu3sGVNUCo,14630
14
14
  risk/_neighborhoods/_neighborhoods.py,sha256=9H7BickJx9GdnOo5d5wpdtXkcWyvzq2w6FAy1rwLBtk,20614
@@ -18,14 +18,14 @@ risk/_neighborhoods/_stats/_permutation/__init__.py,sha256=nfTaW29CK8OZCdFnpMVlH
18
18
  risk/_neighborhoods/_stats/_permutation/_permutation.py,sha256=e5qVuYWGhiAn5Jv8VILk-WYMOO4km48cGdRYTOl355M,10661
19
19
  risk/_neighborhoods/_stats/_permutation/_test_functions.py,sha256=lGI_MkdbW4UHI0jWN_T1OattRjXrq_qmzAmOfels670,3165
20
20
  risk/_network/__init__.py,sha256=YrAMfhL0CMWQb3sY-mn1VxK44zZAWeFAvHrBONH9I-A,127
21
- risk/_network/_io.py,sha256=uiYmbKVsSRr4-TsY9KvRggDghtZv8qoxXac3QYs1lTI,28750
21
+ risk/_network/_io.py,sha256=wmokwNViz24Gv6o3OFRTYHftYYz4sN64VigGrdEGzy8,28057
22
22
  risk/_network/_graph/__init__.py,sha256=SFgxgxUiZK4vvw6bdQ04DSMXEr8xjMaQV-Wne6wAIqM,104
23
- risk/_network/_graph/_api.py,sha256=zH7n-ulqLcbgHdAfLu1yWErdR5G4LgSqR7DcN2qApco,8520
23
+ risk/_network/_graph/_api.py,sha256=sp3_mLJDP_xQexYBjyM17iyzLb2oGmiC050kcw-jVho,8474
24
24
  risk/_network/_graph/_graph.py,sha256=x2EWT_ZVwxh7m9a01yG4WMdmAxBxiaxX3CvkqP9QAXE,12486
25
25
  risk/_network/_graph/_stats.py,sha256=6mxZkuL6LJlwKDsBbP22DAVkNUEhq-JZwYMKhFKD08k,7359
26
26
  risk/_network/_graph/_summary.py,sha256=4eGhCArssePDg4LXr3sg5bUpNn7KFK9oPZcCz5lJKEQ,10334
27
27
  risk/_network/_plotter/__init__.py,sha256=qFRtQKSBGIqmUGwmA7VPL7hTHBb9yvRIt0nLISXnwkY,84
28
- risk/_network/_plotter/_api.py,sha256=MHZIMTlul2u-Ve5m9r-eUljI2oC3IRklNn7AVlfmzGs,1773
28
+ risk/_network/_plotter/_api.py,sha256=OaV1CCRGsz98wEEzyEhaq2CqEuZh6t2qS7g_rY6HJJs,1727
29
29
  risk/_network/_plotter/_canvas.py,sha256=H7rPz4Gv7ED3bDHMif4cf2usdU4ifmxzXeug5A_no68,13599
30
30
  risk/_network/_plotter/_contour.py,sha256=E3ILjlv-VBSbK3ClwObB84TvP1D48_B47ODXwtApjIE,15557
31
31
  risk/_network/_plotter/_labels.py,sha256=8JXzEOIBQefwr1ngF-2ZYCnYLZXs2Erz-R1c28NnsL0,46915
@@ -34,8 +34,8 @@ risk/_network/_plotter/_plotter.py,sha256=F2hw-spUdsXjvuG36o0YFR3Pnd-CZOHYUq4vW0
34
34
  risk/_network/_plotter/_utils/__init__.py,sha256=JXgjKiBWvXx0X2IeFnrOh5YZQGQoELbhJZ0Zh2mFEOo,211
35
35
  risk/_network/_plotter/_utils/_colors.py,sha256=JCliSvz8_-TsjilaRHSEsqdXFBUYlzhXKOSRGdCm9Kw,19177
36
36
  risk/_network/_plotter/_utils/_layout.py,sha256=GyGLc2U1WWUVL1Te9uPi_CLqlW_E4TImXRAL5TeA5D8,3633
37
- risk_network-0.0.14b0.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
- risk_network-0.0.14b0.dist-info/METADATA,sha256=rshHTAf4wXudUsCwUIQpK8VZzmb5-f_c9_fYfrYXdm0,6853
39
- risk_network-0.0.14b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- risk_network-0.0.14b0.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
- risk_network-0.0.14b0.dist-info/RECORD,,
37
+ risk_network-0.0.14b2.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
+ risk_network-0.0.14b2.dist-info/METADATA,sha256=8Ymwky3eLiYB9OMO0kVzfF40uvnD3uFCBmY7q6pfitI,6853
39
+ risk_network-0.0.14b2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ risk_network-0.0.14b2.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
+ risk_network-0.0.14b2.dist-info/RECORD,,