Commit baa1561e authored by Joseph Weston's avatar Joseph Weston Committed by Christoph Groth
Browse files

initialize numpy arrays to zero

Before this commit, if there was a lead for which
the inter-cell hopping matrix was the zero matrix, then
kwant.physics.modes() returned arrays with uninitialized memory.
parent ab437898
......@@ -572,10 +572,10 @@ def modes(h_cell, h_hop, tol=1e6, stabilization=None):
# Note: np.any(h_hop) returns (at least from numpy 1.6.1 - 1.8-devel)
# False if h_hop is purely imaginary
if not (np.any(h_hop.real) or np.any(h_hop.imag)):
v = np.empty((0, m))
return PropagatingModes(np.empty((0, n)), np.empty((0,)),
np.empty((0,))), \
StabilizedModes(np.empty((0, 0)), np.empty((0, 0)), 0, v)
v = np.zeros((0, m))
return (PropagatingModes(np.zeros((0, n)), np.zeros((0,)),
StabilizedModes(np.zeros((0, 0)), np.zeros((0, 0)), 0, v))
# Defer most of the calculation to helper routines.
matrices, v, extract = setup_linsys(h_cell, h_hop, tol, stabilization)
Supports Markdown
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