diff --git a/Lib/lib/__init__.py b/Lib/lib/__init__.py index 981211f38761..eb1cd452b180 100644 --- a/Lib/lib/__init__.py +++ b/Lib/lib/__init__.py @@ -1,8 +1,10 @@ -from info_lib import __doc__ +from info import __doc__ __all__ = ['lapack','blas'] +#from scipy.utils import ppimport +#lapack = ppimport('lapack') +#blas = ppimport('blas') -from scipy.base import ppimport -lapack = ppimport('lapack') -blas = ppimport('blas') +import blas +import lapack diff --git a/Lib/lib/blas/__init__.py b/Lib/lib/blas/__init__.py index 9782fcbae36b..5d44baab9b75 100644 --- a/Lib/lib/blas/__init__.py +++ b/Lib/lib/blas/__init__.py @@ -2,7 +2,7 @@ # BLAS wrappers # -from info_blas import __doc__ +from info import __doc__ __all__ = ['fblas','cblas','get_blas_funcs'] @@ -25,7 +25,7 @@ def get_blas_funcs(names,arrays=(),debug=0): BLAS routines.""" ordering = [] for i in range(len(arrays)): - t = arrays[i].typecode() + t = arrays[i].dtypechar if not _type_conv.has_key(t): t = 'd' ordering.append((t,i)) if ordering: diff --git a/Lib/lib/blas/info_blas.py b/Lib/lib/blas/info.py similarity index 100% rename from Lib/lib/blas/info_blas.py rename to Lib/lib/blas/info.py diff --git a/Lib/lib/blas/setup_blas.py b/Lib/lib/blas/setup.py similarity index 62% rename from Lib/lib/blas/setup_blas.py rename to Lib/lib/blas/setup.py index 3151d2193383..3c68e0cac64d 100755 --- a/Lib/lib/blas/setup_blas.py +++ b/Lib/lib/blas/setup.py @@ -32,18 +32,11 @@ end python module cblas ''' -def configuration(parent_package='',parent_path=None): - from scipy.distutils.core import Extension - from scipy.distutils.misc_util import dot_join, get_path, default_config_dict - from scipy.distutils.system_info import get_info, dict_append - - package = 'blas' - config = default_config_dict(package,parent_package) - local_path = get_path(__name__,parent_path) - def local_join(*paths): - return os.path.join(*((local_path,)+paths)) - def local_glob(path): - return glob(os.path.join(local_path,path)) +def configuration(parent_package='',top_path=None): + from scipy.distutils.misc_util import Configuration + from scipy.distutils.system_info import get_info + + config = Configuration('blas',parent_package,top_path) blas_opt = get_info('blas_opt',notfound_action=2) @@ -70,16 +63,12 @@ def local_glob(path): 'drotmg srotmg drotm srotm'.split()) # fblas: - ext_args = {} - dict_append(ext_args, - name = dot_join(parent_package,package,'fblas'), - sources = [local_join('fblas.pyf.src'), - local_join('fblaswrap.f.src')], - depends = [__file__]+local_glob('fblas_l?.pyf.src'), - f2py_options = ['skip:']+skip_names['fblas']+[':']) - dict_append(ext_args,**blas_opt) - ext = Extension(**ext_args) - config['ext_modules'].append(ext) + config.add_extension('fblas', + sources = ['fblas.pyf.src','fblaswrap.f.src'], + depends = [__file__,'fblas_l?.pyf.src'], + f2py_options = ['skip:']+skip_names['fblas']+[':'], + extra_info = blas_opt + ) # cblas: def get_cblas_source(ext, build_dir): @@ -97,19 +86,17 @@ def get_cblas_source(ext, build_dir): assert os.path.basename(target)=='cblas.pyf.src' return target - ext_args = {} - dict_append(ext_args, - name = dot_join(parent_package,package,'cblas'), - sources = [get_cblas_source], - depends = [local_join('cblas.pyf.src')] \ - + local_glob('cblas_l?.pyf.src'), - f2py_options = ['skip:']+skip_names['cblas']+[':']) - dict_append(ext_args,**blas_opt) - ext = Extension(**ext_args) - config['ext_modules'].append(ext) + config.add_extension('cblas', + sources = [get_cblas_source], + depends = ['cblas.pyf.src','cblas_l?.pyf.src'], + f2py_options = ['skip:']+skip_names['cblas']+[':'], + extra_info = blas_opt + ) + + config.add_data_dir('tests') return config if __name__ == '__main__': from scipy.distutils.core import setup - setup(**configuration(parent_path='')) + setup(**configuration(top_path='').todict()) diff --git a/Lib/lib/blas/tests/test_blas.py b/Lib/lib/blas/tests/test_blas.py index 9b72b35e8851..c52d18991b7e 100644 --- a/Lib/lib/blas/tests/test_blas.py +++ b/Lib/lib/blas/tests/test_blas.py @@ -13,11 +13,11 @@ """ -from Numeric import arange, add, array +from scipy.base import arange, add, array import math import sys -from scipy_test.testing import * +from scipy.test.testing import * set_package_path() from blas import fblas from blas import cblas diff --git a/Lib/lib/blas/tests/test_fblas.py b/Lib/lib/blas/tests/test_fblas.py index fc03dea69465..2a5e05d78d05 100644 --- a/Lib/lib/blas/tests/test_fblas.py +++ b/Lib/lib/blas/tests/test_fblas.py @@ -15,11 +15,10 @@ # !! ever !replaced! by a blas call, we'll need to fill in a simple # !! matrix multiply here to ensure integrity of tests. -from Numeric import * -from scipy.base.fastumath import * +from scipy.base import * import sys -from scipy_test.testing import * +from scipy.test.testing import * set_package_path() from blas import fblas del sys.path[0] @@ -34,39 +33,39 @@ class base_axpy(unittest.TestCase): def check_default_a(self): - x = arange(3.,typecode=self.typecode) - y = arange(3.,typecode=x.typecode()) + x = arange(3.,dtype=self.dtype) + y = arange(3.,dtype=x.dtype) real_y = x*1.+y self.blas_func(x,y) - assert_array_equal(real_y,y) + assert_array_almost_equal(real_y,y) def check_simple(self): - x = arange(3.,typecode=self.typecode) - y = arange(3.,typecode=x.typecode()) + x = arange(3.,dtype=self.dtype) + y = arange(3.,dtype=x.dtype) real_y = x*3.+y self.blas_func(x,y,a=3.) - assert_array_equal(real_y,y) + assert_array_almost_equal(real_y,y) def check_x_stride(self): - x = arange(6.,typecode=self.typecode) - y = zeros(3,x.typecode()) - y = arange(3.,typecode=x.typecode()) + x = arange(6.,dtype=self.dtype) + y = zeros(3,x.dtype) + y = arange(3.,dtype=x.dtype) real_y = x[::2]*3.+y self.blas_func(x,y,a=3.,n=3,incx=2) - assert_array_equal(real_y,y) + assert_array_almost_equal(real_y,y) def check_y_stride(self): - x = arange(3.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(3.,dtype=self.dtype) + y = zeros(6,x.dtype) real_y = x*3.+y[::2] self.blas_func(x,y,a=3.,n=3,incy=2) - assert_array_equal(real_y,y[::2]) + assert_array_almost_equal(real_y,y[::2]) def check_x_and_y_stride(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) real_y = x[::4]*3.+y[::2] self.blas_func(x,y,a=3.,n=3,incx=4,incy=2) - assert_array_equal(real_y,y[::2]) + assert_array_almost_equal(real_y,y[::2]) def check_x_bad_size(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=4,incx=5) except: # what kind of error should be caught? @@ -74,8 +73,8 @@ def check_x_bad_size(self): # should catch error and never get here assert(0) def check_y_bad_size(self): - x = arange(12.,typecode=Complex32) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=complex64) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=3,incy=5) except: # what kind of error should be caught? @@ -86,21 +85,21 @@ def check_y_bad_size(self): try: class test_saxpy(base_axpy): blas_func = fblas.saxpy - typecode = Float32 + dtype = float32 except AttributeError: class test_saxpy: pass class test_daxpy(base_axpy): blas_func = fblas.daxpy - typecode = Float + dtype = float64 try: class test_caxpy(base_axpy): blas_func = fblas.caxpy - typecode = Complex32 + dtype = complex64 except AttributeError: class test_caxpy: pass class test_zaxpy(base_axpy): blas_func = fblas.zaxpy - typecode = Complex + dtype = complex128 ################################################## @@ -108,18 +107,18 @@ class test_zaxpy(base_axpy): class base_scal(unittest.TestCase): def check_simple(self): - x = arange(3.,typecode=self.typecode) + x = arange(3.,dtype=self.dtype) real_x = x*3. self.blas_func(3.,x) - assert_array_equal(real_x,x) + assert_array_almost_equal(real_x,x) def check_x_stride(self): - x = arange(6.,typecode=self.typecode) + x = arange(6.,dtype=self.dtype) real_x = x.copy() - real_x[::2] = x[::2]*array(3.,self.typecode) + real_x[::2] = x[::2]*array(3.,self.dtype) self.blas_func(3.,x,n=3,incx=2) - assert_array_equal(real_x,x) + assert_array_almost_equal(real_x,x) def check_x_bad_size(self): - x = arange(12.,typecode=self.typecode) + x = arange(12.,dtype=self.dtype) try: self.blas_func(2.,x,n=4,incx=5) except: # what kind of error should be caught? @@ -129,21 +128,21 @@ def check_x_bad_size(self): try: class test_sscal(base_scal): blas_func = fblas.sscal - typecode = Float32 + dtype = float32 except AttributeError: class test_sscal: pass class test_dscal(base_scal): blas_func = fblas.dscal - typecode = Float + dtype = float64 try: class test_cscal(base_scal): blas_func = fblas.cscal - typecode = Complex32 + dtype = complex64 except AttributeError: class test_cscal: pass class test_zscal(base_scal): blas_func = fblas.zscal - typecode = Complex + dtype = complex128 @@ -153,28 +152,28 @@ class test_zscal(base_scal): class base_copy(unittest.TestCase): def check_simple(self): - x = arange(3.,typecode=self.typecode) - y = zeros(shape(x),x.typecode()) + x = arange(3.,dtype=self.dtype) + y = zeros(shape(x),x.dtype) self.blas_func(x,y) - assert_array_equal(x,y) + assert_array_almost_equal(x,y) def check_x_stride(self): - x = arange(6.,typecode=self.typecode) - y = zeros(3,x.typecode()) + x = arange(6.,dtype=self.dtype) + y = zeros(3,x.dtype) self.blas_func(x,y,n=3,incx=2) - assert_array_equal(x[::2],y) + assert_array_almost_equal(x[::2],y) def check_y_stride(self): - x = arange(3.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(3.,dtype=self.dtype) + y = zeros(6,x.dtype) self.blas_func(x,y,n=3,incy=2) - assert_array_equal(x,y[::2]) + assert_array_almost_equal(x,y[::2]) def check_x_and_y_stride(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) self.blas_func(x,y,n=3,incx=4,incy=2) - assert_array_equal(x[::4],y[::2]) + assert_array_almost_equal(x[::4],y[::2]) def check_x_bad_size(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=4,incx=5) except: # what kind of error should be caught? @@ -182,8 +181,8 @@ def check_x_bad_size(self): # should catch error and never get here assert(0) def check_y_bad_size(self): - x = arange(12.,typecode=Complex32) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=complex64) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=3,incy=5) except: # what kind of error should be caught? @@ -192,29 +191,29 @@ def check_y_bad_size(self): assert(0) #def check_y_bad_type(self): ## Hmmm. Should this work? What should be the output. - # x = arange(3.,typecode=self.typecode) + # x = arange(3.,dtype=self.dtype) # y = zeros(shape(x)) # self.blas_func(x,y) - # assert_array_equal(x,y) + # assert_array_almost_equal(x,y) try: class test_scopy(base_copy): blas_func = fblas.scopy - typecode = Float32 + dtype = float32 except AttributeError: class test_scopy: pass class test_dcopy(base_copy): blas_func = fblas.dcopy - typecode = Float + dtype = float64 try: class test_ccopy(base_copy): blas_func = fblas.ccopy - typecode = Complex32 + dtype = complex64 except AttributeError: class test_ccopy: pass class test_zcopy(base_copy): blas_func = fblas.zcopy - typecode = Complex + dtype = complex128 ################################################## @@ -222,41 +221,41 @@ class test_zcopy(base_copy): class base_swap(unittest.TestCase): def check_simple(self): - x = arange(3.,typecode=self.typecode) - y = zeros(shape(x),x.typecode()) + x = arange(3.,dtype=self.dtype) + y = zeros(shape(x),x.dtype) desired_x = y.copy() desired_y = x.copy() self.blas_func(x,y) - assert_array_equal(desired_x,x) - assert_array_equal(desired_y,y) + assert_array_almost_equal(desired_x,x) + assert_array_almost_equal(desired_y,y) def check_x_stride(self): - x = arange(6.,typecode=self.typecode) - y = zeros(3,x.typecode()) + x = arange(6.,dtype=self.dtype) + y = zeros(3,x.dtype) desired_x = y.copy() desired_y = x.copy()[::2] self.blas_func(x,y,n=3,incx=2) - assert_array_equal(desired_x,x[::2]) - assert_array_equal(desired_y,y) + assert_array_almost_equal(desired_x,x[::2]) + assert_array_almost_equal(desired_y,y) def check_y_stride(self): - x = arange(3.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(3.,dtype=self.dtype) + y = zeros(6,x.dtype) desired_x = y.copy()[::2] desired_y = x.copy() self.blas_func(x,y,n=3,incy=2) - assert_array_equal(desired_x,x) - assert_array_equal(desired_y,y[::2]) + assert_array_almost_equal(desired_x,x) + assert_array_almost_equal(desired_y,y[::2]) def check_x_and_y_stride(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) desired_x = y.copy()[::2] desired_y = x.copy()[::4] self.blas_func(x,y,n=3,incx=4,incy=2) - assert_array_equal(desired_x,x[::4]) - assert_array_equal(desired_y,y[::2]) + assert_array_almost_equal(desired_x,x[::4]) + assert_array_almost_equal(desired_y,y[::2]) def check_x_bad_size(self): - x = arange(12.,typecode=self.typecode) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=self.dtype) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=4,incx=5) except: # what kind of error should be caught? @@ -264,8 +263,8 @@ def check_x_bad_size(self): # should catch error and never get here assert(0) def check_y_bad_size(self): - x = arange(12.,typecode=Complex32) - y = zeros(6,x.typecode()) + x = arange(12.,dtype=complex64) + y = zeros(6,x.dtype) try: self.blas_func(x,y,n=3,incy=5) except: # what kind of error should be caught? @@ -276,21 +275,21 @@ def check_y_bad_size(self): try: class test_sswap(base_swap): blas_func = fblas.sswap - typecode = Float32 + dtype = float32 except AttributeError: class test_sswap: pass class test_dswap(base_swap): blas_func = fblas.dswap - typecode = Float + dtype = float64 try: class test_cswap(base_swap): blas_func = fblas.cswap - typecode = Complex32 + dtype = complex64 except AttributeError: class test_cswap: pass class test_zswap(base_swap): blas_func = fblas.zswap - typecode = Complex + dtype = complex128 ################################################## ### Test blas ?gemv @@ -298,46 +297,46 @@ class test_zswap(base_swap): class base_gemv(unittest.TestCase): def get_data(self,x_stride=1,y_stride=1): - mult = array(1, typecode = self.typecode) - if self.typecode in ['F', 'D']: - mult = array(1+1j, typecode = self.typecode) - from RandomArray import normal - alpha = array(1., typecode = self.typecode) * mult - beta = array(1.,typecode = self.typecode) * mult - a = normal(0.,1.,(3,3)).astype(self.typecode) * mult - x = arange(shape(a)[0]*x_stride,typecode=self.typecode) * mult - y = arange(shape(a)[1]*y_stride,typecode=self.typecode) * mult + mult = array(1, dtype = self.dtype) + if self.dtype in ['F', 'D']: + mult = array(1+1j, dtype = self.dtype) + from scipy.basic.random import normal + alpha = array(1., dtype = self.dtype) * mult + beta = array(1.,dtype = self.dtype) * mult + a = normal(0.,1.,(3,3)).astype(self.dtype) * mult + x = arange(shape(a)[0]*x_stride,dtype=self.dtype) * mult + y = arange(shape(a)[1]*y_stride,dtype=self.dtype) * mult return alpha,beta,a,x,y def check_simple(self): alpha,beta,a,x,y = self.get_data() desired_y = alpha*matrixmultiply(a,x)+beta*y y = self.blas_func(alpha,a,x,beta,y) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_default_beta_y(self): alpha,beta,a,x,y = self.get_data() desired_y = matrixmultiply(a,x) y = self.blas_func(1,a,x) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_simple_transpose(self): alpha,beta,a,x,y = self.get_data() desired_y = alpha*matrixmultiply(transpose(a),x)+beta*y y = self.blas_func(alpha,a,x,beta,y,trans=1) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_simple_transpose_conj(self): alpha,beta,a,x,y = self.get_data() desired_y = alpha*matrixmultiply(transpose(conjugate(a)),x)+beta*y y = self.blas_func(alpha,a,x,beta,y,trans=2) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_x_stride(self): alpha,beta,a,x,y = self.get_data(x_stride=2) desired_y = alpha*matrixmultiply(a,x[::2])+beta*y y = self.blas_func(alpha,a,x,beta,y,incx=2) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_x_stride_transpose(self): alpha,beta,a,x,y = self.get_data(x_stride=2) desired_y = alpha*matrixmultiply(transpose(a),x[::2])+beta*y y = self.blas_func(alpha,a,x,beta,y,trans=1,incx=2) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_x_stride_assert(self): # What is the use of this test? alpha,beta,a,x,y = self.get_data(x_stride=2) @@ -356,13 +355,13 @@ def check_y_stride(self): desired_y = y.copy() desired_y[::2] = alpha*matrixmultiply(a,x)+beta*y[::2] y = self.blas_func(alpha,a,x,beta,y,incy=2) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_y_stride_transpose(self): alpha,beta,a,x,y = self.get_data(y_stride=2) desired_y = y.copy() desired_y[::2] = alpha*matrixmultiply(transpose(a),x)+beta*y[::2] y = self.blas_func(alpha,a,x,beta,y,trans=1,incy=2) - assert(allclose(desired_y,y)) + assert_array_almost_equal(desired_y,y) def check_y_stride_assert(self): # What is the use of this test? alpha,beta,a,x,y = self.get_data(y_stride=2) @@ -380,21 +379,21 @@ def check_y_stride_assert(self): try: class test_sgemv(base_gemv): blas_func = fblas.sgemv - typecode = Float32 + dtype = float32 except AttributeError: class test_sgemv: pass class test_dgemv(base_gemv): blas_func = fblas.dgemv - typecode = Float + dtype = float64 try: class test_cgemv(base_gemv): blas_func = fblas.cgemv - typecode = Complex32 + dtype = complex64 except AttributeError: class test_cgemv: pass class test_zgemv(base_gemv): blas_func = fblas.zgemv - typecode = Complex + dtype = complex128 """ ################################################## @@ -403,23 +402,23 @@ class test_zgemv(base_gemv): class base_ger(unittest.TestCase): def get_data(self,x_stride=1,y_stride=1): - from RandomArray import normal - alpha = array(1., typecode = self.typecode) - a = normal(0.,1.,(3,3)).astype(self.typecode) - x = arange(shape(a)[0]*x_stride,typecode=self.typecode) - y = arange(shape(a)[1]*y_stride,typecode=self.typecode) + from scipy.basic.random import normal + alpha = array(1., dtype = self.dtype) + a = normal(0.,1.,(3,3)).astype(self.dtype) + x = arange(shape(a)[0]*x_stride,dtype=self.dtype) + y = arange(shape(a)[1]*y_stride,dtype=self.dtype) return alpha,a,x,y def check_simple(self): alpha,a,x,y = self.get_data() # tranpose takes care of Fortran vs. C(and Python) memory layout desired_a = alpha*transpose(x[:,NewAxis]*y) + a self.blas_func(x,y,a) - assert(allclose(desired_a,a)) + assert_array_almost_equal(desired_a,a) def check_x_stride(self): alpha,a,x,y = self.get_data(x_stride=2) desired_a = alpha*transpose(x[::2,NewAxis]*y) + a self.blas_func(x,y,a,incx=2) - assert(allclose(desired_a,a)) + assert_array_almost_equal(desired_a,a) def check_x_stride_assert(self): alpha,a,x,y = self.get_data(x_stride=2) try: @@ -431,7 +430,7 @@ def check_y_stride(self): alpha,a,x,y = self.get_data(y_stride=2) desired_a = alpha*transpose(x[:,NewAxis]*y[::2]) + a self.blas_func(x,y,a,incy=2) - assert(allclose(desired_a,a)) + assert_array_almost_equal(desired_a,a) def check_y_stride_assert(self): alpha,a,x,y = self.get_data(y_stride=2) @@ -443,10 +442,10 @@ def check_y_stride_assert(self): class test_sger(base_ger): blas_func = fblas.sger - typecode = Float32 + dtype = float32 class test_dger(base_ger): blas_func = fblas.dger - typecode = Float + dtype = float64 """ ################################################## ### Test blas ?gerc @@ -455,60 +454,60 @@ class test_dger(base_ger): """ class base_ger_complex(base_ger): def get_data(self,x_stride=1,y_stride=1): - from RandomArray import normal - alpha = array(1+1j, typecode = self.typecode) - a = normal(0.,1.,(3,3)).astype(self.typecode) - a = a + normal(0.,1.,(3,3)) * array(1j, typecode = self.typecode) - x = normal(0.,1.,shape(a)[0]*x_stride).astype(self.typecode) - x = x + x * array(1j, typecode = self.typecode) - y = normal(0.,1.,shape(a)[1]*y_stride).astype(self.typecode) - y = y + y * array(1j, typecode = self.typecode) + from scipy.basic.random import normal + alpha = array(1+1j, dtype = self.dtype) + a = normal(0.,1.,(3,3)).astype(self.dtype) + a = a + normal(0.,1.,(3,3)) * array(1j, dtype = self.dtype) + x = normal(0.,1.,shape(a)[0]*x_stride).astype(self.dtype) + x = x + x * array(1j, dtype = self.dtype) + y = normal(0.,1.,shape(a)[1]*y_stride).astype(self.dtype) + y = y + y * array(1j, dtype = self.dtype) return alpha,a,x,y def check_simple(self): alpha,a,x,y = self.get_data() # tranpose takes care of Fortran vs. C(and Python) memory layout - a = a * array(0.,typecode = self.typecode) + a = a * array(0.,dtype = self.dtype) #desired_a = alpha*transpose(x[:,NewAxis]*self.transform(y)) + a desired_a = alpha*transpose(x[:,NewAxis]*y) + a #self.blas_func(x,y,a,alpha = alpha) fblas.cgeru(x,y,a,alpha = alpha) print x, y - print desired_a.typecode(),desired_a + print desired_a.dtype,desired_a print - print a.typecode(),a - assert(allclose(desired_a,a)) + print a.dtype,a + assert_array_almost_equal(desired_a,a) #def check_x_stride(self): # alpha,a,x,y = self.get_data(x_stride=2) # desired_a = alpha*transpose(x[::2,NewAxis]*self.transform(y)) + a # self.blas_func(x,y,a,incx=2) - # assert(allclose(desired_a,a)) + # assert_array_almost_equal(desired_a,a) #def check_y_stride(self): # alpha,a,x,y = self.get_data(y_stride=2) # desired_a = alpha*transpose(x[:,NewAxis]*self.transform(y[::2])) + a # self.blas_func(x,y,a,incy=2) - # assert(allclose(desired_a,a)) + # assert_array_almost_equal(desired_a,a) class test_cgeru(base_ger_complex): blas_func = fblas.cgeru - typecode = Complex32 + dtype = complex64 def transform(self,x): return x class test_zgeru(base_ger_complex): blas_func = fblas.zgeru - typecode = Complex + dtype = complex128 def transform(self,x): return x class test_cgerc(base_ger_complex): blas_func = fblas.cgerc - typecode = Complex32 + dtype = complex64 def transform(self,x): return conjugate(x) class test_zgerc(base_ger_complex): blas_func = fblas.zgerc - typecode = Complex + dtype = complex128 def transform(self,x): return conjugate(x) """ diff --git a/Lib/lib/info_lib.py b/Lib/lib/info.py similarity index 100% rename from Lib/lib/info_lib.py rename to Lib/lib/info.py diff --git a/Lib/lib/lapack/__init__.py b/Lib/lib/lapack/__init__.py index 12de0f64bd29..ad9a32384815 100644 --- a/Lib/lib/lapack/__init__.py +++ b/Lib/lib/lapack/__init__.py @@ -2,7 +2,7 @@ # LAPACK wrappers # -from info_lapack import __doc__ +from info import __doc__ __all__ = ['get_lapack_funcs','calc_lwork','flapack','clapack'] @@ -39,7 +39,7 @@ def get_lapack_funcs(names,arrays=(),debug=0,force_clapack=1): ordering = [] for i in range(len(arrays)): - t = arrays[i].typecode() + t = arrays[i].dtypechar if not _type_conv.has_key(t): t = 'd' ordering.append((t,i)) if ordering: diff --git a/Lib/lib/lapack/info_lapack.py b/Lib/lib/lapack/info.py similarity index 100% rename from Lib/lib/lapack/info_lapack.py rename to Lib/lib/lapack/info.py diff --git a/Lib/lib/lapack/setup_lapack.py b/Lib/lib/lapack/setup.py similarity index 56% rename from Lib/lib/lapack/setup_lapack.py rename to Lib/lib/lapack/setup.py index af93fa8082bc..444120e09c8e 100755 --- a/Lib/lib/lapack/setup_lapack.py +++ b/Lib/lib/lapack/setup.py @@ -23,18 +23,11 @@ ''' -def configuration(parent_package='',parent_path=None): - from scipy.distutils.core import Extension - from scipy.distutils.misc_util import dot_join, get_path, default_config_dict - from scipy.distutils.system_info import get_info, dict_append - - package = 'lapack' - config = default_config_dict(package,parent_package) - local_path = get_path(__name__,parent_path) - def local_join(*paths): - return os.path.join(*((local_path,)+paths)) - def local_glob(path): - return glob(os.path.join(local_path,path)) +def configuration(parent_package='',top_path=None): + from scipy.distutils.misc_util import Configuration + from scipy.distutils.system_info import get_info + + config = Configuration('lapack',parent_package,top_path) lapack_opt = get_info('lapack_opt',notfound_action=2) @@ -66,16 +59,12 @@ def local_glob(path): skip_names['clapack'].extend('cpotrf zpotrf'.split()) # flapack: - ext_args = {} - dict_append(ext_args, - name = dot_join(parent_package,package,'flapack'), - sources = [local_join('flapack.pyf.src')], - depends = [__file__]+local_glob('flapack_*.pyf.src'), - f2py_options = ['skip:']+skip_names['flapack']+[':']) - dict_append(ext_args,**lapack_opt) - ext = Extension(**ext_args) - config['ext_modules'].append(ext) - + config.add_extension('flapack', + sources = ['flapack.pyf.src'], + depends = [__file__,'flapack_*.pyf.src'], + f2py_options = ['skip:']+skip_names['flapack']+[':'], + extra_info = lapack_opt + ) # clapack: def get_clapack_source(ext, build_dir): @@ -93,34 +82,30 @@ def get_clapack_source(ext, build_dir): assert os.path.basename(target)=='clapack.pyf.src' return target - ext_args = {} - dict_append(ext_args, - name = dot_join(parent_package,package,'clapack'), - sources = [get_clapack_source], - depends = [local_join('clapack.pyf.src')] \ - + local_glob('clapack_*.pyf.src'), - f2py_options = ['skip:']+skip_names['clapack']+[':']) - dict_append(ext_args,**lapack_opt) - ext = Extension(**ext_args) - config['ext_modules'].append(ext) + config.add_extension('clapack', + sources = [get_clapack_source], + depends = ['clapack.pyf.src'], + f2py_options = ['skip:']+skip_names['clapack']+[':'], + extra_info = lapack_opt + ) # calc_lwork: - ext_args = {'name':dot_join(parent_package,package,'calc_lwork'), - 'sources':[local_join('calc_lwork.f')], - } - dict_append(ext_args,**lapack_opt) - config['ext_modules'].append(Extension(**ext_args)) + config.add_extension('calc_lwork', + sources = ['calc_lwork.f'], + extra_info = lapack_opt + ) # atlas_version: - ext_args = {'name':dot_join(parent_package,package,'atlas_version'), - 'sources':[os.path.join(local_path,'atlas_version.c')]} - dict_append(ext_args,**lapack_opt) - ext = Extension(**ext_args) - config['ext_modules'].append(ext) + config.add_extension('atlas_version', + sources = ['atlas_version.c'], + extra_info = lapack_opt + ) + + config.add_data_dir('tests') return config if __name__ == '__main__': from scipy.distutils.core import setup - setup(**configuration(parent_path='')) + setup(**configuration(top_path='').todict()) diff --git a/Lib/lib/lapack/tests/esv_tests.py b/Lib/lib/lapack/tests/esv_tests.py index c7ee5ada1a16..a25be5207aaf 100644 --- a/Lib/lib/lapack/tests/esv_tests.py +++ b/Lib/lib/lapack/tests/esv_tests.py @@ -1,5 +1,5 @@ -from scipy_test.testing import * +from scipy.test.testing import * from scipy.base import * class _test_ev: diff --git a/Lib/lib/lapack/tests/gesv_tests.py b/Lib/lib/lapack/tests/gesv_tests.py index 78784ce97423..d424b896b2be 100644 --- a/Lib/lib/lapack/tests/gesv_tests.py +++ b/Lib/lib/lapack/tests/gesv_tests.py @@ -1,5 +1,5 @@ -from scipy_test.testing import * +from scipy.test.testing import * from scipy.base import * class _test_gev: diff --git a/Lib/lib/lapack/tests/test_lapack.py b/Lib/lib/lapack/tests/test_lapack.py index c6da77e1c892..a4fdcc536077 100644 --- a/Lib/lib/lapack/tests/test_lapack.py +++ b/Lib/lib/lapack/tests/test_lapack.py @@ -13,7 +13,7 @@ """ import sys -from scipy_test.testing import * +from scipy.test.testing import * from scipy.base import * set_package_path() diff --git a/Lib/lib/setup.py b/Lib/lib/setup.py new file mode 100644 index 000000000000..1a85d2ff8eea --- /dev/null +++ b/Lib/lib/setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +def configuration(parent_package='',top_path=None): + from scipy.distutils.misc_util import Configuration + + config = Configuration('lib',parent_package,top_path) + config.add_subpackage('blas') + config.add_subpackage('lapack') + + return config + +if __name__ == '__main__': + from scipy.distutils.core import setup + + setup(**configuration(top_path='').todict()) diff --git a/Lib/lib/setup_lib.py b/Lib/lib/setup_lib.py deleted file mode 100644 index abbbf3dabcfa..000000000000 --- a/Lib/lib/setup_lib.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -def configuration(parent_package='',parent_path=None): - from scipy.distutils.misc_util import dot_join, get_path,\ - default_config_dict, merge_config_dicts, get_subpackages - - package = 'lib' - config = default_config_dict(package,parent_package) - local_path = get_path(__name__,parent_path) - - config_list = [config] - config_list += get_subpackages(local_path, - parent=config['name'], - parent_path=parent_path) - - config_dict = merge_config_dicts(config_list) - - config = merge_config_dicts(config_list) - return config - -if __name__ == '__main__': - from scipy.distutils.core import setup - - setup(**configuration(parent_path='')) diff --git a/Lib/setup.py b/Lib/setup.py index 38061764d8b4..fe736c5fdff0 100644 --- a/Lib/setup.py +++ b/Lib/setup.py @@ -15,6 +15,7 @@ def configuration(parent_package='',top_path=None): config.add_subpackage('interpolate') config.add_subpackage('sparse') config.add_subpackage('cluster') + config.add_subpackage('lib') config.make_svn_version_py() # installs __svn_version__.py config.make_config_py('__scipy_config__') return config diff --git a/Lib/stats/tests/test_distributions.py b/Lib/stats/tests/test_distributions.py index bb3b947b8f56..5c165c6f91dc 100644 --- a/Lib/stats/tests/test_distributions.py +++ b/Lib/stats/tests/test_distributions.py @@ -67,7 +67,7 @@ def check_cdf(self): #if (pval < %f): # D,pval = stats.kstest('%s','',args=%s,N=30) assert (pval > %f), "D = " + str(D) + "; pval = " + str(pval) + "; alpha = " + str(alpha) + "\nargs = " + str(%s) -""" % (dist,dist,dist,args,alpha,dist,args,alpha,dist,args,alpha,args) +""" % (dist,dist,args,alpha,dist,args,alpha,dist,args,alpha,args) exec exstr