Skip to content

Commit

Permalink
commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpedigo committed Apr 23, 2024
1 parent f4f5e69 commit 3932f25
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions networkframe/networkframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,11 +1332,10 @@ def k_hop_aggregation(
rows.append(agg_neighbor_features)
neighborhood_features = pd.concat(rows, axis=1).T
elif engine == "scipy":
# ensure that only "mean" and "sum" are allowed in aggregations
# TODO add more aggregations here
if not all([x in ["mean", "sum", "std"] for x in aggregations]):
raise ValueError(
"Currently only 'mean' and 'sum' are allowed in `aggregations`"
"Currently only 'mean', 'sum', and 'std' are allowed in "
"`aggregations` "
"when using the 'scipy' engine."
)

Expand Down Expand Up @@ -1391,6 +1390,8 @@ def k_hop_aggregation(
# squared sum of the shifted data, divided by the number of non-NaNs
second_term = (mask @ inner_term) ** 2 / divisor_matrix

# this is a node by feature matrix of the variances for each feature
# in that node's neighborhood
variances = (first_term - second_term) / (divisor_matrix - 1)
variances[variances < 0] = 0

Expand Down

0 comments on commit 3932f25

Please sign in to comment.