Skip to content

Commit

Permalink
merge devel to master to release v0.2.22 (#786)
Browse files Browse the repository at this point in the history
<!-- 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 -->
  • Loading branch information
njzjz authored Jan 21, 2025
2 parents 6387419 + 8ef2646 commit 5b7af6f
Show file tree
Hide file tree
Showing 102 changed files with 2,057 additions and 318 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
- name: Install dependencies
run: uv pip install --system .[test,amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
- name: Run benchmarks
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.12"]
python-version: ["3.8", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -18,13 +18,19 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/pyproject.toml
cache-suffix: "py${{ matrix.python-version }}"
- name: Install dependencies
run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin rdkit openbabel-wheel
- name: Test
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
- name: Run codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
pass:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
# there are many log files in tests
# TODO: seperate py files and log files
Expand All @@ -21,7 +21,7 @@ repos:
# Python
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.5
rev: v0.9.2
hooks:
- id: ruff
args: ["--fix"]
Expand All @@ -36,7 +36,7 @@ repos:
args: ["--write"]
# Python inside docs
- repo: https://github.com/asottile/blacken-docs
rev: 1.18.0
rev: 1.19.1
hooks:
- id: blacken-docs
ci:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "mambaforge-22.9"
python: "mambaforge-23.11"
conda:
environment: docs/rtd_environment.yml
sphinx:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Installation

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:
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:

- Install via pip: `pip install dpdata`
- Install via conda: `conda install -c conda-forge dpdata`
Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# -- Project information -----------------------------------------------------

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

# The short X.Y version
Expand All @@ -44,7 +44,7 @@
# ones.
extensions = [
"deepmodeling_sphinx",
"sphinx_rtd_theme",
"sphinx_book_theme",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
Expand Down Expand Up @@ -87,7 +87,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "sphinx_rtd_theme"
html_theme = "sphinx_book_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation

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:
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:

- Install via pip: `pip install dpdata`
- Install via conda: `conda install -c conda-forge dpdata`
Expand Down
7 changes: 1 addition & 6 deletions docs/make_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

import csv
import os
import sys
from collections import defaultdict
from inspect import Parameter, Signature, cleandoc, signature

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing import Literal

from numpydoc.docscrape import Parameter as numpydoc_Parameter
from numpydoc.docscrape_sphinx import SphinxDocString
Expand Down
3 changes: 2 additions & 1 deletion docs/rtd_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: dpdata
channels:
- conda-forge
dependencies:
- mamba
- python <3.13
- mamba <2
- pip:
- ..[docs]
20 changes: 11 additions & 9 deletions dpdata/abacus/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def get_coords_from_dump(dumplines, natoms):
if "VIRIAL" in dumplines[6]:
calc_stress = True
check_line = 10
assert (
"POSITION" in dumplines[check_line]
), "keywords 'POSITION' cannot be found in the 6th line. Please check."
assert "POSITION" in dumplines[check_line], (
"keywords 'POSITION' cannot be found in the 6th line. Please check."
)
if "FORCE" in dumplines[check_line]:
calc_force = True

Expand All @@ -68,7 +68,7 @@ def get_coords_from_dump(dumplines, natoms):
else:
nframes_dump = int(nlines / (total_natoms + 9))
assert nframes_dump > 0, (
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete."
"Number of lines in MD_dump file = %d. Number of atoms = %d. The MD_dump file is incomplete." # noqa: UP031
% (nlines, total_natoms)
)
cells = np.zeros([nframes_dump, 3, 3])
Expand Down Expand Up @@ -125,7 +125,7 @@ def get_coords_from_dump(dumplines, natoms):
)
iframe += 1
assert iframe == nframes_dump, (
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump."
"iframe=%d, nframe_dump=%d. Number of frames does not match number of lines in MD_dump." # noqa: UP031
% (iframe, nframes_dump)
)
stresses *= kbar2evperang3
Expand All @@ -145,7 +145,7 @@ def get_energy(outlines, ndump, dump_freq):
energy.append(np.nan)
nenergy += 1
assert ndump == len(energy), (
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check."
"Number of total energies in running_md.log = %d. Number of frames in MD_dump = %d. Please check." # noqa: UP031
% (len(energy), ndump)
)
energy = np.array(energy)
Expand All @@ -167,7 +167,7 @@ def get_frame(fname):
with open_file(geometry_path_in) as fp:
geometry_inlines = fp.read().split("\n")
celldm, cell = get_cell(geometry_inlines)
atom_names, natoms, types, coords = get_coords(
atom_names, natoms, types, coords, move, magmom = get_coords(
celldm, cell, geometry_inlines, inlines
)
# This coords is not to be used.
Expand All @@ -191,7 +191,7 @@ def get_frame(fname):
force = np.delete(force, i - ndump, axis=0)
stress = np.delete(stress, i - ndump, axis=0)
energy = np.delete(energy, i - ndump, axis=0)
unconv_stru += "%d " % i
unconv_stru += "%d " % i # noqa: UP031
ndump = len(energy)
if unconv_stru != "":
warnings.warn(f"Structure {unconv_stru} are unconverged and not collected!")
Expand Down Expand Up @@ -220,6 +220,8 @@ def get_frame(fname):
if len(magmom) > 0:
data["spins"] = magmom
if len(magforce) > 0:
data["mag_forces"] = magforce
data["force_mags"] = magforce
if len(move) > 0:
data["move"] = move

return data
10 changes: 6 additions & 4 deletions dpdata/abacus/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_coords_from_log(loglines, natoms):
natoms_log += int(line.split()[-1])

assert natoms_log > 0 and natoms_log == natoms, (
"ERROR: detected atom number in log file is %d" % natoms
"ERROR: detected atom number in log file is %d" % natoms # noqa: UP031
)

energy = []
Expand Down Expand Up @@ -76,7 +76,7 @@ def get_coords_from_log(loglines, natoms):
list(map(lambda x: float(x) * a0, loglines[i + k].split()[1:4]))
)
else:
assert False, "Unrecongnized coordinate type, %s, line:%d" % (
assert False, "Unrecongnized coordinate type, %s, line:%d" % ( # noqa: UP031
loglines[i].split()[0],
i,
)
Expand Down Expand Up @@ -183,7 +183,7 @@ def get_frame(fname):
with open_file(geometry_path_in) as fp:
geometry_inlines = fp.read().split("\n")
celldm, cell = get_cell(geometry_inlines)
atom_names, natoms, types, coord_tmp = get_coords(
atom_names, natoms, types, coord_tmp, move, magmom = get_coords(
celldm, cell, geometry_inlines, inlines
)

Expand Down Expand Up @@ -217,6 +217,8 @@ def get_frame(fname):
if len(magmom) > 0:
data["spins"] = magmom
if len(magforce) > 0:
data["mag_forces"] = magforce
data["force_mags"] = magforce
if len(move) > 0:
data["move"] = move

return data
Loading

0 comments on commit 5b7af6f

Please sign in to comment.