risk-network 0.0.8b22__py3-none-any.whl → 0.0.8b23__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 +1 -1
- risk/network/plot/utils/layout.py +38 -0
- {risk_network-0.0.8b22.dist-info → risk_network-0.0.8b23.dist-info}/METADATA +1 -1
- {risk_network-0.0.8b22.dist-info → risk_network-0.0.8b23.dist-info}/RECORD +7 -7
- {risk_network-0.0.8b22.dist-info → risk_network-0.0.8b23.dist-info}/LICENSE +0 -0
- {risk_network-0.0.8b22.dist-info → risk_network-0.0.8b23.dist-info}/WHEEL +0 -0
- {risk_network-0.0.8b22.dist-info → risk_network-0.0.8b23.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
@@ -30,6 +30,44 @@ def calculate_bounding_box(
|
|
30
30
|
return center, radius
|
31
31
|
|
32
32
|
|
33
|
+
def refine_center_iteratively(
|
34
|
+
node_coordinates: np.ndarray,
|
35
|
+
radius_margin: float = 1.05,
|
36
|
+
max_iterations: int = 10,
|
37
|
+
tolerance: float = 1e-2,
|
38
|
+
) -> Tuple[np.ndarray, float]:
|
39
|
+
"""Refine the center of the graph iteratively to minimize skew in node distribution.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
node_coordinates (np.ndarray): Array of node coordinates (x, y).
|
43
|
+
radius_margin (float, optional): Margin factor to apply to the bounding box radius. Defaults to 1.05.
|
44
|
+
max_iterations (int, optional): Maximum number of iterations for refining the center. Defaults to 10.
|
45
|
+
tolerance (float, optional): Stopping tolerance for center adjustment. Defaults to 1e-2.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
tuple: Refined center and the final radius.
|
49
|
+
"""
|
50
|
+
# Initial center and radius based on the bounding box
|
51
|
+
center, radius = calculate_bounding_box(node_coordinates, radius_margin)
|
52
|
+
for _ in range(max_iterations):
|
53
|
+
# Shift the coordinates based on the current center
|
54
|
+
shifted_coordinates = node_coordinates - center
|
55
|
+
# Calculate skew (difference in distance from the center)
|
56
|
+
skew = np.mean(shifted_coordinates, axis=0)
|
57
|
+
# If skew is below tolerance, stop
|
58
|
+
if np.linalg.norm(skew) < tolerance:
|
59
|
+
break
|
60
|
+
|
61
|
+
# Adjust the center by moving it in the direction opposite to the skew
|
62
|
+
center += skew
|
63
|
+
|
64
|
+
# After refinement, recalculate the bounding radius
|
65
|
+
shifted_coordinates = node_coordinates - center
|
66
|
+
new_radius = np.max(np.linalg.norm(shifted_coordinates, axis=1)) * radius_margin
|
67
|
+
|
68
|
+
return center, new_radius
|
69
|
+
|
70
|
+
|
33
71
|
def calculate_centroids(network, domain_id_to_node_ids_map):
|
34
72
|
"""Calculate the centroid for each domain based on node x and y coordinates in the network.
|
35
73
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=t7Ysy06wQrCx89cCOIVl2tjIIhHYi4_PNQWAUTijJAU,113
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=rjV0hllegCX978QaUo175FworKxNXlhQEQaQAPjHqos,23397
|
4
4
|
risk/annotations/__init__.py,sha256=kXgadEXaCh0z8OyhOhTj7c3qXGmWgOhaSZ4gSzSb59U,147
|
@@ -22,7 +22,7 @@ risk/network/plot/labels.py,sha256=ozkqwhBOTHKJLaAz4dJopXuykAvssSZUer2W5V0x2jM,4
|
|
22
22
|
risk/network/plot/network.py,sha256=6RURL1OdBFyQ34qNcwM_uH3LSQGYZZ8tZT51dggH1a0,13685
|
23
23
|
risk/network/plot/plotter.py,sha256=iTPMiTnTTatM_-q1Ox_bjt5Pvv-Lo8gceiYB6TVzDcw,5770
|
24
24
|
risk/network/plot/utils/color.py,sha256=WSs1ge2oZ8yXwyVk2QqBF-avRd0aYT-sYZr9cxxAn7M,19626
|
25
|
-
risk/network/plot/utils/layout.py,sha256=
|
25
|
+
risk/network/plot/utils/layout.py,sha256=RnJq0yODpoheZnDl7KKFPQeXrnrsS3FLIdxupoYVZq4,3553
|
26
26
|
risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
|
27
27
|
risk/stats/hypergeom.py,sha256=oc39f02ViB1vQ-uaDrxG_tzAT6dxQBRjc88EK2EGn78,2282
|
28
28
|
risk/stats/poisson.py,sha256=polLgwS08MTCNzupYdmMUoEUYrJOjAbcYtYwjlfeE5Y,1803
|
@@ -30,8 +30,8 @@ risk/stats/stats.py,sha256=6iGi0-oN05mTmupg6X_VEBxEQvi2rujNhfPk4aLjwNI,7186
|
|
30
30
|
risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
|
31
31
|
risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
|
32
32
|
risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
|
33
|
-
risk_network-0.0.
|
34
|
-
risk_network-0.0.
|
35
|
-
risk_network-0.0.
|
36
|
-
risk_network-0.0.
|
37
|
-
risk_network-0.0.
|
33
|
+
risk_network-0.0.8b23.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
34
|
+
risk_network-0.0.8b23.dist-info/METADATA,sha256=NcDzE6PKoco47jMvWySV2Xnu8abFT5I03KI-KNGqARk,47498
|
35
|
+
risk_network-0.0.8b23.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
36
|
+
risk_network-0.0.8b23.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
37
|
+
risk_network-0.0.8b23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|