diff --git a/kwant/kpm.py b/kwant/kpm.py index eb161de374b5a1276a7e2030b14a009cd7cd656c..a06d7c6d19af5a3a5266e5fff68103cc9f7b3b04 100644 --- a/kwant/kpm.py +++ b/kwant/kpm.py @@ -945,7 +945,7 @@ class LocalVectors: must be a list of integers with the indices where column vectors are nonzero. """ - def __init__(self, syst, where, *args): + def __init__(self, syst, where=None, *args): self.tot_norbs, self.orbs = _normalize_orbs_where(syst, where) self._idx = 0 @@ -1006,7 +1006,11 @@ def _normalize_orbs_where(syst, where): tot_norbs = _get_tot_norbs(syst) orbs = _from_where_to_orbs(syst, where) else: - tot_norbs = csr_matrix(syst).shape[0] + try: + tot_norbs = csr_matrix(syst).shape[0] + except TypeError: + raise TypeError("'syst' is neither a matrix " + "nor a Kwant system.") orbs = (range(tot_norbs) if where is None else np.asarray(where, int)) return tot_norbs, orbs