Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sum as a stats method #168

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/stats/test_edgestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,23 @@ def test_aggregates(edgelist1, edgelist2, edgelist8):
H = xgi.Hypergraph(edgelist1)
assert H.edges.order.max() == 2
assert H.edges.order.min() == 0
assert H.edges.order.sum() == 5
assert round(H.edges.order.mean(), 3) == 1.25
assert round(H.edges.order.std(), 3) == 0.829
assert round(H.edges.order.var(), 3) == 0.688

H = xgi.Hypergraph(edgelist2)
assert H.edges.order.max() == 2
assert H.edges.order.min() == 1
assert H.edges.order.sum() == 4
assert round(H.edges.order.mean(), 3) == 1.333
assert round(H.edges.order.std(), 3) == 0.471
assert round(H.edges.order.var(), 3) == 0.222

H = xgi.Hypergraph(edgelist8)
assert H.edges.order.max() == 4
assert H.edges.order.min() == 1
assert H.edges.order.sum() == 17
assert round(H.edges.order.mean(), 3) == 1.889
assert round(H.edges.order.std(), 3) == 0.875
assert round(H.edges.order.var(), 3) == 0.765
Expand Down
3 changes: 3 additions & 0 deletions tests/stats/test_nodestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,23 @@ def test_aggregates(edgelist1, edgelist2, edgelist8):
H = xgi.Hypergraph(edgelist1)
assert H.nodes.degree.max() == 2
assert H.nodes.degree.min() == 1
assert H.nodes.degree.sum() == 9
assert round(H.nodes.degree.mean(), 3) == 1.125
assert round(H.nodes.degree.std(), 3) == 0.331
assert round(H.nodes.degree.var(), 3) == 0.109

H = xgi.Hypergraph(edgelist2)
assert H.nodes.degree.max() == 2
assert H.nodes.degree.min() == 1
assert H.nodes.degree.sum() == 7
assert round(H.nodes.degree.mean(), 3) == 1.167
assert round(H.nodes.degree.std(), 3) == 0.373
assert round(H.nodes.degree.var(), 3) == 0.139

H = xgi.Hypergraph(edgelist8)
assert H.nodes.degree.max() == 6
assert H.nodes.degree.min() == 2
assert H.nodes.degree.sum() == 26
assert round(H.nodes.degree.mean(), 3) == 3.714
assert round(H.nodes.degree.std(), 3) == 1.385
assert round(H.nodes.degree.var(), 3) == 1.918
Expand Down
2 changes: 1 addition & 1 deletion xgi/readwrite/xgi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def load_xgi_data(dataset, nodetype=None, edgetype=None):
index = requests.get(index_url).json()
if dataset not in index:
print("Valid dataset names:")
print(*index, sep = "\n")
print(*index, sep="\n")
raise XGIError("Must choose a valid dataset name!")

r = requests.get(index[dataset]["url"])
Expand Down
4 changes: 4 additions & 0 deletions xgi/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ def min(self):
"""The minimum value of this stat."""
return self.asnumpy().min(axis=0)

def sum(self):
"""The sum of this stat."""
return self.asnumpy().sum(axis=0)

def mean(self):
"""The arithmetic mean of this stat."""
return self.asnumpy().mean(axis=0)
Expand Down