Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Sep 19, 2023
1 parent d8d38c1 commit 573d405
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/stats/test_edgestats.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pandas as pd
import pytest

import xgi
Expand Down Expand Up @@ -126,3 +127,9 @@ def test_view_val(edgelist1, edgelist2):
H = xgi.Hypergraph(edgelist2)
assert H.edges.order._val == {0: 1, 1: 1, 2: 2}
assert H.edges([1, 2]).order._val == {1: 1, 2: 2}


def test_issue_468():
H = xgi.sunflower(3, 1, 20)
df = pd.DataFrame([[20.0, 3]], columns=["bin_center", "value"])
assert H.edges.size.ashist().equals(df)
7 changes: 6 additions & 1 deletion xgi/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,13 @@ def ashist(self, bins=10, bin_edges=False, density=False, log_binning=False):
Notes
-----
Originally from https://github.com/jkbren/networks-and-dataviz
"""

# if there is one unique value and more than one bin is specified,
# sets the number of bins to 1.
if isinstance(bins, int) and len(set(self.aslist())) == 1:
bins = 1

return hist(self.asnumpy(), bins, bin_edges, density, log_binning)

def max(self):
Expand Down

0 comments on commit 573d405

Please sign in to comment.