deepmodeling / deepmodeling/dftio

[Code scan] Fix NumPy API mistakes in AtomicDataDict vector lengths

Open Beginner friendly
#36 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
`AtomicDataDict.with_env_vectors()` and `with_onsitenv_vectors()` call `np.linalg.norm(..., dim=-1)`, but `dim` is a Torch argument, not a NumPy argument:

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/data/AtomicDataDict.py#L135-L138

https://github.com/deepmodeling/dftio/blob/c9d128f24a74ef2911e1a28f5640357488beb196/dftio/data/AtomicDataDict.py#L188-L191

This raises `TypeError` whenever lengths are requested.

## Suggested fix
Use `axis=-1` for NumPy:

```python
np.linalg.norm(env_vec, axis=-1)
```

Contributor guide

Open the contributing guide

Research direction

Open dftio/data/AtomicDataDict.py and inspect with_env_vectors() around lines 135-138 and with_onsitenv_vectors() around lines 188-191. Reproduce a request for vector lengths to confirm the TypeError, then verify that both NumPy norm calls accept the array-axis argument and no longer fail.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.