Skip to content

Commit

Permalink
Only look up value after checking if entries exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaris committed May 3, 2024
1 parent bf2fe66 commit a5510e5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions depmap_analysis/network_functions/net_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,11 @@ def add_corr_to_edges(graph: DiGraph, z_corr: pd.DataFrame,
for u, v, data in tqdm(graph.edges(data=True)):
un = u[0] if isinstance(u, tuple) else u
vn = v[0] if isinstance(v, tuple) else v
z_sc = z_corr.loc[un, vn]
if un in z_corr and vn in z_corr and not np.isnan(z_sc) and not np.isinf(z_sc):
if (
un in z_corr and vn in z_corr and
not np.isnan(z_corr.loc[un, vn]) and
not np.isinf(z_corr.loc[un, vn])
):
z_sc = z_corr.loc[un, vn]
data['z_score'] = round(z_sc, 4)
data['corr_weight'] = round(z_sc_weight(z_sc, self_corr), 4)
Expand Down

0 comments on commit a5510e5

Please sign in to comment.