@@ -76,11 +76,14 @@ def get_prod_dist(bdd_model: BDDModel,
7676 get_prod_dist (bdd_model , low , dist , mark , complemented ^ bdd_model .negated (low ))
7777
7878 # compute low_dist to account for the removed nodes through low
79- removed_nodes = bdd_model .index (low ) - bdd_model .index (node ) - 1
80- low_dist = [0 ] * (removed_nodes + len (dist [id_low ]))
81- for i in range (removed_nodes + 1 ):
82- for j in range (len (dist [id_low ])):
83- low_dist [i + j ] = low_dist [i + j ] + dist [id_low ][j ] * math .comb (removed_nodes , i )
79+ low_index = bdd_model .index (low )
80+ node_index = bdd_model .index (node )
81+ if low_index is not None and node_index is not None :
82+ removed_nodes = low_index - node_index - 1
83+ low_dist = [0 ] * (removed_nodes + len (dist [id_low ]))
84+ for i in range (removed_nodes + 1 ):
85+ for j in range (len (dist [id_low ])):
86+ low_dist [i + j ] = low_dist [i + j ] + dist [id_low ][j ] * math .comb (removed_nodes , i )
8487
8588 # traverse
8689 high = bdd_model .get_high_node (node )
@@ -89,12 +92,15 @@ def get_prod_dist(bdd_model: BDDModel,
8992 get_prod_dist (bdd_model , high , dist , mark , complemented )
9093
9194 # compute high_dist to account for the removed nodes through high
92- removed_nodes = bdd_model .index (high ) - bdd_model .index (node ) - 1
93- high_dist = [0 ] * (removed_nodes + len (dist [id_high ]))
94- for i in range (removed_nodes + 1 ):
95- for j in range (len (dist [id_high ])):
96- high_dist [i + j ] = high_dist [i + j ] + dist [id_high ][j ] * (
97- math .comb (removed_nodes , i ))
95+ high_index = bdd_model .index (high )
96+ node_index = bdd_model .index (node )
97+ if high_index is not None and node_index is not None :
98+ removed_nodes = high_index - node_index - 1
99+ high_dist = [0 ] * (removed_nodes + len (dist [id_high ]))
100+ for i in range (removed_nodes + 1 ):
101+ for j in range (len (dist [id_high ])):
102+ high_dist [i + j ] = high_dist [i + j ] + dist [id_high ][j ] * (
103+ math .comb (removed_nodes , i ))
98104 # combine low and high distributions
99105 combine_distributions (id_node , dist , low_dist , high_dist )
100106
@@ -116,7 +122,7 @@ def combine_distributions(id_node: int,
116122 dist [id_node ] = node_dist
117123
118124
119- def descriptive_statistics (prod_dist : list [int ]) -> dict [str , Any ]: # noqa: MC0001
125+ def descriptive_statistics (prod_dist : list [int ]) -> dict [str , Any ]:
120126 total_elements = sum (prod_dist )
121127 if total_elements == 0 :
122128 return {
0 commit comments