3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-19 06:21:38 +02:00

[py3] Be sure to properly use floor division in various places

This commit is contained in:
Nils Wentzell 2020-04-08 15:53:35 -04:00
parent 2b673f7926
commit 484e10ef1f
4 changed files with 9 additions and 9 deletions

View File

@ -266,7 +266,7 @@ class ConfigParameters:
mat = np.array(rows) mat = np.array(rows)
else: else:
err_mess = "Complex matrix must contain 2*M values:\n%s"%(par_str) err_mess = "Complex matrix must contain 2*M values:\n%s"%(par_str)
assert 2 * (nm / 2) == nm, err_mess assert 2 * (nm // 2) == nm, err_mess
tmp = np.array(rows, dtype=np.complex128) tmp = np.array(rows, dtype=np.complex128)
mat = tmp[:, 0::2] + 1.0j * tmp[:, 1::2] mat = tmp[:, 0::2] + 1.0j * tmp[:, 1::2]

View File

@ -135,8 +135,8 @@ class ProjectorShell:
assert nrow%nion == 0, "Number of rows in TRANSFILE must be divisible by the number of ions" assert nrow%nion == 0, "Number of rows in TRANSFILE must be divisible by the number of ions"
assert ncol%nm == 0, "Number of columns in TRANSFILE must be divisible by the number of orbitals 2*l + 1" assert ncol%nm == 0, "Number of columns in TRANSFILE must be divisible by the number of orbitals 2*l + 1"
nr = nrow / nion nr = nrow // nion
nsize = ncol / nm nsize = ncol // nm
assert nsize in (1, 2, 4), "Number of columns in TRANSFILE must be divisible by either 1, 2, or 4" assert nsize in (1, 2, 4), "Number of columns in TRANSFILE must be divisible by either 1, 2, or 4"
# #
# Determine the spin-dimension and whether the matrices are real or complex # Determine the spin-dimension and whether the matrices are real or complex
@ -154,11 +154,11 @@ class ProjectorShell:
# is_complex = True # is_complex = True
# #
is_complex = nsize > 1 is_complex = nsize > 1
ns_dim = max(1, nsize / 2) ns_dim = max(1, nsize // 2)
# Dimension of the orbital subspace # Dimension of the orbital subspace
assert nr%ns_dim == 0, "Number of rows in TRANSFILE is not compatible with the spin dimension" assert nr%ns_dim == 0, "Number of rows in TRANSFILE is not compatible with the spin dimension"
ndim = nr / ns_dim ndim = nr // ns_dim
self.tmatrices = np.zeros((nion, nr, nm * ns_dim), dtype=np.complex128) self.tmatrices = np.zeros((nion, nr, nm * ns_dim), dtype=np.complex128)
@ -181,7 +181,7 @@ class ProjectorShell:
assert ncol%nm == 0, "Number of columns in TRANSFORM must be divisible by the number of orbitals 2*l + 1" assert ncol%nm == 0, "Number of columns in TRANSFORM must be divisible by the number of orbitals 2*l + 1"
# Only spin-independent matrices are expected here # Only spin-independent matrices are expected here
nsize = ncol / nm nsize = ncol // nm
assert nsize in (1, 2), "Number of columns in TRANSFORM must be divisible by either 1 or 2" assert nsize in (1, 2), "Number of columns in TRANSFORM must be divisible by either 1 or 2"
is_complex = nsize > 1 is_complex = nsize > 1

View File

@ -701,7 +701,7 @@ def read_symmcar(vasp_dir, symm_filename='SYMMCAR'):
line = next(sym_file) line = next(sym_file)
# Permutations (in chunks of 20 indices per line) # Permutations (in chunks of 20 indices per line)
for it in range(ntrans): for it in range(ntrans):
for ibl in range((nion - 1) / 20 + 1): for ibl in range((nion - 1) // 20 + 1):
i1 = ibl * 20 i1 = ibl * 20
i2 = (ibl + 1) * 20 i2 = (ibl + 1) * 20
line = next(sym_file) line = next(sym_file)

View File

@ -60,7 +60,7 @@ for i in range(5):
assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block" assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block"
assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size" assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size"
for i in range(10): for i in range(10):
assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i/2), i%2), "wrong mapping" assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping"
assert len(SK.deg_shells[0]) == 2, "wrong number of equivalent groups found" assert len(SK.deg_shells[0]) == 2, "wrong number of equivalent groups found"
assert sorted([len(d) for d in SK.deg_shells[0]]) == [2,3], "wrong number of members in the equivalent groups found" assert sorted([len(d) for d in SK.deg_shells[0]]) == [2,3], "wrong number of members in the equivalent groups found"
@ -103,7 +103,7 @@ for i in range(5):
assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block" assert 'ud_{}'.format(i) in SK.gf_struct_solver[0], "missing block"
assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size" assert SK.gf_struct_solver[0]['ud_{}'.format(i)] == list(range(2)), "wrong block size"
for i in range(10): for i in range(10):
assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i/2), i%2), "wrong mapping" assert SK.sumk_to_solver[0]['ud',i] == ('ud_{}'.format(i//2), i%2), "wrong mapping"
assert len(SK.deg_shells[0]) == 2, "wrong number of equivalent groups found" assert len(SK.deg_shells[0]) == 2, "wrong number of equivalent groups found"
assert sorted([len(d) for d in SK.deg_shells[0]]) == [2,3], "wrong number of members in the equivalent groups found" assert sorted([len(d) for d in SK.deg_shells[0]]) == [2,3], "wrong number of members in the equivalent groups found"