Skip to content
Snippets Groups Projects
Commit 242df6b3 authored by Christoph Groth's avatar Christoph Groth
Browse files

Merge branch 'stable_py2' into stable

parents a0b17027 109e145a
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -1059,6 +1059,9 @@ class Builder:
The lead numbering starts from zero and increments from there, i.e.
the leads are numbered in the order in which they are attached.
"""
if self.symmetry.num_directions:
raise ValueError("Leads can only be attached to finite systems.")
if add_cells < 0 or int(add_cells) != add_cells:
raise ValueError('add_cells must be an integer >= 0.')
......
......@@ -578,8 +578,8 @@ def modes(h_cell, h_hop, tol=1e6, stabilization=None):
raise ValueError("Incompatible matrix sizes for h_cell and h_hop.")
if not complex_any(h_hop):
v = np.zeros((0, m))
return (PropagatingModes(np.zeros((0, n)), np.zeros((0,)),
v = np.zeros((m, 0))
return (PropagatingModes(np.zeros((n, 0)), np.zeros((0,)),
np.zeros((0,))),
StabilizedModes(np.zeros((0, 0)), np.zeros((0, 0)), 0, v))
......
......@@ -324,3 +324,19 @@ def test_dtype_linsys():
lsys = kwant.physics.leads.setup_linsys(h_cell - 0.3*np.eye(2),
h_hop)
assert lsys.eigenproblem[0].dtype == np.complex128
def test_zero_hopping():
h_cell = np.identity(2)
h_hop = np.zeros((2, 1))
expected = (leads.PropagatingModes(np.zeros((2, 0)), np.zeros((0,)),
np.zeros((0,))),
leads.StabilizedModes(np.zeros((0, 0)), np.zeros((0, 0)), 0,
np.zeros((1, 0))))
actual = leads.modes(h_cell, h_hop)
assert all(np.alltrue(getattr(actual[1], attr) ==
getattr(expected[1], attr)) for attr
in ('vecs', 'vecslmbdainv', 'nmodes', 'sqrt_hop'))
assert all(np.alltrue(getattr(actual[0], attr) ==
getattr(expected[0], attr)) for attr
in ('wave_functions', 'velocities', 'momenta'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment