[Code scan] Fix LDOS valence-band slicing and z-scan indexing

Open Beginner friendly
#40 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
Half a day
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
data

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:

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/calc/ldos.py#L49-L50

LDOS.get() later assigns that float to n and uses it as a slice bound:

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/calc/ldos.py#L97-L105

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:

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/calc/ldos.py#L205-L207

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from deepmodeling/dftio

All issues in deepmodeling/dftio

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.