Skip to content

Commit a5510e5

Browse files
committed
Only look up value after checking if entries exist
1 parent bf2fe66 commit a5510e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

depmap_analysis/network_functions/net_functions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,11 @@ def add_corr_to_edges(graph: DiGraph, z_corr: pd.DataFrame,
393393
for u, v, data in tqdm(graph.edges(data=True)):
394394
un = u[0] if isinstance(u, tuple) else u
395395
vn = v[0] if isinstance(v, tuple) else v
396-
z_sc = z_corr.loc[un, vn]
397-
if un in z_corr and vn in z_corr and not np.isnan(z_sc) and not np.isinf(z_sc):
396+
if (
397+
un in z_corr and vn in z_corr and
398+
not np.isnan(z_corr.loc[un, vn]) and
399+
not np.isinf(z_corr.loc[un, vn])
400+
):
398401
z_sc = z_corr.loc[un, vn]
399402
data['z_score'] = round(z_sc, 4)
400403
data['corr_weight'] = round(z_sc_weight(z_sc, self_corr), 4)

0 commit comments

Comments
 (0)