Skip to content

Commit

Permalink
format with isort and black
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Dec 19, 2024
1 parent a549885 commit 8ac2c9e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion benchmarks/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ def setup():
def dual(H):
H.dual()

benchmark.pedantic(dual, setup=setup, rounds=rounds)
benchmark.pedantic(dual, setup=setup, rounds=rounds)
1 change: 0 additions & 1 deletion tests/readwrite/test_xgi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def test_load_xgi_data(capfd):
assert H.num_edges == 77733



@pytest.mark.skipif(
sys.version_info != (3, 12) and not platform.system() == "Linux",
reason="only need one test",
Expand Down
40 changes: 18 additions & 22 deletions tests/stats/test_core_stats_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,44 +575,41 @@ def test_issue_468():
assert H.edges.size.ashist().equals(df)




def test_ashist_attrs_exist():
"""Test that ashist returns DataFrame with expected attributes."""
H = xgi.sunflower(3, 1, 20)
df = H.edges.size.ashist()

# Check that all expected attributes exist
assert 'xlabel' in df.attrs
assert 'ylabel' in df.attrs
assert 'title' in df.attrs
assert "xlabel" in df.attrs
assert "ylabel" in df.attrs
assert "title" in df.attrs


def test_ashist_density_labels():
"""Test that ylabel changes based on density parameter."""
H = xgi.sunflower(3, 1, 20)

# Test default (density=False)
df_count = H.edges.size.ashist(density=False)
assert df_count.attrs['ylabel'] == 'Count'
assert df_count.attrs["ylabel"] == "Count"

# Test with density=True
df_density = H.edges.size.ashist(density=True)
assert df_density.attrs['ylabel'] == 'Probability'
assert df_density.attrs["ylabel"] == "Probability"


def test_ashist_original_functionality():
"""Test that adding attributes doesn't break original functionality."""
H = xgi.sunflower(3, 1, 20)
df = H.edges.size.ashist()

# Original test case should still pass
expected_df = pd.DataFrame([[20.0, 3]], columns=["bin_center", "value"])
assert df.equals(expected_df) # Original functionality

# And should have attributes
assert 'xlabel' in df.attrs

# And should have attributes
assert "xlabel" in df.attrs


def test_ashist_single_unique_value():
Expand All @@ -621,20 +618,19 @@ def test_ashist_single_unique_value():
H.add_nodes_from(range(5))
# All edges have the same size
H.add_edges_from([[0, 1], [2, 3], [4, 0]])

# The edge sizes will all be 2
df = H.edges.size.ashist(bins=10)

# Since there's only one unique value, bins should be set to 1
assert len(df) == 1 # Only one bin should be present
assert df['bin_center'].iloc[0] == 2 # The bin center should be the unique value
assert df['value'].iloc[0] == 3 # There are three edges of size 2
assert df["bin_center"].iloc[0] == 2 # The bin center should be the unique value
assert df["value"].iloc[0] == 3 # There are three edges of size 2

# Check that attributes are present
assert 'xlabel' in df.attrs
assert 'ylabel' in df.attrs
assert 'title' in df.attrs

assert "xlabel" in df.attrs
assert "ylabel" in df.attrs
assert "title" in df.attrs


### Attribute statistics
Expand Down
3 changes: 0 additions & 3 deletions xgi/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def aspandas(self):
"""
return pd.Series(self._val, name=self.name)


def ashist(self, bins=10, bin_edges=False, density=False, log_binning=False):
"""Return the distribution of a numpy array.
Expand Down Expand Up @@ -216,8 +215,6 @@ def ashist(self, bins=10, bin_edges=False, density=False, log_binning=False):

return df



def max(self):
"""The maximum value of this stat."""
return self.asnumpy().max(axis=0).item()
Expand Down

0 comments on commit 8ac2c9e

Please sign in to comment.