Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Nov 24, 2024
1 parent f2624e1 commit c53446e
Show file tree
Hide file tree
Showing 12 changed files with 174,285 additions and 463 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/benchmark.yml
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
97 changes: 97 additions & 0 deletions benchmarks/bench.py
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()
1 change: 0 additions & 1 deletion benchmarks/benchmarks/__init__.py

This file was deleted.

55 changes: 0 additions & 55 deletions benchmarks/benchmarks/bench_core_hypergraph.py

This file was deleted.

15 changes: 0 additions & 15 deletions benchmarks/benchmarks/common.py

This file was deleted.

Loading

0 comments on commit c53446e

Please sign in to comment.