Skip to content

Commit

Permalink
Merge pull request #66 from KrishnaswamyLab/scipy-graph-shortest-path
Browse files Browse the repository at this point in the history
Use `scipy.sparse.csgraph.shortest_path`
  • Loading branch information
scottgigante authored Jan 3, 2023
2 parents a94cb37 + 582d9d4 commit 3518ff8
Show file tree
Hide file tree
Showing 28 changed files with 465 additions and 270 deletions.
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ exclude_lines =
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.


62 changes: 62 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: pre-commit
on:
push:
branches-ignore:
- 'master'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest

if: >-
!endsWith(github.event.head_commit.message, '# ci skip') &&
(
startsWith(github.ref, 'refs/heads') ||
github.event.pull_request.draft == false
)
steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache pre-commit
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}-

- name: Run pre-commit
id: precommit
uses: pre-commit/[email protected]
continue-on-error: true

- name: Commit files
if: steps.precommit.outcome == 'failure' && startsWith(github.ref, 'refs/heads')
run: |
if [[ `git status --porcelain --untracked-files=no` ]]; then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git checkout -- .github/workflows
git commit -m "pre-commit" -a
fi
shell: bash -ex {0}

- name: Push changes
if: steps.precommit.outcome == 'failure' && startsWith(github.ref, 'refs/heads')
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

- name: Check pre-commit
if: steps.precommit.outcome == 'failure'
uses: pre-commit/[email protected]
77 changes: 77 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Unit Tests

on:
push:
branches-ignore:
- 'test_deploy'
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

run_tester:
runs-on: ${{ matrix.config.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"

strategy:
fail-fast: false
matrix:
config:
- {name: '3.10', os: ubuntu-latest, python: '3.10' }
- {name: '3.9', os: ubuntu-latest, python: '3.9' }
- {name: '3.8', os: ubuntu-latest, python: '3.8' }
- {name: '3.7', os: ubuntu-latest, python: '3.7' }

steps:

- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update -qq
sudo apt-get install -y libhdf5-dev libhdf5-serial-dev pandoc gfortran libblas-dev liblapack-dev llvm-dev
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.config.python }}

- name: Cache Python packages
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{runner.os}}-${{ matrix.config.python }}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
restore-keys: ${{runner.os}}-${{ matrix.config.python }}-pip-${{ env.pythonLocation }}-

- name: Install package & dependencies
run: |
python -m pip install --upgrade pip
pip install -U wheel setuptools
pip install -U .[test]
python -c "import graphtools"
- name: Run tests
run: |
nose2 -vvv
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
run: |
coveralls
- name: Upload check results on fail
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ matrix.config.name }}_results
path: check
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: \.(ai|gz)$
- repo: https://github.com/timothycrosley/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ['--target-version=py36']
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.5.4
hooks:
- id: autopep8
# - repo: https://gitlab.com/pycqa/flake8
# rev: 3.8.4
# hooks:
# - id: flake8
# additional_dependencies: ['hacking']
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ graphtools
.. image:: https://anaconda.org/conda-forge/graphtools/badges/version.svg
:target: https://anaconda.org/conda-forge/graphtools/
:alt: Latest Conda version
.. image:: https://api.travis-ci.com/KrishnaswamyLab/graphtools.svg?branch=master
.. image:: https://img.shields.io/github/workflow/status/KrishnaswamyLab/graphtools/Unit%20Tests/master?label=Github%20Actions
:target: https://travis-ci.com/KrishnaswamyLab/graphtools
:alt: Travis CI Build
:alt: Github Actions Build
.. image:: https://img.shields.io/readthedocs/graphtools.svg
:target: https://graphtools.readthedocs.io/
:alt: Read the Docs
Expand Down
1 change: 0 additions & 1 deletion autoblack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ for file in \$files; do
done
EOF
chmod +x .git/hooks/pre-commit

2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 3 additions & 1 deletion graphtools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from .api import Graph, from_igraph, read_pickle
from .api import from_igraph
from .api import Graph
from .api import read_pickle
from .version import __version__
15 changes: 8 additions & 7 deletions graphtools/api.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import numpy as np
import warnings
from . import base
from . import graphs
from scipy import sparse

import numpy as np
import pickle
import pygsp
import tasklogger

from . import base, graphs
import warnings

_logger = tasklogger.get_tasklogger("graphtools")

Expand Down Expand Up @@ -36,7 +37,7 @@ def Graph(
graphtype="auto",
use_pygsp=False,
initialize=True,
**kwargs
**kwargs,
):
"""Create a graph built on data.
Expand Down Expand Up @@ -255,7 +256,7 @@ def Graph(
else:
msg = msg + " and PyGSP inheritance"

_logger.debug(msg)
_logger.log_debug(msg)

class_names = [p.__name__.replace("Graph", "") for p in parent_classes]
try:
Expand All @@ -273,7 +274,7 @@ def Graph(
pass

# build graph and return
_logger.debug(
_logger.log_debug(
"Initializing {} with arguments {}".format(
parent_classes,
", ".join(
Expand Down
Loading

0 comments on commit 3518ff8

Please sign in to comment.