From 9e7196dea275d296152a25f9c3947e3ac6512e62 Mon Sep 17 00:00:00 2001 From: Anton Akhmerov <anton.akhmerov@gmail.com> Date: Sat, 3 Mar 2012 13:49:54 -0500 Subject: [PATCH] fix bug in f4f8bf6ee which reintroduced the memory leak --- kwant/solvers/sparse.py | 7 ++----- kwant/solvers/tests/test_sparse.py | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kwant/solvers/sparse.py b/kwant/solvers/sparse.py index 5d3d4737..fafb55b4 100644 --- a/kwant/solvers/sparse.py +++ b/kwant/solvers/sparse.py @@ -15,11 +15,8 @@ from kwant import physics, system # reached all of our users. def del_for_umfpackcontext(self): self.free() -try: - if not hasattr(spl.dsolve.umfpack.UmfpackContext, '__del__'): - spl.dsolve.umfpack.UmfpackContext.__del__ = del_for_umfpackcontext -except: - pass +if not hasattr(umfpack.UmfpackContext, '__del__'): + umfpack.UmfpackContext.__del__ = del_for_umfpackcontext del del_for_umfpackcontext def factorized(A, piv_tol=1.0, sym_piv_tol=1.0): diff --git a/kwant/solvers/tests/test_sparse.py b/kwant/solvers/tests/test_sparse.py index 06ef4d3f..7e1aebe0 100644 --- a/kwant/solvers/tests/test_sparse.py +++ b/kwant/solvers/tests/test_sparse.py @@ -280,4 +280,7 @@ def test_very_singular_leads(): sys.attach_lead(right_lead) fsys = sys.finalized() result = solve(fsys) - assert result[1] == [0, 2] \ No newline at end of file + assert result[1] == [0, 2] + +def test_umfpack_del(): + assert hasattr(kwant.solvers.sparse.umfpack.UmfpackContext, '__del__') -- GitLab