Skip to content

Commit

Permalink
add auto option
Browse files Browse the repository at this point in the history
  • Loading branch information
bdpedigo committed Apr 23, 2024
1 parent 3932f25 commit f7e7fc6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion networkframe/networkframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,22 @@ def k_hop_aggregation(
drop_non_numeric=True,
n_jobs=-1,
verbose=False,
engine="pandas",
engine="auto",
):
if k < 0:
raise ValueError("k must be non-negative.")

if isinstance(aggregations, str):
aggregations = [aggregations]

if engine == "auto":
if not all([isinstance(x, str) for x in aggregations]) or not all(
[x in ["mean", "sum", "std"] for x in aggregations]
):
engine = "pandas"
else:
engine = "scipy"

nodes = self.nodes
if drop_non_numeric:
nodes = nodes.select_dtypes(include=[np.number])
Expand Down

0 comments on commit f7e7fc6

Please sign in to comment.