risk-network 0.0.8b0__tar.gz → 0.0.8b1__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.
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/PKG-INFO +1 -1
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/__init__.py +1 -1
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/io.py +42 -6
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/PKG-INFO +1 -1
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/LICENSE +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/MANIFEST.in +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/README.md +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/pyproject.toml +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/annotations.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/io.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/constants.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/config.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/params.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/community.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/domains.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/neighborhoods.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/geometry.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/graph.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/plot.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/risk.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/hypergeom.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/__init__.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/permutation.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/test_functions.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/poisson.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/stats.py +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/SOURCES.txt +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/dependency_links.txt +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/requires.txt +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/top_level.txt +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/setup.cfg +0 -0
- {risk_network-0.0.8b0 → risk_network-0.0.8b1}/setup.py +0 -0
@@ -153,8 +153,10 @@ class NetworkIO:
|
|
153
153
|
params.log_network(filetype=filetype)
|
154
154
|
self._log_loading(filetype)
|
155
155
|
|
156
|
+
# Important: Make a copy of the network to avoid modifying the original
|
157
|
+
network_copy = network.copy()
|
156
158
|
# Initialize the graph
|
157
|
-
return self._initialize_graph(
|
159
|
+
return self._initialize_graph(network_copy)
|
158
160
|
|
159
161
|
@staticmethod
|
160
162
|
def load_cytoscape_network(
|
@@ -475,16 +477,50 @@ class NetworkIO:
|
|
475
477
|
logger.debug(f"Total edges missing weights: {missing_weights}")
|
476
478
|
|
477
479
|
def _validate_nodes(self, G: nx.Graph) -> None:
|
478
|
-
"""Validate the graph structure and attributes.
|
480
|
+
"""Validate the graph structure and attributes with attribute fallback for positions and labels.
|
479
481
|
|
480
482
|
Args:
|
481
483
|
G (nx.Graph): A NetworkX graph object.
|
482
484
|
"""
|
485
|
+
# Keep track of nodes missing labels
|
486
|
+
nodes_with_missing_labels = []
|
487
|
+
|
483
488
|
for node, attrs in G.nodes(data=True):
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
489
|
+
# Attribute fallback for 'x' and 'y' attributes
|
490
|
+
if "x" not in attrs or "y" not in attrs:
|
491
|
+
if (
|
492
|
+
"pos" in attrs
|
493
|
+
and isinstance(attrs["pos"], (tuple, list))
|
494
|
+
and len(attrs["pos"]) >= 2
|
495
|
+
):
|
496
|
+
attrs["x"], attrs["y"] = attrs["pos"][
|
497
|
+
:2
|
498
|
+
] # Use only x and y, ignoring z if present
|
499
|
+
else:
|
500
|
+
raise ValueError(
|
501
|
+
f"Node {node} is missing 'x', 'y', and a valid 'pos' attribute."
|
502
|
+
)
|
503
|
+
|
504
|
+
# Attribute fallback for 'label' attribute
|
505
|
+
if "label" not in attrs:
|
506
|
+
# Try alternative attribute names for label
|
507
|
+
if "name" in attrs:
|
508
|
+
attrs["label"] = attrs["name"]
|
509
|
+
elif "id" in attrs:
|
510
|
+
attrs["label"] = attrs["id"]
|
511
|
+
else:
|
512
|
+
# Collect nodes with missing labels
|
513
|
+
nodes_with_missing_labels.append(node)
|
514
|
+
attrs["label"] = str(node) # Use node ID as the label
|
515
|
+
|
516
|
+
# Issue a single warning if any labels were missing
|
517
|
+
if nodes_with_missing_labels:
|
518
|
+
total_nodes = len(G.nodes)
|
519
|
+
fraction_missing_labels = len(nodes_with_missing_labels) / total_nodes
|
520
|
+
logger.warning(
|
521
|
+
f"{len(nodes_with_missing_labels)} out of {total_nodes} nodes "
|
522
|
+
f"({fraction_missing_labels:.2%}) were missing 'label' attributes and were assigned node IDs."
|
523
|
+
)
|
488
524
|
|
489
525
|
def _assign_edge_lengths(self, G: nx.Graph) -> None:
|
490
526
|
"""Prepare the network by adjusting surface depth and calculating edge lengths.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|