Permalink
Browse files

DEP: linalg: add _ prefix to *blas, *lapack and deprecate the f2py mo…

…dules from semi-public API

Instead, allow using scipy.linalg.blas / scipy.linalg.lapack
  • Loading branch information...
1 parent 082b39a commit a61b2b359edce537a25a80106850e119604954af @pv committed Nov 17, 2012
View
8 scipy/linalg/bento.info
@@ -1,17 +1,17 @@
HookFile: bscript
Library:
- Extension: fblas
+ Extension: _fblas
Sources:
fblas.pyf.src,
src/fblaswrap.f
- Extension: cblas
+ Extension: _cblas
Sources:
generic_cblas.pyf
- Extension: flapack
+ Extension: _flapack
Sources:
flapack.pyf.src
- Extension: clapack
+ Extension: _clapack
Sources:
generic_clapack.pyf
Extension: _flinalg
View
18 scipy/linalg/blas.py
@@ -111,9 +111,9 @@
# replaced with the available one. If none is available, exception
# is raised at the first attempt to use the resources.
-from scipy.linalg import fblas as _fblas
+from scipy.linalg import _fblas
try:
- from scipy.linalg import cblas as _cblas
+ from scipy.linalg import _cblas
except ImportError:
_cblas = None
if _cblas is None:
@@ -122,7 +122,9 @@
_fblas = _cblas
# Expose all functions (only fblas --- cblas is an implementation detail)
-from scipy.linalg.fblas import *
+empty_module = None
+from scipy.linalg._fblas import *
+del empty_module
# 'd' will be default for 'i',..
_type_conv = {'f':'s', 'd':'d', 'F':'c', 'D':'z', 'G':'z'}
@@ -178,7 +180,8 @@ def find_best_blas_type(arrays=(), dtype=None):
return prefix, dtype, prefer_fortran
def _get_funcs(names, arrays, dtype,
- lib_name, fmodule, cmodule, alias):
+ lib_name, fmodule, cmodule,
+ fmodule_name, cmodule_name, alias):
"""
Return available BLAS/LAPACK functions.
@@ -188,8 +191,8 @@ def _get_funcs(names, arrays, dtype,
funcs = []
unpack = False
dtype = _np.dtype(dtype)
- module1 = (cmodule, cmodule.__name__.split('.')[-1])
- module2 = (fmodule, fmodule.__name__.split('.')[-1])
+ module1 = (cmodule, cmodule_name)
+ module2 = (fmodule, fmodule_name)
if isinstance(names, str):
names = (names,)
@@ -260,4 +263,5 @@ def get_blas_funcs(names, arrays=(), dtype=None):
of the returned functions.
"""
return _get_funcs(names, arrays, dtype,
- "BLAS", _fblas, _cblas, _blas_alias)
+ "BLAS", _fblas, _cblas, "fblas", "cblas",
+ _blas_alias)
View
8 scipy/linalg/bscript
@@ -17,24 +17,24 @@ def pre_build(context):
features="c fc pyext bento cshlib f2py",
source=source,
use="FBLAS CLIB")
- context.register_builder("fblas", fblas_builder)
+ context.register_builder("_fblas", fblas_builder)
def cblas_builder(extension):
if bld.env.HAS_CBLAS:
return default_builder(extension,
features="c fc pyext bento cshlib f2py",
use="CBLAS")
- context.register_builder("cblas", cblas_builder)
+ context.register_builder("_cblas", cblas_builder)
- context.tweak_extension("flapack", features="c fc pyext bento cshlib f2py",
+ context.tweak_extension("_flapack", features="c fc pyext bento cshlib f2py",
use="FLAPACK CLIB")
def builder(extension):
if bld.env.HAS_CLAPACK:
return default_builder(extension,
features="c pyext bento cshlib f2py",
use="CLAPACK")
- context.register_builder("clapack", builder)
+ context.register_builder("_clapack", builder)
context.tweak_extension("_flinalg", features="c fc pyext bento cshlib f2py f2py_fortran",
use="FLAPACK CLIB")
View
11 scipy/linalg/cblas.py
@@ -0,0 +1,11 @@
+"""
+This module is deprecated -- use scipy.linalg.blas instead
+"""
+try:
+ from _cblas import *
+except ImportError:
+ empty_module = True
+import numpy as _np
+@_np.deprecate(old_name="scipy.linalg.cblas", new_name="scipy.linalg.blas")
+def _deprecate(): pass
+_deprecate()
View
4 scipy/linalg/cblas.pyf.src
@@ -6,10 +6,10 @@
! $Revision$ $Date$
!
-python module cblas
+python module _cblas
interface
include "cblas_l1.pyf.src"
end interface
-end python module cblas
+end python module _cblas
View
11 scipy/linalg/clapack.py
@@ -0,0 +1,11 @@
+"""
+This module is deprecated -- use scipy.linalg.lapack instead
+"""
+try:
+ from _clapack import *
+except ImportError:
+ empty_module = True
+import numpy as _np
+@_np.deprecate(old_name="scipy.linalg.clapack", new_name="scipy.linalg.lapack")
+def _deprecate(): pass
+_deprecate()
View
4 scipy/linalg/clapack.pyf.src
@@ -12,7 +12,7 @@
! trtri
!
-python module clapack
+python module _clapack
interface
function <prefix>gesv(n,nrhs,a,piv,b,info,rowmajor)
@@ -202,4 +202,4 @@ python module clapack
end interface
-end python module clapack
+end python module _clapack
View
8 scipy/linalg/fblas.py
@@ -0,0 +1,8 @@
+"""
+This module is deprecated -- use scipy.linalg.blas instead
+"""
+from _fblas import *
+import numpy as _np
+@_np.deprecate(old_name="scipy.linalg.fblas", new_name="scipy.linalg.blas")
+def _deprecate(): pass
+_deprecate()
View
4 scipy/linalg/fblas.pyf.src
@@ -7,12 +7,12 @@
!
-python module fblas
+python module _fblas
interface
include 'fblas_l1.pyf.src'
include 'fblas_l2.pyf.src'
include 'fblas_l3.pyf.src'
end interface
-end python module fblas
+end python module _fblas
View
8 scipy/linalg/flapack.py
@@ -0,0 +1,8 @@
+"""
+This module is deprecated -- use scipy.linalg.lapack instead
+"""
+from _flapack import *
+import numpy as _np
+@_np.deprecate(old_name="scipy.linalg.flapack", new_name="scipy.linalg.lapack")
+def _deprecate(): pass
+_deprecate()
View
4 scipy/linalg/flapack.pyf.src
@@ -11,7 +11,7 @@
! <prefix2=s,d> <ctype2=float,double> <ftype2=real,double precision>
! <prefix2c=c,z> <ftype2c=complex,double complex> <ctype2c=complex_float,complex_double>
-python module flapack
+python module _flapack
interface
include 'flapack_user.pyf.src'
@@ -2142,7 +2142,7 @@ end subroutine zhegvx
end interface
-end python module flapack
+end python module _flapack
! This file was auto-generated with f2py (version:2.10.173).
! See http://cens.ioc.ee/projects/f2py2e/
View
11 scipy/linalg/lapack.py
@@ -208,22 +208,20 @@
# Backward compatibility:
from blas import find_best_blas_type as find_best_lapack_type
-from scipy.linalg import flapack as _flapack
+from scipy.linalg import _flapack
try:
- from scipy.linalg import clapack as _clapack
+ from scipy.linalg import _clapack
except ImportError:
_clapack = None
-_use_force_clapack = 1
if _clapack is None:
_clapack = _flapack
- _use_force_clapack = 0
elif hasattr(_flapack,'empty_module'):
_flapack = _clapack
# Expose all functions (only flapack --- clapack is an implementation detail)
empty_module = None
-from scipy.linalg.flapack import *
+from scipy.linalg._flapack import *
del empty_module
# some convenience alias for complex functions
@@ -271,4 +269,5 @@ def get_lapack_funcs(names, arrays=(), dtype=None):
are stored in attribute `typecode` of the returned functions.
"""
return _get_funcs(names, arrays, dtype,
- "LAPACK", _flapack, _clapack, _lapack_alias)
+ "LAPACK", _flapack, _clapack,
+ "flapack", "clapack", _lapack_alias)
View
4 scipy/linalg/misc.py
@@ -1,6 +1,6 @@
import numpy as np
from numpy.linalg import LinAlgError
-import fblas
+import blas
__all__ = ['LinAlgError', 'norm']
@@ -13,7 +13,7 @@ def norm(a, ord=None):
if ord in (None, 2) and (a.ndim == 1) and (a.dtype.char in 'fdFD'):
# use blas for fast and stable euclidean norm
func_name = _nrm2_prefix.get(a.dtype.char, 'd') + 'nrm2'
- nrm2 = getattr(fblas, func_name)
+ nrm2 = getattr(blas, func_name)
return nrm2(a)
return np.linalg.norm(a, ord=ord)
View
8 scipy/linalg/setup.py
@@ -48,7 +48,7 @@ def configuration(parent_package='',top_path=None):
# Note: `depends` needs to include fblaswrap(_veclib) for both files to be
# included by "python setup.py sdist"
- config.add_extension('fblas',
+ config.add_extension('_fblas',
sources = sources,
depends = ['fblas_l?.pyf.src',
join('src', 'fblaswrap_veclib_c.c'),
@@ -57,22 +57,22 @@ def configuration(parent_package='',top_path=None):
)
# flapack:
- config.add_extension('flapack',
+ config.add_extension('_flapack',
sources = ['flapack.pyf.src'],
depends = ['flapack_user.pyf.src'],
extra_info = lapack_opt
)
if atlas_version is not None:
# cblas:
- config.add_extension('cblas',
+ config.add_extension('_cblas',
sources = ['cblas.pyf.src'],
depends = ['cblas.pyf.src', 'cblas_l1.pyf.src'],
extra_info = lapack_opt
)
# clapack:
- config.add_extension('clapack',
+ config.add_extension('_clapack',
sources = ['clapack.pyf.src'],
depends = ['clapack.pyf.src'],
extra_info = lapack_opt
View
2 scipy/linalg/tests/test_blas.py
@@ -16,7 +16,7 @@
from numpy.testing import TestCase, run_module_suite, assert_equal, \
assert_almost_equal, assert_array_almost_equal
-from scipy.linalg import fblas, cblas, get_blas_funcs
+from scipy.linalg import _fblas as fblas, _cblas as cblas, get_blas_funcs
def test_get_blas_funcs():
# check that it returns Fortran code for arrays that are
View
2 scipy/linalg/tests/test_build.py
@@ -5,7 +5,7 @@
from numpy.testing import TestCase, dec
from numpy.compat import asbytes
-from scipy.linalg import flapack
+from scipy.linalg import _flapack as flapack
# XXX: this is copied from numpy trunk. Can be removed when we will depend on
# numpy 1.3
View
2 scipy/linalg/tests/test_decomp.py
@@ -18,7 +18,7 @@
schur, rsf2csf, lu_solve, lu_factor, solve, diagsvd, hessenberg, rq, \
eig_banded, eigvals_banded, eigh, eigvalsh, qr_multiply, LinAlgError, \
qz
-from scipy.linalg.flapack import dgbtrf, dgbtrs, zgbtrf, zgbtrs, \
+from scipy.linalg.lapack import dgbtrf, dgbtrs, zgbtrf, zgbtrs, \
dsbev, dsbevd, dsbevx, zhbevd, zhbevx
from numpy import array, transpose, sometrue, diag, ones, linalg, \
View
2 scipy/linalg/tests/test_fblas.py
@@ -8,7 +8,7 @@
from numpy import float32, float64, complex64, complex128, arange, array, \
zeros, shape, transpose, newaxis, common_type, conjugate
-from scipy.linalg import fblas
+from scipy.linalg import _fblas as fblas
from numpy.testing import TestCase, run_module_suite, assert_array_equal, \
assert_array_almost_equal, assert_
View
2 scipy/linalg/tests/test_lapack.py
@@ -8,7 +8,7 @@
import numpy as np
-from scipy.linalg import flapack, clapack
+from scipy.linalg import _flapack as flapack, _clapack as clapack
from scipy.linalg.lapack import get_lapack_funcs
REAL_DTYPES = [np.float32, np.float64]

0 comments on commit a61b2b3

Please sign in to comment.