From d1adb9282bfc92dbdebaa41c56160be61c415058 Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Sun, 2 Jun 2019 20:32:07 +0200
Subject: [PATCH] use that sqrt_hop is never None

---
 kwant/physics/leads.py  |  6 +++---
 kwant/solvers/common.py | 23 +++++++----------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/kwant/physics/leads.py b/kwant/physics/leads.py
index b156f029..fc799edc 100644
--- a/kwant/physics/leads.py
+++ b/kwant/physics/leads.py
@@ -174,11 +174,11 @@ class StabilizedModes:
         Translation eigenvectors divided by the corresponding eigenvalues.
     nmodes : int
         Number of left-moving (or right-moving) modes.
-    sqrt_hop : numpy array or None
-        Part of the SVD of `h_hop`, or None if the latter is invertible.
+    sqrt_hop : numpy array
+        Part of the SVD of `h_hop`.
     """
 
-    def __init__(self, vecs, vecslmbdainv, nmodes, sqrt_hop=None):
+    def __init__(self, vecs, vecslmbdainv, nmodes, sqrt_hop):
         kwargs = locals()
         kwargs.pop('self')
         self.__dict__.update(kwargs)
diff --git a/kwant/solvers/common.py b/kwant/solvers/common.py
index ecf33f80..7f87980c 100644
--- a/kwant/solvers/common.py
+++ b/kwant/solvers/common.py
@@ -210,8 +210,7 @@ class SparseSolver(metaclass=abc.ABCMeta):
                 iface_orbs = np.r_[tuple(slice(offsets[i], offsets[i + 1])
                                         for i in interface)]
 
-                n_lead_orbs = (svd_v.shape[0] if svd_v is not None
-                               else u_out.shape[0])
+                n_lead_orbs = svd_v.shape[0]
                 if n_lead_orbs != len(iface_orbs):
                     msg = ('Lead {0} has hopping with dimensions '
                            'incompatible with its interface dimension.')
@@ -221,25 +220,17 @@ class SparseSolver(metaclass=abc.ABCMeta):
                 transf = sp.csc_matrix((np.ones(len(iface_orbs)), coords),
                                        shape=(iface_orbs.size, lhs.shape[0]))
 
-                if svd_v is not None:
-                    v_sp = sp.csc_matrix(svd_v.T.conj()) * transf
-                    vdaguout_sp = (transf.T *
-                                   sp.csc_matrix(np.dot(svd_v, u_out)))
-                    lead_mat = - ulinv_out
-                else:
-                    v_sp = transf
-                    vdaguout_sp = transf.T * sp.csc_matrix(u_out)
-                    lead_mat = - ulinv_out
+                v_sp = sp.csc_matrix(svd_v.T.conj()) * transf
+                vdaguout_sp = (transf.T *
+                               sp.csc_matrix(np.dot(svd_v, u_out)))
+                lead_mat = - ulinv_out
 
                 lhs = sp.bmat([[lhs, vdaguout_sp], [v_sp, lead_mat]],
                               format=self.lhsformat)
 
                 if leadnum in in_leads and nprop > 0:
-                    if svd_v is not None:
-                        vdaguin_sp = transf.T * sp.csc_matrix(
-                            -np.dot(svd_v, u_in))
-                    else:
-                        vdaguin_sp = transf.T * sp.csc_matrix(-u_in)
+                    vdaguin_sp = transf.T * sp.csc_matrix(
+                        -np.dot(svd_v, u_in))
 
                     # defer formation of the real matrix until the proper
                     # system size is known
-- 
GitLab