Skip to content

Commit 5870b57

Browse files
committed
Add warning when multilayer pruning truncates omega estimates
This closes #10.
1 parent 8b7d3ca commit 5870b57

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

utilities/parameter_estimation_utilities.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,11 @@ def prune_to_multilayer_stable_partitions(G_intralayer, G_interlayer, layer_vec,
548548
549549
See https://doi.org/10.1038/s41598-022-20142-6 for more details.
550550
551-
NOTE: This method truncates omega estimates to ``omega_end - 1e-3`` in order to properly identify stable partitions
552-
with infinite interlayer coupling estimates (e.g. when all membership labels persist across layers). If
553-
``omega_end`` is set too low, such partitions may be incorrectly identified as stable. As such, you should be
554-
somewhat wary of the returned partitions with zero community structure differences across layers.
551+
NOTE: This method will truncate omega estimates to ``omega_end - 1e-3`` (and raise a warning) if needed to properly
552+
identify stable partitions with very large or infinite interlayer coupling estimates (e.g., when all membership
553+
labels persist across layers). If ``omega_end`` is set too low, these partitions may be incorrectly identified as
554+
stable. Conversely, some partitions with large omega estimates might be misclassified as not stable. Therefore, be
555+
cautious of returned partitions with little or no community structure differences across layers.
555556
556557
:param G_intralayer: intralayer graph of interest
557558
:type G_intralayer: igraph.Graph
@@ -611,6 +612,11 @@ def prune_to_multilayer_stable_partitions(G_intralayer, G_interlayer, layer_vec,
611612
omega_start, omega_end)
612613
domains_with_estimates = domains_to_gamma_omega_estimates(G_intralayer, G_interlayer, layer_vec, domains, model)
613614

615+
if any(o_est >= omega_end for _, _, g_est, o_est in domains_with_estimates if g_est is not None):
616+
warnings.warn(f"We are truncating some omega estimates to your choice of omega_end={omega_end}. You should "
617+
f"check that this accurately captures the high-omega behavior of the partition domains. "
618+
f"Be cautious of partitions with little or no community structure differences across layers!")
619+
614620
# Truncate infinite omega solutions to our maximum omega
615621
domains_with_estimates = [(polyverts, membership, g_est, min(o_est, omega_end - 1e-3))
616622
for polyverts, membership, g_est, o_est in domains_with_estimates

0 commit comments

Comments
 (0)