From 1be3dd85db68865c5cbd512b88a0dc03f32cdf36 Mon Sep 17 00:00:00 2001 From: ysitu Date: Tue, 29 Apr 2014 17:45:36 -0400 Subject: [PATCH] Remove Cholesky solver in algebraic_connectivity --- .travis.yml | 7 ++--- networkx/linalg/algebraic_connectivity.py | 26 ++----------------- .../tests/test_algebraic_connectivity.py | 2 +- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25fec1b5e9f..8348332c0fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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. @@ -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 diff --git a/networkx/linalg/algebraic_connectivity.py b/networkx/linalg/algebraic_connectivity.py index 5e9682fd08c..4f2705b8fcc 100644 --- a/networkx/linalg/algebraic_connectivity.py +++ b/networkx/linalg/algebraic_connectivity.py @@ -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. """ @@ -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 @@ -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.') @@ -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 =============== ======================================== @@ -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 =============== ======================================== @@ -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 =============== ======================================== diff --git a/networkx/linalg/tests/test_algebraic_connectivity.py b/networkx/linalg/tests/test_algebraic_connectivity.py index 53133d22599..d365461ee3e 100644 --- a/networkx/linalg/tests/test_algebraic_connectivity.py +++ b/networkx/linalg/tests/test_algebraic_connectivity.py @@ -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: