diff --git a/kwant/_system.pyx b/kwant/_system.pyx index 79eea1d67abbc9e383c3575689dc9453d19d3fef..971d99b7c2343c14800f37517823478bad014b5d 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 65b0047b4748742eb8330a544ebeec8a5302da00..477696a4df81bca458725d7eeaf91737d6d4ba09 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 b9b7bb046b2f7395caeb81a5808d5023b2401d04..8f61405817d72b7b10b5ae146f01d1977ba6b125 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 bd9cf36eea4b3ea2c9eca006130761036307958f..a90b72175cfc46c2ceb57faf6285b50aad61e46d 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')])