Skip to content

Commit ebd6b6d

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 4d212cf + 724a950 commit ebd6b6d

File tree

5 files changed

+367
-291
lines changed

5 files changed

+367
-291
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,28 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: [3.6, 3.7, 3.8, 3.9]
21+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
2222
os: [ubuntu-latest, macOS-latest]
2323
include:
2424
- os: ubuntu-latest
25-
path: ~/.cache/pip
2625
- os: macos-latest
27-
path: ~/Library/Caches/pip
2826

2927
steps:
30-
- uses: actions/cache@v2
31-
with:
32-
path: ${{ matrix.path }}
33-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
34-
restore-keys: |
35-
${{ runner.os }}-pip-${{ matrix.python-version }}-
3628
- uses: actions/checkout@v2
3729
- name: Set up Python ${{ matrix.python-version }}
3830
uses: actions/setup-python@v2
3931
with:
4032
python-version: ${{ matrix.python-version }}
41-
- name: Setup macOS dependencies
42-
if: startsWith(runner.os, 'macOS')
43-
run: |
44-
brew install libomp
4533
- name: Install dependencies
4634
run: |
47-
python -m pip install --upgrade pip
48-
python -m pip install flake8 pytest
49-
python -m pip install cython
50-
python -m pip install numpy
51-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
35+
# $CONDA is an environment variable pointing to the root of the miniconda directory
36+
$CONDA/bin/conda install -c conda-forge --file requirements.txt flake8 pytest
5237
- name: Lint with flake8
5338
run: |
5439
# stop the build if there are Python syntax errors or undefined names
55-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
40+
$CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
5641
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
57-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
42+
$CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
5843
- name: Test with pytest
5944
run: |
60-
pytest
45+
$CONDA/bin/pytest

GraphRicciCurvature/OllivierRicci.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020

2121
import heapq
22-
import importlib
2322
import math
2423
import multiprocessing as mp
2524
import time
2625
from functools import lru_cache
26+
from importlib import util
2727

2828
import networkit as nk
2929
import networkx as nx
@@ -690,7 +690,7 @@ def __init__(self, G: nx.Graph, weight="weight", alpha=0.5, method="OTDSinkhornM
690690
self.lengths = {} # all pair shortest path dictionary
691691
self.densities = {} # density distribution dictionary
692692

693-
assert importlib.util.find_spec("ot"), \
693+
assert util.find_spec("ot"), \
694694
"Package POT: Python Optimal Transport is required for Sinkhorn distance."
695695

696696
if not nx.get_edge_attributes(self.G, weight):

GraphRicciCurvature/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
import community as community_louvain
2+
import community.community_louvain as community_louvain
33
import networkx as nx
44
import numpy as np
55
from functools import partial, partialmethod

my_surgery.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from importlib import util
2+
3+
import community as community_louvain
14
import networkx as nx
25
import numpy as np
3-
import importlib
4-
import community as community_louvain
5-
import matplotlib.pyplot as plt
66

77

88
def ARI(G, clustering, clustering_label="club"):
@@ -24,10 +24,10 @@ def ARI(G, clustering, clustering_label="club"):
2424
Adjust Rand Index for predicted community.
2525
"""
2626

27-
if importlib.util.find_spec("sklearn") is not None:
27+
if util.find_spec("sklearn") is not None:
2828
from sklearn import preprocessing, metrics
2929
else:
30-
print("scikit-learn not installed...")
30+
print("scikit-learn not installed, skipped...")
3131
return -1
3232

3333
complex_list = nx.get_node_attributes(G, clustering_label)
@@ -107,6 +107,12 @@ def check_accuracy(G_origin, weight="weight", clustering_label="value", plot_cut
107107
To plot the good guessed cut or not.
108108
109109
"""
110+
if util.find_spec("matplotlib") is not None:
111+
import matplotlib.pyplot as plt
112+
else:
113+
print("matplotlib not installed, skipped to show the cut graph...")
114+
return -1
115+
110116
G = G_origin.copy()
111117
modularity, ari = [], []
112118
maxw = max(nx.get_edge_attributes(G, weight).values())

0 commit comments

Comments
 (0)