From 511f1980f10c42ab9821d788b17671e522968e1b Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Sun, 30 Oct 2016 16:05:34 -0400
Subject: [PATCH] depend on scipy >= 0.11, update scipy dependency descriptions
 in source

---
 kwant/_system.pyx       |  5 +++--
 kwant/solvers/common.py | 19 +++++++++++--------
 kwant/solvers/sparse.py | 10 ----------
 setup.py                |  2 +-
 4 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/kwant/_system.pyx b/kwant/_system.pyx
index 79eea1d6..971d99b7 100644
--- a/kwant/_system.pyx
+++ b/kwant/_system.pyx
@@ -85,8 +85,9 @@ def make_sparse(ham, args, CGraph gr, diag,
                         rows_cols[1, k] = j + from_off[n_fs]
                         k += 1
 
-    # hack around a bug in Scipy + Python 3 + memoryviews
-    # see https://github.com/scipy/scipy/issues/5123 for details
+    # Hack around a bug in Scipy + Python 3 + memoryviews
+    # see https://github.com/scipy/scipy/issues/5123 for details.
+    # TODO: remove this once we depend on scipy >= 0.18.
     np_data = np.asarray(data)
     np_rows_cols = np.asarray(rows_cols)
     np_to_off = np.asarray(to_off)
diff --git a/kwant/solvers/common.py b/kwant/solvers/common.py
index 65b0047b..477696a4 100644
--- a/kwant/solvers/common.py
+++ b/kwant/solvers/common.py
@@ -17,14 +17,17 @@ from .._common import ensure_isinstance
 from .. import system
 from functools import reduce
 
-# Currently, scipy.sparse does not support matrices with one dimension being
-# zero: http://projects.scipy.org/scipy/ticket/1602 We use NumPy dense matrices
-# as a replacement.
-
-# TODO: Once this issue is fixed, code for the special cases can be removed
-# from _make_linear_sys, _solve_linear_sys and possibly other places marked by
-# the line "See comment about zero-shaped sparse matrices at the top of
-# common.py".
+# Until v0.13.0, scipy.sparse did not support making block matrices out of
+# matrices with one dimension being zero:
+# https://github.com/scipy/scipy/issues/2127 Additionally, 'scipy.sparse.bmat'
+# didn't support matrices with zero size until v0.18:
+# https://github.com/scipy/scipy/issues/5976. For now we use NumPy dense
+# matrices as a replacement.
+
+# TODO: Once we depend on scipy >= 0.18, code for the special cases can be
+# removed from _make_linear_sys, _solve_linear_sys and possibly other places
+# marked by the line "See comment about zero-shaped sparse matrices at the top
+# of common.py".
 
 LinearSys = namedtuple('LinearSys', ['lhs', 'rhs', 'indices', 'num_orb'])
 
diff --git a/kwant/solvers/sparse.py b/kwant/solvers/sparse.py
index b9b7bb04..8f614058 100644
--- a/kwant/solvers/sparse.py
+++ b/kwant/solvers/sparse.py
@@ -27,16 +27,6 @@ if uses_umfpack:
     umfpack = linsolve.umfpack
 
 if uses_umfpack:
-    # This patches a memory leak in SciPy:
-    # https://github.com/scipy/scipy/issues/2122
-    #
-    # TODO: Remove this code once we depend on scipy >= 0.10.1.
-    def del_for_umfpackcontext(self):
-        self.free()
-    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):
         """
         Return a fuction for solving a sparse linear system, with A
diff --git a/setup.py b/setup.py
index bd9cf36e..a90b7217 100755
--- a/setup.py
+++ b/setup.py
@@ -585,7 +585,7 @@ def main():
           ext_modules=exts,
           setup_requires=['pytest-runner >= 2.7'],
           tests_require=['numpy > 1.6.1', 'pytest >= 2.6.3'],
-          install_requires=['numpy > 1.6.1', 'scipy >= 0.9', 'tinyarray'],
+          install_requires=['numpy > 1.6.1', 'scipy >= 0.11.0', 'tinyarray'],
           extras_require={'plotting': 'matplotlib >= 1.2'},
           classifiers=[c.strip() for c in classifiers.split('\n')])
 
-- 
GitLab