deepmodeling / deepmodeling/dftio

[Code scan] Fix ABACUS NSPIN detection for spinful matrices

Open Beginner friendly
#29 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
16
Forks
14
PR merge metrics
No merged PRs in 30d

Description

This issue comes from a Codex global repository scan.

## Problem
ABACUS spinful runs are always treated as spinless. The condition below is always truthy because the first string literal is evaluated as truthy before checking the line content:

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/io/abacus/abacus_parser.py#L246-L253

As a result, an `NSPIN == 4` run never reaches the spinful branch. Spinful matrices are parsed with spinless dimensions, which can either fail assertions later or, worse, produce incorrectly shaped blocks.

## Reproduction
Evaluate the condition with `line = "NSPIN == 4"`; it still sets `spinful = False`.

## Suggested fix
Normalize `line` and test membership on both operands, for example:

```python
lower = line.lower()
if "nspin == 1" in lower or "nspin = 1" in lower:
spinful = False
elif "nspin == 4" in lower or "nspin = 4" in lower:
spinful = True
```

Contributor guide

Open the contributing guide

Research direction

Start at dftio/io/abacus/abacus_parser.py lines 246-253 and reproduce the condition with line = "NSPIN == 4". Verify that NSPIN 1 and NSPIN 4 inputs select the correct spinless or spinful parsing path, including the resulting matrix dimensions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.