From 9f9091479e49e43043044bc95bb30ae28685de53 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Wed, 15 Feb 2012 23:46:04 +0100 Subject: [PATCH 1/2] BUG: sparse/umfpack: free data in UmfpackContext.__del__ (#1597) --- scipy/sparse/linalg/dsolve/umfpack/umfpack.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scipy/sparse/linalg/dsolve/umfpack/umfpack.py b/scipy/sparse/linalg/dsolve/umfpack/umfpack.py index de3ff8099cc1..8db7789211ef 100644 --- a/scipy/sparse/linalg/dsolve/umfpack/umfpack.py +++ b/scipy/sparse/linalg/dsolve/umfpack/umfpack.py @@ -296,6 +296,9 @@ def __init__( self, family = 'di', **kwargs ): self.funs.defaults( self.control ) self.control[UMFPACK_PRL] = 3 + def __del__(self): + self.free() + ## # 30.11.2005, c def strControl( self ): From d2096e2e069a9be69beb236e4539c988d4b257e6 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 16 Feb 2012 00:02:48 +0100 Subject: [PATCH 2/2] TST: sparse/umfpack: run tests despite the deprecationwarning --- .../dsolve/umfpack/tests/test_umfpack.py | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py b/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py index 50855131dad1..1aa0529aa725 100644 --- a/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py +++ b/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py @@ -7,8 +7,10 @@ import warnings import random + from numpy.testing import TestCase, assert_array_almost_equal, dec, \ decorate_methods +from numpy.testing.utils import WarningManager from scipy import rand, matrix, diag, eye from scipy.sparse import csc_matrix, spdiags, SparseEfficiencyWarning @@ -29,7 +31,17 @@ _umfpack_skip = dec.skipif(not _have_umfpack, 'UMFPACK appears not to be compiled') -class TestSolvers(TestCase): +class _DeprecationAccept: + def setUp(self): + self.mgr = WarningManager() + self.mgr.__enter__() + warnings.simplefilter("ignore", DeprecationWarning) + + def tearDown(self): + self.mgr.__exit__() + + +class TestSolvers(TestCase, _DeprecationAccept): """Tests inverting a sparse linear system""" def test_solve_complex_without_umfpack(self): @@ -113,9 +125,9 @@ def setUp(self): self.b = np.array([1, 2, 3, 4, 5]) self.b2 = np.array([5, 4, 3, 2, 1]) + _DeprecationAccept.setUp(self) - -class TestFactorization(TestCase): +class TestFactorization(TestCase, _DeprecationAccept): """Tests factorizing a sparse linear system""" def test_complex_lu(self): @@ -175,6 +187,8 @@ def setUp(self): self.complex_matrices = [x.astype(np.complex128) for x in self.real_matrices] + _DeprecationAccept.setUp(self) + # Skip methods if umfpack not present for cls in [TestSolvers, TestFactorization]: decorate_methods(cls, _umfpack_skip)