Skip to content

Commit 5b7af6f

Browse files
authored
merge devel to master to release v0.2.22 (#786)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit I'll craft concise release notes focusing on the key user-facing changes across the dpdata library: ## Release Notes - **Python Version Support** - Minimum Python version updated from 3.7 to 3.8 - Removed support for Python 3.7 - **New Features** - Added support for spin data handling in multiple formats (LAMMPS, DeePMD, ABACUS) - Enhanced selective dynamics support in VASP POSCAR files - Improved handling of magnetic moments and forces in various computational chemistry formats - **Documentation** - Updated documentation theme from `sphinx_rtd_theme` to `sphinx-book-theme` - Refined installation and compatibility documentation - **Bug Fixes** - Improved error handling for force and spin data processing - Fixed data type conversions and registrations across different file formats - **Performance** - Optimized data type handling and conversions - Enhanced caching mechanisms for error calculations <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 6387419 + 8ef2646 commit 5b7af6f

File tree

102 files changed

+2057
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2057
-318
lines changed

.github/workflows/benchmark.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ jobs:
1313
uses: actions/setup-python@v5
1414
with:
1515
python-version: 3.12
16-
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
16+
- uses: astral-sh/setup-uv@v5
17+
with:
18+
enable-cache: true
19+
cache-dependency-glob: |
20+
**/requirements*.txt
21+
**/pyproject.toml
1722
- name: Install dependencies
1823
run: uv pip install --system .[test,amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
1924
- name: Run benchmarks

.github/workflows/test.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66

77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-22.04
1010
strategy:
1111
matrix:
12-
python-version: ["3.7", "3.8", "3.12"]
12+
python-version: ["3.8", "3.12"]
1313

1414
steps:
1515
- uses: actions/checkout@v4
@@ -18,13 +18,19 @@ jobs:
1818
uses: actions/setup-python@v5
1919
with:
2020
python-version: ${{ matrix.python-version }}
21-
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
21+
- uses: astral-sh/setup-uv@v5
22+
with:
23+
enable-cache: true
24+
cache-dependency-glob: |
25+
**/requirements*.txt
26+
**/pyproject.toml
27+
cache-suffix: "py${{ matrix.python-version }}"
2228
- name: Install dependencies
2329
run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin rdkit openbabel-wheel
2430
- name: Test
2531
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
2632
- name: Run codecov
27-
uses: codecov/codecov-action@v4
33+
uses: codecov/codecov-action@v5
2834
env:
2935
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3036
pass:

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.6.0
5+
rev: v5.0.0
66
hooks:
77
# there are many log files in tests
88
# TODO: seperate py files and log files
@@ -21,7 +21,7 @@ repos:
2121
# Python
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
2323
# Ruff version.
24-
rev: v0.6.5
24+
rev: v0.9.2
2525
hooks:
2626
- id: ruff
2727
args: ["--fix"]
@@ -36,7 +36,7 @@ repos:
3636
args: ["--write"]
3737
# Python inside docs
3838
- repo: https://github.com/asottile/blacken-docs
39-
rev: 1.18.0
39+
rev: 1.19.1
4040
hooks:
4141
- id: blacken-docs
4242
ci:

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
build:
44
os: ubuntu-22.04
55
tools:
6-
python: "mambaforge-22.9"
6+
python: "mambaforge-23.11"
77
conda:
88
environment: docs/rtd_environment.yml
99
sphinx:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
## Installation
1010

11-
DP-GEN only supports Python 3.7 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install DP-GEN:
11+
dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata:
1212

1313
- Install via pip: `pip install dpdata`
1414
- Install via conda: `conda install -c conda-forge dpdata`

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# -- Project information -----------------------------------------------------
2525

2626
project = "dpdata"
27-
copyright = "2019-%d, DeepModeling " % date.today().year
27+
copyright = "2019-%d, DeepModeling " % date.today().year # noqa: UP031
2828
author = "Han Wang"
2929

3030
# The short X.Y version
@@ -44,7 +44,7 @@
4444
# ones.
4545
extensions = [
4646
"deepmodeling_sphinx",
47-
"sphinx_rtd_theme",
47+
"sphinx_book_theme",
4848
"sphinx.ext.mathjax",
4949
"sphinx.ext.viewcode",
5050
"sphinx.ext.intersphinx",
@@ -87,7 +87,7 @@
8787
# The theme to use for HTML and HTML Help pages. See the documentation for
8888
# a list of builtin themes.
8989
#
90-
html_theme = "sphinx_rtd_theme"
90+
html_theme = "sphinx_book_theme"
9191

9292
# Theme options are theme-specific and customize the look and feel of a theme
9393
# further. For a list of options available for each theme, see the

docs/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Installation
22

3-
DP-GEN only supports Python 3.7 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install DP-GEN:
3+
dpdata only supports Python 3.8 and above. You can [setup a conda/pip environment](https://docs.deepmodeling.com/faq/conda.html), and then use one of the following methods to install dpdata:
44

55
- Install via pip: `pip install dpdata`
66
- Install via conda: `conda install -c conda-forge dpdata`

docs/make_format.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22

33
import csv
44
import os
5-
import sys
65
from collections import defaultdict
76
from inspect import Parameter, Signature, cleandoc, signature
8-
9-
if sys.version_info >= (3, 8):
10-
from typing import Literal
11-
else:
12-
from typing_extensions import Literal
7+
from typing import Literal
138

149
from numpydoc.docscrape import Parameter as numpydoc_Parameter
1510
from numpydoc.docscrape_sphinx import SphinxDocString

docs/rtd_environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: dpdata
22
channels:
33
- conda-forge
44
dependencies:
5-
- mamba
5+
- python <3.13
6+
- mamba <2
67
- pip:
78
- ..[docs]

dpdata/abacus/md.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ def get_coords_from_dump(dumplines, natoms):
5656
if "VIRIAL" in dumplines[6]:
5757
calc_stress = True
5858
check_line = 10
59-
assert (
60-
"POSITION" in dumplines[check_line]
61-
), "keywords 'POSITION' cannot be found in the 6th line. Please check."
59+
assert "POSITION" in dumplines[check_line], (
60+
"keywords 'POSITION' cannot be found in the 6th line. Please check."
61+
)
6262
if "FORCE" in dumplines[check_line]:
6363
calc_force = True
6464

@@ -68,7 +68,7 @@ def get_coords_from_dump(dumplines, natoms):
6868
else:
6969
nframes_dump = int(nlines / (total_natoms + 9))
7070
assert nframes_dump > 0, (
71-
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete."
71+
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete." # noqa: UP031
7272
% (nlines, total_natoms)
7373
)
7474
cells = np.zeros([nframes_dump, 3, 3])
@@ -125,7 +125,7 @@ def get_coords_from_dump(dumplines, natoms):
125125
)
126126
iframe += 1
127127
assert iframe == nframes_dump, (
128-
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump."
128+
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump." # noqa: UP031
129129
% (iframe, nframes_dump)
130130
)
131131
stresses *= kbar2evperang3
@@ -145,7 +145,7 @@ def get_energy(outlines, ndump, dump_freq):
145145
energy.append(np.nan)
146146
nenergy += 1
147147
assert ndump == len(energy), (
148-
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check."
148+
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check." # noqa: UP031
149149
% (len(energy), ndump)
150150
)
151151
energy = np.array(energy)
@@ -167,7 +167,7 @@ def get_frame(fname):
167167
with open_file(geometry_path_in) as fp:
168168
geometry_inlines = fp.read().split("\n")
169169
celldm, cell = get_cell(geometry_inlines)
170-
atom_names, natoms, types, coords = get_coords(
170+
atom_names, natoms, types, coords, move, magmom = get_coords(
171171
celldm, cell, geometry_inlines, inlines
172172
)
173173
# This coords is not to be used.
@@ -191,7 +191,7 @@ def get_frame(fname):
191191
force = np.delete(force, i - ndump, axis=0)
192192
stress = np.delete(stress, i - ndump, axis=0)
193193
energy = np.delete(energy, i - ndump, axis=0)
194-
unconv_stru += "%d " % i
194+
unconv_stru += "%d " % i # noqa: UP031
195195
ndump = len(energy)
196196
if unconv_stru != "":
197197
warnings.warn(f"Structure {unconv_stru} are unconverged and not collected!")
@@ -220,6 +220,8 @@ def get_frame(fname):
220220
if len(magmom) > 0:
221221
data["spins"] = magmom
222222
if len(magforce) > 0:
223-
data["mag_forces"] = magforce
223+
data["force_mags"] = magforce
224+
if len(move) > 0:
225+
data["move"] = move
224226

225227
return data

0 commit comments

Comments
 (0)