diff --git a/kwant/rmt.py b/kwant/rmt.py index 1d3fbb725b6e83218c2afe3aa89d80f761937e42..0f66dd62444331cd9e227b7d0a2db4c0715572b3 100644 --- a/kwant/rmt.py +++ b/kwant/rmt.py @@ -106,12 +106,14 @@ def gaussian(n, sym='A', v=1.): """ if sym not in sym_list: raise ValueError('Unknown symmetry type.') - if (c(sym) or t(sym) == -1 or p(sym) == -1) and n % 2: - raise ValueError('Matrix dimension should be even in chosen symmetry' - 'class.') - else: - tau_z = np.array((n // 2) * [1, -1]) - idx_x = np.arange(n) + tau_z + if (c(sym) or t(sym) == -1 or p(sym) == -1): + if n % 2: + raise ValueError('Matrix dimension should be even in' + ' chosen symmetry class.') + else: + tau_z = np.array((n // 2) * [1, -1]) + idx_x = np.arange(n) + tau_z + if sym == 'CII' and n % 4: raise ValueError('Matrix dimension should be a multiple of 4 in' 'symmetry class CII.') diff --git a/kwant/tests/test_rmt.py b/kwant/tests/test_rmt.py index 87ef04fb8e68bf58a6181e3e849f35444b97b30a..c8869e48c7c9ac0ea12b9e954b839a8cabd89f1d 100644 --- a/kwant/tests/test_rmt.py +++ b/kwant/tests/test_rmt.py @@ -19,6 +19,8 @@ def test_gaussian(): for sym in rmt.sym_list: if sym not in ('A', 'D', 'AI'): assert_raises(ValueError, rmt.gaussian, 5, sym) + else: + rmt.gaussian(5, sym) # Check it is allowed. h = rmt.gaussian(n, sym) if rmt.t(sym): t_mat = np.array(rmt.h_t_matrix[sym])