Commit 03d7e9b5 authored by Christoph Groth's avatar Christoph Groth
Browse files

Merge branch 'stable'

parents a9f326a9 8ed9b47b
......@@ -424,8 +424,8 @@ class HermConjOfFunc(object):
def __init__(self, function):
self.function = function
def __call__(self, i, j):
return herm_conj(self.function(j, i))
def __call__(self, i, j, *args):
return herm_conj(self.function(j, i, *args))
################ Leads
......
......@@ -210,10 +210,10 @@ def test_construction_and_indexing():
def test_hermitian_conjugation():
def f(i, j):
def f(i, j, arg):
i, j = i.tag, j.tag
if j[0] == i[0] + 1:
return ta.array([[1, 2j], [3 + 1j, 4j]])
return arg * ta.array([[1, 2j], [3 + 1j, 4j]])
else:
raise ValueError
......@@ -224,8 +224,8 @@ def test_hermitian_conjugation():
sys[fam(0), fam(1)] = f
assert sys[fam(0), fam(1)] is f
assert isinstance(sys[fam(1), fam(0)], builder.HermConjOfFunc)
assert_equal(sys[fam(1), fam(0)](fam(1), fam(0)),
sys[fam(0), fam(1)](fam(0), fam(1)).conjugate().transpose())
assert_equal(sys[fam(1), fam(0)](fam(1), fam(0), 2),
sys[fam(0), fam(1)](fam(0), fam(1), 2).conjugate().transpose())
sys[fam(0), fam(1)] = sys[fam(1), fam(0)]
assert isinstance(sys[fam(0), fam(1)], builder.HermConjOfFunc)
assert sys[fam(1), fam(0)] is f
......
......@@ -91,10 +91,10 @@ def test_hamiltonian_submatrix():
sys[((chain(i), chain(i + 1)) for i in xrange(2))] = hopping
sys2 = sys.finalized()
mat = sys2.hamiltonian_submatrix((2, 1))
mat_should_be = [[5, 1, 0], [1, 4, 1.], [0, 1, 3]]
mat_should_be = [[3, 1, 0], [1, 4, 1], [0, 1, 5]]
# Sorting is required due to unknown compression order of builder.
onsite_hamiltonians = mat.flat[::3]
onsite_hamiltonians = mat.flat[::4]
perm = np.argsort(onsite_hamiltonians)
mat = mat[perm, :]
mat = mat[:, perm]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment