deepmodeling / deepmodeling/dpti
[Code scan] block_avg crashes when no full block remains
- Dominant language
- Python
- Stars
- 42
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Source: Codex global repository scan of deepmodeling/dpti at commit b719828e7eeb571bd26411430197cd74ea78e38c.
Project: https://github.com/orgs/deepmodeling/projects/27
Problem
`block_avg()` assumes at least one full block survives after `skip`. If the input after skipping is empty, `data_chunks[-1]` raises `IndexError`; if it has fewer samples than `block_size`, the only partial block is dropped and NumPy later raises an axis error.
Code references
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/dpti/lib/utils.py#L105
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/dpti/lib/utils.py#L112
https://github.com/deepmodeling/dpti/blob/b719828e7eeb571bd26411430197cd74ea78e38c/dpti/lib/utils.py#L120
Reproduction
Run:
```python
import numpy as np
from dpti.lib.utils import block_avg
block_avg(np.arange(5), block_size=10)
```
Expected result
The function should either handle the partial block intentionally or raise a clear validation error explaining that no complete block is available.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in dpti/lib/utils.py at block_avg(), especially the referenced lines, and run the provided np.arange(5) reproduction. Decide whether the partial block should be handled or rejected with a clear validation error, then add coverage for empty-after-skip and shorter-than-block-size inputs. Done means these cases no longer produce IndexError or an unclear NumPy axis error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100