[Scipy-svn] r4737 - in trunk/scipy/sparse: . benchmarks linalg/dsolve/tests linalg/dsolve/umfpack linalg/dsolve/umfpack/tests linalg/eigen/arpack linalg/eigen/arpack/tests linalg/eigen/lobpcg linalg/eigen/lobpcg/tests linalg/isolve linalg/isolve/tests linalg/tests tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Sep 18 17:20:23 EDT 2008
Author: alan.mcintyre
Date: 2008-09-18 16:20:05 -0500 (Thu, 18 Sep 2008)
New Revision: 4737
Modified:
trunk/scipy/sparse/benchmarks/bench_sparse.py
trunk/scipy/sparse/bsr.py
trunk/scipy/sparse/compressed.py
trunk/scipy/sparse/construct.py
trunk/scipy/sparse/coo.py
trunk/scipy/sparse/csc.py
trunk/scipy/sparse/csr.py
trunk/scipy/sparse/dia.py
trunk/scipy/sparse/dok.py
trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py
trunk/scipy/sparse/linalg/dsolve/umfpack/umfpack.py
trunk/scipy/sparse/linalg/eigen/arpack/speigs.py
trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
trunk/scipy/sparse/linalg/isolve/iterative.py
trunk/scipy/sparse/linalg/isolve/minres.py
trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
trunk/scipy/sparse/linalg/tests/test_interface.py
trunk/scipy/sparse/spfuncs.py
trunk/scipy/sparse/tests/test_base.py
trunk/scipy/sparse/tests/test_extract.py
Log:
Removed unused imports.
Standardize NumPy import as "import numpy as np".
Modified: trunk/scipy/sparse/benchmarks/bench_sparse.py
===================================================================
--- trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/benchmarks/bench_sparse.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -8,8 +8,7 @@
from numpy.testing import *
from scipy import sparse
-from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \
- coo_matrix, lil_matrix, dia_matrix, spdiags
+from scipy.sparse import csr_matrix, coo_matrix, dia_matrix
def random_sparse(m,n,nnz_per_row):
Modified: trunk/scipy/sparse/bsr.py
===================================================================
--- trunk/scipy/sparse/bsr.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/bsr.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -7,16 +7,15 @@
from warnings import warn
from numpy import zeros, intc, array, asarray, arange, diff, tile, rank, \
- prod, ravel, empty, matrix, asmatrix, empty_like, hstack
+ ravel, empty, empty_like
from data import _data_matrix
from compressed import _cs_matrix
from base import isspmatrix, _formats
-from sputils import isshape, getdtype, to_native, isscalarlike, isdense, \
- upcast
+from sputils import isshape, getdtype, to_native, upcast
import sparsetools
-from sparsetools import bsr_matvec, bsr_matvecs, csr_matmat_pass1, csr_matmat_pass2, \
- bsr_matmat_pass2, bsr_transpose, bsr_sort_indices
+from sparsetools import bsr_matvec, bsr_matvecs, csr_matmat_pass1, \
+ bsr_matmat_pass2, bsr_transpose, bsr_sort_indices
class bsr_matrix(_cs_matrix):
"""Block Sparse Row matrix
Modified: trunk/scipy/sparse/compressed.py
===================================================================
--- trunk/scipy/sparse/compressed.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/compressed.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -5,10 +5,8 @@
from warnings import warn
-import numpy
-from numpy import array, matrix, asarray, asmatrix, zeros, rank, intc, \
- empty, hstack, isscalar, ndarray, shape, searchsorted, empty_like, \
- where, concatenate, transpose, deprecate
+from numpy import array, asarray, zeros, rank, intc, empty, isscalar, \
+ empty_like, where, concatenate, deprecate, diff, multiply
from base import spmatrix, isspmatrix, SparseEfficiencyWarning
from data import _data_matrix
@@ -166,7 +164,7 @@
if self.indices.min() < 0:
raise ValueError, "%s index values must be >= 0" % \
minor_name
- if numpy.diff(self.indptr).min() < 0:
+ if diff(self.indptr).min() < 0:
raise ValueError,'index pointer values must form a " \
"non-decreasing sequence'
@@ -260,7 +258,7 @@
raise ValueError('inconsistent shapes')
if isdense(other):
- return numpy.multiply(self.todense(),other)
+ return multiply(self.todense(),other)
else:
other = self.__class__(other)
return self._binopt(other,'_elmul_')
@@ -541,7 +539,7 @@
index = self.indices[indices] - start
data = self.data[indices]
- indptr = numpy.array([0, len(indices)])
+ indptr = array([0, len(indices)])
return self.__class__((data, index, indptr), shape=shape, \
dtype=self.dtype)
Modified: trunk/scipy/sparse/construct.py
===================================================================
--- trunk/scipy/sparse/construct.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/construct.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -15,16 +15,13 @@
from sputils import upcast
-from csr import csr_matrix, isspmatrix_csr
-from csc import csc_matrix, isspmatrix_csc
+from csr import csr_matrix
+from csc import csc_matrix
from bsr import bsr_matrix
from coo import coo_matrix
-from dok import dok_matrix
from lil import lil_matrix
from dia import dia_matrix
-from base import isspmatrix
-
def spdiags(data, diags, m, n, format=None):
"""Return a sparse matrix from diagonals.
Modified: trunk/scipy/sparse/coo.py
===================================================================
--- trunk/scipy/sparse/coo.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/coo.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -7,14 +7,13 @@
from itertools import izip
from warnings import warn
-from numpy import array, asarray, empty, intc, zeros, \
- unique, searchsorted, atleast_2d, rank, deprecate, hstack
+from numpy import array, asarray, empty, intc, zeros, unique, searchsorted,\
+ atleast_2d, rank, deprecate, hstack
-from sparsetools import coo_tocsr, coo_tocsc, coo_todense, coo_matvec
+from sparsetools import coo_tocsr, coo_todense, coo_matvec
from base import isspmatrix
from data import _data_matrix
from sputils import upcast, to_native, isshape, getdtype
-from spfuncs import estimate_blocksize
class coo_matrix(_data_matrix):
"""A sparse matrix in COOrdinate format.
Modified: trunk/scipy/sparse/csc.py
===================================================================
--- trunk/scipy/sparse/csc.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/csc.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -6,15 +6,9 @@
from warnings import warn
-import numpy
-from numpy import array, matrix, asarray, asmatrix, zeros, rank, intc, \
- empty, hstack, isscalar, ndarray, shape, searchsorted, where, \
- concatenate, deprecate, transpose, ravel
-
-from base import spmatrix, isspmatrix
+from numpy import asarray, intc, empty, searchsorted, deprecate
from sparsetools import csc_tocsr
-from sputils import upcast, to_native, isdense, isshape, getdtype, \
- isscalarlike, isintlike
+from sputils import upcast, isintlike
from compressed import _cs_matrix
Modified: trunk/scipy/sparse/csr.py
===================================================================
--- trunk/scipy/sparse/csr.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/csr.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -7,16 +7,12 @@
from warnings import warn
-import numpy
-from numpy import array, matrix, asarray, asmatrix, zeros, rank, intc, \
- empty, hstack, isscalar, ndarray, shape, searchsorted, where, \
- concatenate, deprecate, arange, ones, ravel
+from numpy import asarray, asmatrix, zeros, intc, empty, isscalar, array, \
+ searchsorted, where, deprecate, arange, ones, ravel
-from base import spmatrix, isspmatrix
from sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
get_csr_submatrix
-from sputils import upcast, to_native, isdense, isshape, getdtype, \
- isscalarlike, isintlike
+from sputils import upcast, isintlike
from compressed import _cs_matrix
@@ -319,7 +315,7 @@
index = self.indices[indices] - start
data = self.data[indices]
- indptr = numpy.array([0, len(indices)])
+ indptr = array([0, len(indices)])
return csr_matrix( (data, index, indptr), shape=(1, stop-start) )
def _get_submatrix( self, row_slice, col_slice ):
Modified: trunk/scipy/sparse/dia.py
===================================================================
--- trunk/scipy/sparse/dia.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/dia.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -4,14 +4,12 @@
__all__ = ['dia_matrix','isspmatrix_dia']
-from numpy import asarray, asmatrix, matrix, zeros, arange, array, \
- empty_like, intc, atleast_1d, atleast_2d, add, multiply, \
- unique, hstack
+from numpy import asarray, zeros, arange, array, intc, atleast_1d, \
+ atleast_2d, unique, hstack
from base import isspmatrix, _formats
from data import _data_matrix
-from sputils import isscalarlike, isshape, upcast, getdtype, isdense
-
+from sputils import isshape, upcast, getdtype
from sparsetools import dia_matvec
class dia_matrix(_data_matrix):
Modified: trunk/scipy/sparse/dok.py
===================================================================
--- trunk/scipy/sparse/dok.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/dok.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -7,7 +7,7 @@
import operator
from itertools import izip
-from numpy import asarray, asmatrix, intc, isscalar, array, matrix
+from numpy import asarray, intc, isscalar
from base import spmatrix,isspmatrix
from sputils import isdense, getdtype, isshape, isintlike, isscalarlike
Modified: trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -4,7 +4,7 @@
from numpy.testing import *
from scipy.linalg import norm, inv
-from scipy.sparse import spdiags, csc_matrix, SparseEfficiencyWarning
+from scipy.sparse import spdiags, SparseEfficiencyWarning
from scipy.sparse.linalg.dsolve import spsolve, use_solver
warnings.simplefilter('ignore',SparseEfficiencyWarning)
Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -6,14 +6,11 @@
"""
import warnings
-
-from numpy import transpose, array, arange
-
import random
from numpy.testing import *
from scipy import rand, matrix, diag, eye
-from scipy.sparse import csc_matrix, dok_matrix, spdiags, SparseEfficiencyWarning
+from scipy.sparse import csc_matrix, spdiags, SparseEfficiencyWarning
from scipy.sparse.linalg import linsolve
warnings.simplefilter('ignore',SparseEfficiencyWarning)
@@ -112,8 +109,8 @@
self.a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)
#print "The sparse matrix (constructed from diagonals):"
#print self.a
- self.b = array([1, 2, 3, 4, 5])
- self.b2 = array([5, 4, 3, 2, 1])
+ self.b = np.array([1, 2, 3, 4, 5])
+ self.b2 = np.array([5, 4, 3, 2, 1])
Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/umfpack.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/umfpack/umfpack.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/dsolve/umfpack/umfpack.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -9,7 +9,7 @@
#from base import Struct, pause
import numpy as np
import scipy.sparse as sp
-import re, imp
+import re
try: # Silence import error.
import _umfpack as _um
except:
Modified: trunk/scipy/sparse/linalg/eigen/arpack/speigs.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/speigs.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/eigen/arpack/speigs.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -1,6 +1,5 @@
import numpy as np
import _arpack
-import warnings
__all___=['ArpackException','ARPACK_eigs', 'ARPACK_gen_eigs']
Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -7,9 +7,8 @@
from numpy.testing import *
-from numpy import array,real,imag,finfo,concatenate,\
- column_stack,argsort,dot,round,conj,sort,random
-from scipy.sparse.linalg.eigen.arpack import eigen_symmetric,eigen
+from numpy import array, finfo, argsort, dot, round, conj, random
+from scipy.sparse.linalg.eigen.arpack import eigen_symmetric, eigen
def assert_almost_equal_cc(actual,desired,decimal=7,err_msg='',verbose=True):
Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/eigen/lobpcg/lobpcg.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -10,8 +10,6 @@
Examples in tests directory contributed by Nils Wagner.
"""
-from warnings import warn
-
import numpy as np
import scipy as sp
Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -5,8 +5,7 @@
import numpy
from numpy.testing import *
-from scipy import array, arange, ones, sort, cos, pi, rand, \
- set_printoptions, r_, diag, linalg
+from scipy import arange, ones, rand, set_printoptions, r_, diag, linalg
from scipy.linalg import eig
from scipy.sparse.linalg.eigen.lobpcg import lobpcg
Modified: trunk/scipy/sparse/linalg/isolve/iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/iterative.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/isolve/iterative.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -13,7 +13,6 @@
import _iterative
import numpy as np
-import copy
from scipy.sparse.linalg.interface import LinearOperator
from utils import make_system
Modified: trunk/scipy/sparse/linalg/isolve/minres.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/minres.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/isolve/minres.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -1,4 +1,4 @@
-from numpy import ndarray, matrix, sqrt, inner, finfo, asarray, zeros
+from numpy import sqrt, inner, finfo, zeros
from numpy.linalg import norm
from utils import make_system
@@ -280,7 +280,6 @@
from scipy import ones, arange
from scipy.linalg import norm
from scipy.sparse import spdiags
- from scipy.sparse.linalg import cg
n = 10
Modified: trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -4,8 +4,7 @@
from numpy.testing import *
-from numpy import zeros, dot, diag, ones, arange, array, abs, max
-from numpy.random import rand
+from numpy import zeros, ones, arange, array, abs, max
from scipy.linalg import norm
from scipy.sparse import spdiags, csr_matrix
Modified: trunk/scipy/sparse/linalg/tests/test_interface.py
===================================================================
--- trunk/scipy/sparse/linalg/tests/test_interface.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/linalg/tests/test_interface.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -5,7 +5,7 @@
from numpy.testing import *
import numpy
-from numpy import array, matrix, ones, ravel
+from numpy import array, matrix, dtype
from scipy.sparse import csr_matrix
from scipy.sparse.linalg.interface import *
@@ -21,7 +21,7 @@
class matlike:
def __init__(self):
- self.dtype = numpy.dtype('int')
+ self.dtype = dtype('int')
self.shape = (2,3)
def matvec(self,x):
y = array([ 1*x[0] + 2*x[1] + 3*x[2],
Modified: trunk/scipy/sparse/spfuncs.py
===================================================================
--- trunk/scipy/sparse/spfuncs.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/spfuncs.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -3,15 +3,8 @@
__all__ = ['count_blocks','estimate_blocksize']
-from numpy import empty, ravel
-
-from base import isspmatrix
from csr import isspmatrix_csr, csr_matrix
from csc import isspmatrix_csc
-from bsr import isspmatrix_bsr
-from sputils import upcast
-
-import sparsetools
from sparsetools import csr_count_blocks
def extract_diagonal(A):
Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/tests/test_base.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -15,9 +15,10 @@
import warnings
-import numpy
-from numpy import arange, zeros, array, dot, ones, matrix, asmatrix, \
- asarray, vstack, ndarray, transpose, diag
+import numpy as np
+from numpy import arange, zeros, array, dot, matrix, asmatrix, asarray, \
+ vstack, ndarray, transpose, diag, kron, inf, conjugate, \
+ int8
import random
from numpy.testing import *
@@ -94,12 +95,12 @@
mats.append( [[0,1],[0,2],[0,3]] )
mats.append( [[0,0,1],[0,0,2],[0,3,0]] )
- mats.append( numpy.kron(mats[0],[[1,2]]) )
- mats.append( numpy.kron(mats[0],[[1],[2]]) )
- mats.append( numpy.kron(mats[1],[[1,2],[3,4]]) )
- mats.append( numpy.kron(mats[2],[[1,2],[3,4]]) )
- mats.append( numpy.kron(mats[3],[[1,2],[3,4]]) )
- mats.append( numpy.kron(mats[3],[[1,2,3,4]]) )
+ mats.append( kron(mats[0],[[1,2]]) )
+ mats.append( kron(mats[0],[[1],[2]]) )
+ mats.append( kron(mats[1],[[1,2],[3,4]]) )
+ mats.append( kron(mats[2],[[1,2],[3,4]]) )
+ mats.append( kron(mats[3],[[1,2],[3,4]]) )
+ mats.append( kron(mats[3],[[1,2,3,4]]) )
for m in mats:
assert_equal(self.spmatrix(m).diagonal(),diag(m))
@@ -257,7 +258,7 @@
assert_array_equal((self.datsp / self.datsp).todense(),expected)
denom = self.spmatrix(matrix([[1,0,0,4],[-1,0,0,0],[0,8,0,-5]],'d'))
- res = matrix([[1,0,0,0.5],[-3,0,numpy.inf,0],[0,0.25,0,0]],'d')
+ res = matrix([[1,0,0,0.5],[-3,0,inf,0],[0,0.25,0,0]],'d')
assert_array_equal((self.datsp / denom).todense(),res)
# complex
@@ -421,7 +422,7 @@
def test_tobsr(self):
x = array([[1,0,2,0],[0,0,0,0],[0,0,4,5]])
y = array([[0,1,2],[3,0,5]])
- A = numpy.kron(x,y)
+ A = kron(x,y)
Asp = self.spmatrix(A)
for format in ['bsr']:
fn = getattr(Asp, 'to' + format )
@@ -584,16 +585,16 @@
Wagner for a 64-bit machine, 02 March 2005 (EJS)
"""
n = 20
- numpy.random.seed(0) #make tests repeatable
+ np.random.seed(0) #make tests repeatable
A = zeros((n,n), dtype=complex)
- x = numpy.random.rand(n)
- y = numpy.random.rand(n-1)+1j*numpy.random.rand(n-1)
- r = numpy.random.rand(n)
+ x = np.random.rand(n)
+ y = np.random.rand(n-1)+1j*np.random.rand(n-1)
+ r = np.random.rand(n)
for i in range(len(x)):
A[i,i] = x[i]
for i in range(len(y)):
A[i,i+1] = y[i]
- A[i+1,i] = numpy.conjugate(y[i])
+ A[i+1,i] = conjugate(y[i])
A = self.spmatrix(A)
x = splu(A).solve(r)
assert_almost_equal(A*x,r)
@@ -764,7 +765,7 @@
# Check bug reported by Robert Cimrman:
# http://thread.gmane.org/gmane.comp.python.scientific.devel/7986
- s = slice(numpy.int8(2),numpy.int8(4),None)
+ s = slice(int8(2),int8(4),None)
assert_equal(A[s,:].todense(), B[2:4,:])
assert_equal(A[:,s].todense(), B[:,2:4])
@@ -920,9 +921,9 @@
def test_constructor4(self):
"""using (data, ij) format"""
- row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
- col = numpy.array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
- data = numpy.array([ 6., 10., 3., 9., 1., 4.,
+ row = array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
+ col = array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
+ data = array([ 6., 10., 3., 9., 1., 4.,
11., 2., 8., 5., 7.])
ij = vstack((row,col))
@@ -994,9 +995,9 @@
def test_constructor4(self):
"""using (data, ij) format"""
- row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
- col = numpy.array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
- data = numpy.array([ 6., 10., 3., 9., 1., 4.,
+ row = array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
+ col = array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
+ data = array([ 6., 10., 3., 9., 1., 4.,
11., 2., 8., 5., 7.])
ij = vstack((row,col))
@@ -1295,9 +1296,9 @@
spmatrix = coo_matrix
def test_constructor1(self):
"""unsorted triplet format"""
- row = numpy.array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
- col = numpy.array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
- data = numpy.array([ 6., 10., 3., 9., 1., 4.,
+ row = array([2, 3, 1, 3, 0, 1, 3, 0, 2, 1, 2])
+ col = array([0, 1, 0, 0, 1, 1, 2, 2, 2, 2, 1])
+ data = array([ 6., 10., 3., 9., 1., 4.,
11., 2., 8., 5., 7.])
coo = coo_matrix((data,(row,col)),(4,3))
@@ -1306,9 +1307,9 @@
def test_constructor2(self):
"""unsorted triplet format with duplicates (which are summed)"""
- row = numpy.array([0,1,2,2,2,2,0,0,2,2])
- col = numpy.array([0,2,0,2,1,1,1,0,0,2])
- data = numpy.array([2,9,-4,5,7,0,-1,2,1,-5])
+ row = array([0,1,2,2,2,2,0,0,2,2])
+ col = array([0,2,0,2,1,1,1,0,0,2])
+ data = array([2,9,-4,5,7,0,-1,2,1,-5])
coo = coo_matrix((data,(row,col)),(3,3))
mat = matrix([[4,-1,0],[0,0,9],[-3,7,0]])
@@ -1327,14 +1328,14 @@
def test_constructor4(self):
"""from dense matrix"""
- mat = numpy.array([[0,1,0,0],
+ mat = array([[0,1,0,0],
[7,0,3,0],
[0,4,0,0]])
coo = coo_matrix(mat)
assert_array_equal(coo.todense(),mat)
#upgrade rank 1 arrays to row matrix
- mat = numpy.array([0,1,0,0])
+ mat = array([0,1,0,0])
coo = coo_matrix(mat)
assert_array_equal(coo.todense(),mat.reshape(1,-1))
@@ -1366,7 +1367,7 @@
data[3] = array([[ 0, 5, 10],
[15, 0, 25]])
- A = numpy.kron( [[1,0,2,0],[0,0,0,0],[0,0,4,5]], [[0,1,2],[3,0,5]] )
+ A = kron( [[1,0,2,0],[0,0,0,0],[0,0,4,5]], [[0,1,2],[3,0,5]] )
Asp = bsr_matrix((data,indices,indptr),shape=(6,12))
assert_equal(Asp.todense(),A)
@@ -1385,7 +1386,7 @@
assert_equal(bsr_matrix(A,blocksize=(2,2)).todense(),A)
assert_equal(bsr_matrix(A,blocksize=(2,3)).todense(),A)
- A = numpy.kron( [[1,0,2,0],[0,0,0,0],[0,0,4,5]], [[0,1,2],[3,0,5]] )
+ A = kron( [[1,0,2,0],[0,0,0,0],[0,0,4,5]], [[0,1,2],[3,0,5]] )
assert_equal(bsr_matrix(A).todense(),A)
assert_equal(bsr_matrix(A,shape=(6,12)).todense(),A)
assert_equal(bsr_matrix(A,blocksize=(1,1)).todense(),A)
@@ -1395,11 +1396,11 @@
assert_equal(bsr_matrix(A,blocksize=(3,12)).todense(),A)
assert_equal(bsr_matrix(A,blocksize=(6,12)).todense(),A)
- A = numpy.kron( [[1,0,2,0],[0,1,0,0],[0,0,0,0]], [[0,1,2],[3,0,5]] )
+ A = kron( [[1,0,2,0],[0,1,0,0],[0,0,0,0]], [[0,1,2],[3,0,5]] )
assert_equal(bsr_matrix(A,blocksize=(2,3)).todense(),A)
def test_eliminate_zeros(self):
- data = numpy.kron([1, 0, 0, 0, 2, 0, 3, 0], [[1,1],[1,1]]).T
+ data = kron([1, 0, 0, 0, 2, 0, 3, 0], [[1,1],[1,1]]).T
data = data.reshape(-1,2,2)
indices = array( [1, 2, 3, 4, 5, 6, 7, 8] )
indptr = array( [0, 3, 8] )
Modified: trunk/scipy/sparse/tests/test_extract.py
===================================================================
--- trunk/scipy/sparse/tests/test_extract.py 2008-09-18 20:00:22 UTC (rev 4736)
+++ trunk/scipy/sparse/tests/test_extract.py 2008-09-18 21:20:05 UTC (rev 4737)
@@ -1,9 +1,6 @@
"""test sparse matrix construction functions"""
-import numpy
-from numpy import array, matrix
from numpy.testing import *
-
from scipy.sparse import csr_matrix
import numpy as np
More information about the Scipy-svn
mailing list