This issue comes from a Codex global repository scan.
Problem
LDOS.__init__() computes self.n_valbands with /, so it stores a float:
|
if z_valence is not None: |
|
self.n_valbands = sum([z_valence[atomic_numbers_r[i]] for i in self.atomic_numbers]) / self.nspin |
LDOS.get() later assigns that float to n and uses it as a slice bound:
|
if self.n_valbands: |
|
assert n >= self.n_valbands, f"Number of bands must be at least {self.n_valbands}" |
|
n = self.n_valbands |
|
else: |
|
print("Warning: Number of valence bands not provided. All input coeff and eigenvalues are considered corresponding to valence bands.") |
|
assert m >= n |
|
|
|
coefficients = coefficients[:,:n] |
|
eigenvalues = eigenvalues[:,:n] |
This raises TypeError: slice indices must be integers when z_valence is provided.
LDOS.scan() also has a left-branch off-by-one: ldos_wbias_diff has length nz - 1, but the loop indexes it up to i == nz - 1:
|
for i in range(1,nz): |
|
mask = torch.logical_or(mask, ldos_wbias_diff[:,:,i] < 0) |
|
ldos_wbias[:,:,i][mask] = 100 |
Suggested fix
Validate valence-band divisibility and store an integer band count. In scan(), iterate only over valid diff indices and explicitly write to the corresponding shifted z-plane.
This issue comes from a Codex global repository scan.
Problem
LDOS.__init__()computesself.n_valbandswith/, so it stores a float:dftio/dftio/calc/ldos.py
Lines 49 to 50 in c9d128f
LDOS.get()later assigns that float tonand uses it as a slice bound:dftio/dftio/calc/ldos.py
Lines 97 to 105 in c9d128f
This raises
TypeError: slice indices must be integerswhenz_valenceis provided.LDOS.scan()also has a left-branch off-by-one:ldos_wbias_diffhas lengthnz - 1, but the loop indexes it up toi == nz - 1:dftio/dftio/calc/ldos.py
Lines 205 to 207 in c9d128f
Suggested fix
Validate valence-band divisibility and store an integer band count. In
scan(), iterate only over valid diff indices and explicitly write to the corresponding shifted z-plane.