Skip to content

Commit

Permalink
Remove Cholesky solver in algebraic_connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
ysitu committed Apr 30, 2014
1 parent 2b5520e commit 1be3dd8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ python:
before_install:
# Current TravisCI VM is Ubuntu 12.04 which has Python 2.7 and 3.2.
# So apt-get will only apply to those virtualenvs.
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then source ~/virtualenv/python2.7_with_system_site_packages/bin/activate; sudo apt-get install -qq python-numpy python-scipy python-matplotlib python-pydot python-gdal cython libsuitesparse-dev; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then source ~/virtualenv/python3.2_with_system_site_packages/bin/activate; sudo apt-get install -qq python3-numpy python3-scipy libsuitesparse-dev; fi
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then source ~/virtualenv/python2.7_with_system_site_packages/bin/activate; sudo apt-get install -qq python-numpy python-scipy python-matplotlib python-pydot python-gdal; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then source ~/virtualenv/python3.2_with_system_site_packages/bin/activate; sudo apt-get install -qq python3-numpy python3-scipy; fi

# Additionally, the TravisCI VM has numpy preinstalled on 2.6, 2.7 and 3.2.
# So for 3.3 and pypy, numpy is not preinstalled and must be pip-installed.
Expand All @@ -26,9 +26,6 @@ before_install:
- pip install pyyaml --use-mirrors
- pip install pyparsing --use-mirrors
- pip install coveralls --use-mirrors
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install scikits.sparse; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then pip install Cython; fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]]; then pip install scikits.sparse; fi

# In general, 2.6, 3.2, 3.3, and pypy will have lower coverage levels
# due to missing dependencies. The coverage level reported by coveralls
Expand Down
26 changes: 2 additions & 24 deletions networkx/linalg/algebraic_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,6 @@ def solve(self, b):
p += z


class _CholeskySolver(object):
"""Cholesky factorization.
"""

def __init__(self, A):
if not self._cholesky:
raise nx.NetworkXError('Cholesky solver unavailable.')
self._chol = self._cholesky(A)

def solve(self, b):
return self._chol(b)

try:
from scikits.sparse.cholmod import cholesky
_cholesky = cholesky
except ImportError:
_cholesky = None


class _LUSolver(object):
"""LU factorization.
"""
Expand Down Expand Up @@ -179,7 +160,7 @@ def gram_schmidt(X):
if solver is None or solver == 'pcg':
M = (1. / L.diagonal()).__mul__
solver = _PCGSolver(L, M, tol / 10)
elif solver == 'chol' or solver == 'lu':
elif solver == 'lu':
# Convert A to CSC to suppress SparseEfficiencyWarning.
A = csc_matrix(L, dtype=float, copy=True)
# Force A to be nonsingular. Since A is the Laplacian matrix of a
Expand All @@ -188,7 +169,7 @@ def gram_schmidt(X):
# corresponding element in the solution.
i = A.diagonal().argmin()
A[i, i] = float('inf')
solver = (_CholeskySolver if solver == 'chol' else _LUSolver)(A)
solver = _LUSolver(A)
else:
raise nx.NetworkXError('unknown linear system solver.')

Expand Down Expand Up @@ -265,7 +246,6 @@ def algebraic_connectivity(G, weight='weight', normalized=False, tol=1e-8,
Value Solver
=============== ========================================
'tracemin_pcg' Preconditioned conjugate gradient method
'tracemin_chol' Cholesky factorization
'tracemin_lu' LU factorization
=============== ========================================
Expand Down Expand Up @@ -366,7 +346,6 @@ def fiedler_vector(G, weight='weight', normalized=False, tol=1e-8,
Value Solver
=============== ========================================
'tracemin_pcg' Preconditioned conjugate gradient method
'tracemin_chol' Cholesky factorization
'tracemin_lu' LU factorization
=============== ========================================
Expand Down Expand Up @@ -466,7 +445,6 @@ def spectral_ordering(G, weight='weight', normalized=False, tol=1e-8,
Value Solver
=============== ========================================
'tracemin_pcg' Preconditioned conjugate gradient method
'tracemin_chol' Cholesky factorization
'tracemin_lu' LU factorization
=============== ========================================
Expand Down
2 changes: 1 addition & 1 deletion networkx/linalg/tests/test_algebraic_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from nose import SkipTest
from nose.tools import *

methods = ('tracemin_pcg', 'tracemin_chol', 'tracemin_lu', 'lanczos', 'lobpcg')
methods = ('tracemin_pcg', 'tracemin_lu', 'lanczos', 'lobpcg')


try:
Expand Down

0 comments on commit 1be3dd8

Please sign in to comment.