[Scipy-svn] r6899 - in trunk/scipy/linalg: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Nov 14 16:17:52 EST 2010
Author: warren.weckesser
Date: 2010-11-14 15:17:52 -0600 (Sun, 14 Nov 2010)
New Revision: 6899
Modified:
trunk/scipy/linalg/basic.py
trunk/scipy/linalg/tests/test_basic.py
Log:
DEP: linalg: change return value of solveh_banded to just the solution (see the 0.8.0 release notes)
Modified: trunk/scipy/linalg/basic.py
===================================================================
--- trunk/scipy/linalg/basic.py 2010-11-14 21:02:56 UTC (rev 6898)
+++ trunk/scipy/linalg/basic.py 2010-11-14 21:17:52 UTC (rev 6899)
@@ -6,8 +6,6 @@
__all__ = ['solve', 'solve_triangular', 'solveh_banded', 'solve_banded',
'inv', 'det', 'lstsq', 'pinv', 'pinv2']
-from warnings import warn
-
from numpy import asarray, zeros, sum, conjugate, dot, transpose, \
asarray_chkfinite, single
import numpy
@@ -227,19 +225,10 @@
Returns
-------
- c : array, shape (u+1, M)
- Cholesky factorization of a, in the same banded format as ab
x : array, shape (M,) or (M, K)
The solution to the system a x = b
-
- Notes
- -----
- The inclusion of `c` in the return value is deprecated. In SciPy
- version 0.9, the return value will be the solution `x` only.
"""
- warn("In SciPy 0.9, the return value of solveh_banded will be "
- "the solution x only.", DeprecationWarning)
ab, b = map(asarray_chkfinite, (ab, b))
@@ -255,7 +244,7 @@
if info < 0:
raise ValueError('illegal value in %d-th argument of internal pbsv'
% -info)
- return c, x
+ return x
# matrix inversion
Modified: trunk/scipy/linalg/tests/test_basic.py
===================================================================
--- trunk/scipy/linalg/tests/test_basic.py 2010-11-14 21:02:56 UTC (rev 6898)
+++ trunk/scipy/linalg/tests/test_basic.py 2010-11-14 21:17:52 UTC (rev 6899)
@@ -19,10 +19,8 @@
python tests/test_basic.py
"""
-import warnings
-
from numpy import arange, array, dot, zeros, identity, conjugate, transpose, \
- float32, zeros_like
+ float32
import numpy.linalg as linalg
from numpy.testing import TestCase, rand, run_module_suite, assert_raises, \
@@ -101,12 +99,8 @@
class TestSolveHBanded(TestCase):
- # solveh_banded currently has a DeprecationWarning. When the warning
- # is removed in scipy 0.9, the 'ignore' filters and the test for the
- # warning can be removed.
def test_01_upper(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1]
# [ 1 4 1] X = [4]
@@ -114,17 +108,10 @@
# with the RHS as a 1D array.
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
b = array([1.0, 4.0, 1.0])
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
- # Remove the following part of this test in scipy 0.9.
- a = array([[4.0, 1.0, 0.0], [1.0, 4.0, 1.0], [0.0, 1.0, 4.0]])
- fac = zeros_like(a)
- fac[range(3),range(3)] = c[-1]
- fac[(0,1),(1,2)] = c[0,1:]
- assert_array_almost_equal(a, dot(fac.T, fac))
def test_02_upper(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1 4]
# [ 1 4 1] X = [4 2]
@@ -135,14 +122,13 @@
b = array([[1.0, 4.0],
[4.0, 2.0],
[1.0, 4.0]])
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
expected = array([[0.0, 1.0],
[1.0, 0.0],
[0.0, 1.0]])
assert_array_almost_equal(x, expected)
def test_03_upper(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1]
# [ 1 4 1] X = [4]
@@ -150,11 +136,10 @@
# with the RHS as a 2D array with shape (3,1).
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
b = array([1.0, 4.0, 1.0]).reshape(-1,1)
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
assert_array_almost_equal(x, array([0.0, 1.0, 0.0]).reshape(-1,1))
def test_01_lower(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1]
# [ 1 4 1] X = [4]
@@ -163,11 +148,10 @@
ab = array([[4.0, 4.0, 4.0],
[1.0, 1.0, -99]])
b = array([1.0, 4.0, 1.0])
- c, x = solveh_banded(ab, b, lower=True)
+ x = solveh_banded(ab, b, lower=True)
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
def test_02_lower(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1 4]
# [ 1 4 1] X = [4 2]
@@ -178,14 +162,13 @@
b = array([[1.0, 4.0],
[4.0, 2.0],
[1.0, 4.0]])
- c, x = solveh_banded(ab, b, lower=True)
+ x = solveh_banded(ab, b, lower=True)
expected = array([[0.0, 1.0],
[1.0, 0.0],
[0.0, 1.0]])
assert_array_almost_equal(x, expected)
def test_01_float32(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1]
# [ 1 4 1] X = [4]
@@ -193,11 +176,10 @@
#
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]], dtype=float32)
b = array([1.0, 4.0, 1.0], dtype=float32)
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
def test_02_float32(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 1 0] [1 4]
# [ 1 4 1] X = [4 2]
@@ -208,14 +190,13 @@
b = array([[1.0, 4.0],
[4.0, 2.0],
[1.0, 4.0]], dtype=float32)
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
expected = array([[0.0, 1.0],
[1.0, 0.0],
[0.0, 1.0]])
assert_array_almost_equal(x, expected)
def test_01_complex(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 -j 0] [ -j]
# [ j 4 -j] X = [4-j]
@@ -223,11 +204,10 @@
#
ab = array([[-99, -1.0j, -1.0j], [4.0, 4.0, 4.0]])
b = array([-1.0j, 4.0-1j, 4+1j])
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
assert_array_almost_equal(x, [0.0, 1.0, 1.0])
def test_02_complex(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
# Solve
# [ 4 -j 0] [ -j 4j]
# [ j 4 -j] X = [4-j -1-j]
@@ -238,15 +218,13 @@
b = array([[ -1j, 4.0j],
[4.0-1j, -1.0-1j],
[4.0+1j, 4.0]])
- c, x = solveh_banded(ab, b)
+ x = solveh_banded(ab, b)
expected = array([[0.0, 1.0j],
[1.0, 0.0],
[1.0, 1.0]])
assert_array_almost_equal(x, expected)
def test_bad_shapes(self):
- warnings.simplefilter('ignore', category=DeprecationWarning)
-
ab = array([[-99, 1.0, 1.0],
[4.0, 4.0, 4.0]])
b = array([[1.0, 4.0],
@@ -255,13 +233,7 @@
assert_raises(ValueError, solveh_banded, ab, [1.0, 2.0])
assert_raises(ValueError, solveh_banded, ab, [1.0])
- def test_00_deprecation_warning(self):
- warnings.simplefilter('error', category=DeprecationWarning)
- ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
- b = array([1.0, 4.0, 1.0])
- assert_raises(DeprecationWarning, solveh_banded, ab, b)
-
class TestSolve(TestCase):
def test_20Feb04_bug(self):
More information about the Scipy-svn
mailing list