[Code scan] Fix LDOS valence-band slicing and z-scan indexing
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 75/100
Research direction
Start in dftio/calc/ldos.py and read LDOS.init(), LDOS.get(), and LDOS.scan() around the cited lines. Check the valence-band count and scan loop against their expected bounds. Done means z_valence no longer causes a slice-index error, valence-band divisibility is validated, and scan indexing stays within ldos_wbias_diff while writing to the shifted z-plane.
Written by the indexing model from the issue text.
Description
This issue comes from a Codex global repository scan.
Problem
LDOS.__init__() computes self.n_valbands with /, so it stores a float:
LDOS.get() later assigns that float to n and uses it as a slice bound:
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:
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.
- Dominant language
- Jupyter Notebook
- Stars
- 16
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from deepmodeling/dftio
-
Difficulty 2/5 1-2 days Newbie friendliness 78/100
deepmodeling/dftio#44 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
deepmodeling/dftio#43 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
deepmodeling/dftio#42 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
deepmodeling/dftio#41 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
deepmodeling/dftio#39 ·
All issues in deepmodeling/dftio
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
open-compass/VLMEvalKit#1698 ·
-
triage:deciding
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
open-telemetry/otel-arrow#4123 · 1 reaction ·