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

asv GitHub action #556

Closed
wants to merge 5 commits into from
Closed
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
32 changes: 32 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Benchmarks

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- uses: actions/checkout@v3
- name: Install packages
run: |
git fetch origin $GITHUB_BASE_REF:base $GITHUB_REF:pr
python -m pip install --upgrade pip wheel setuptools
pip install -r requirements/default.txt -r requirements/benchmarks.txt
pip install virtualenv
pip install setuptools
pip install .
python -m pip list
- name: Benchmark against main
run: |
cd benchmarks/
asv machine --yes
asv continuous base pr -e
2 changes: 1 addition & 1 deletion requirements/benchmarks.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hypernetx>=1.0
asv>=0.5
asv>=0.5, <0.6
7 changes: 5 additions & 2 deletions xgi/algorithms/centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def clique_eigenvector_centrality(H, tol=1e-6):
if not is_connected(H):
return {n: np.nan for n in H.nodes}
W, node_dict = clique_motif_matrix(H, index=True)
_, v = eigsh(W.asfptype(), k=1, which="LM", tol=tol)

try:
_, v = eigsh(W.astype(float), k=1, which="LM", tol=tol)
except AttributeError:
_, v = eigsh(W.asfptype(), k=1, which="LM", tol=tol)

# multiply by the sign to try and enforce positivity
v = np.sign(v[0]) * v / norm(v, 1)
return {node_dict[n]: v[n].item() for n in node_dict}
Expand Down
Loading