-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
174,285 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Python Example with pytest | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: write | ||
deployments: write | ||
|
||
jobs: | ||
benchmark: | ||
name: Run pytest-benchmark benchmark example | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.13 | ||
- name: Run benchmark | ||
run: | | ||
cd benchmarks | ||
pip install --upgrade pip | ||
pip install .[benchmark] | ||
pytest bench.py --benchmark-json output.json | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Python Benchmark with pytest-benchmark | ||
tool: 'pytest' | ||
output-file-path: benchmarks/output.json | ||
# Use personal access token instead of GITHUB_TOKEN due to https://git.luolix.topmunity/t/github-action-not-triggering-gh-pages-upon-push/16096 | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
auto-push: true | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '200%' | ||
comment-on-alert: false | ||
fail-on-alert: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import pandas as pd | ||
|
||
import xgi | ||
import numpy as np | ||
import random | ||
|
||
|
||
import pytest | ||
|
||
def test_construct_from_edgelist(benchmark): | ||
def setup(): | ||
H = xgi.read_hif("email-enron.json") | ||
return (H.edges.members(),), {} | ||
|
||
benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) | ||
|
||
|
||
def test_construct_from_edgedict(benchmark): | ||
def setup(): | ||
H = xgi.read_hif("email-enron.json") | ||
return (H.edges.members(dtype=dict),), {} | ||
|
||
benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) | ||
|
||
|
||
def test_construct_from_df(benchmark): | ||
def setup(): | ||
H = xgi.read_hif("email-enron.json") | ||
return (xgi.to_bipartite_pandas_dataframe(H),), {} | ||
|
||
benchmark.pedantic(xgi.Hypergraph, setup=setup, rounds=10) | ||
|
||
def test_node_memberships(benchmark): | ||
def setup(): | ||
H = xgi.read_hif("email-enron.json") | ||
return (H,), {} | ||
|
||
def node_memberships(H): | ||
[H.nodes.memberships(n) for n in H.nodes] | ||
|
||
benchmark.pedantic(node_memberships, setup=setup, rounds=10) | ||
|
||
|
||
def test_edge_members(benchmark): | ||
def setup(): | ||
H = xgi.read_hif("email-enron.json") | ||
return (H,), {} | ||
|
||
def edge_members(H): | ||
[H.edges.members(eid) for eid in H.edges] | ||
|
||
benchmark.pedantic(edge_members, setup=setup, rounds=10) | ||
|
||
|
||
# def setup_benchmarks(): | ||
# random.seed(1) | ||
# # but will seed it nevertheless | ||
# np.random.seed(1) | ||
# self.hypergraph = xgi.load_xgi_data("email-enron") | ||
# self.enron_edgelist = xgi.to_hyperedge_list(self.hypergraph) | ||
# self.enron_edgedict = xgi.to_hyperedge_dict(self.hypergraph) | ||
# self.enron_df = xgi.to_bipartite_pandas_dataframe(self.hypergraph) | ||
|
||
|
||
# class CoreHypergraph(Benchmark): | ||
# def setup(self): | ||
# self.hypergraph = xgi.load_xgi_data("email-enron") | ||
# self.enron_edgelist = xgi.to_hyperedge_list(self.hypergraph) | ||
# self.enron_edgedict = xgi.to_hyperedge_dict(self.hypergraph) | ||
# self.enron_df = xgi.to_bipartite_pandas_dataframe(self.hypergraph) | ||
|
||
# def time_node_attributes(self): | ||
# [self.hypergraph.nodes[n] for n in self.hypergraph.nodes] | ||
|
||
# def time_edge_attributes(self): | ||
# [self.hypergraph.edges[e] for e in self.hypergraph.edges] | ||
|
||
# def time_degree(self): | ||
# self.hypergraph.degree() | ||
|
||
# def time_nodestats_degree(self): | ||
# self.hypergraph.nodes.degree.asnumpy() | ||
|
||
# def time_edge_size(self): | ||
# self.hypergraph.edges.size.asnumpy() | ||
|
||
# def time_isolates(self): | ||
# self.hypergraph.nodes.isolates() | ||
|
||
# def time_singletons(self): | ||
# self.hypergraph.edges.singletons() | ||
|
||
# def time_copy(self): | ||
# self.hypergraph.copy() | ||
|
||
# def time_dual(self): | ||
# self.hypergraph.dual() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.