dpdata 0.2.24__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/benchmark.yml +6 -4
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/pyright.yml +2 -2
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/test.yml +4 -4
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/test_import.yml +2 -2
- {dpdata-0.2.24 → dpdata-1.0.0}/.gitignore +5 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.pre-commit-config.yaml +3 -3
- dpdata-1.0.0/AGENTS.md +148 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/PKG-INFO +8 -1
- {dpdata-0.2.24 → dpdata-1.0.0}/README.md +7 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/_version.py +16 -3
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/abacus/scf.py +8 -3
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/abacus/stru.py +52 -30
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/data_type.py +37 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/deepmd/mixed.py +33 -13
- dpdata-1.0.0/dpdata/gaussian/fchk.py +175 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/lammps/dump.py +56 -0
- dpdata-1.0.0/dpdata/lammps/lmp.py +596 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/ase.py +15 -8
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/gaussian.py +31 -0
- dpdata-1.0.0/dpdata/plugins/lammps.py +193 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/vasp.py +8 -2
- dpdata-1.0.0/dpdata/plugins/xyz.py +116 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/qe/traj.py +27 -1
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/system.py +2 -2
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/unit.py +28 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/vasp/outcar.py +110 -19
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/vasp/xml.py +57 -7
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/xyz/quip_gap_xyz.py +65 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/PKG-INFO +8 -1
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/SOURCES.txt +2 -0
- dpdata-0.2.24/dpdata/lammps/lmp.py +0 -302
- dpdata-0.2.24/dpdata/plugins/lammps.py +0 -101
- dpdata-0.2.24/dpdata/plugins/xyz.py +0 -58
- {dpdata-0.2.24 → dpdata-1.0.0}/.git-blame-ignore-revs +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.git_archival.txt +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.gitattributes +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/ISSUE_TEMPLATE/generic-issue.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/dependabot.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/mirror_gitee.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.github/workflows/pub-pypi.yml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/.readthedocs.yaml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/LICENSE +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/MANIFEST.in +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/benchmark/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/benchmark/test_import.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/__about__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/__main__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/abacus/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/abacus/md.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/abacus/relax.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/amber/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/amber/mask.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/amber/md.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/amber/sqm.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/ase_calculator.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/bond_order_system.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/cli.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/cp2k/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/cp2k/cell.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/cp2k/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/deepmd/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/deepmd/comp.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/deepmd/hdf5.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/deepmd/raw.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/dftbplus/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/dftbplus/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/driver.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/fhi_aims/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/fhi_aims/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/format.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/gaussian/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/gaussian/gjf.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/gaussian/log.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/gromacs/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/gromacs/gro.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/lammps/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/md/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/md/msd.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/md/pbc.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/md/rdf.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/md/water.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/openmx/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/openmx/omx.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/orca/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/orca/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/periodic_table.json +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/periodic_table.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugin.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/3dmol.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/abacus.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/amber.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/cp2k.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/deepmd.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/dftbplus.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/fhi_aims.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/gromacs.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/list.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/n2p2.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/openmx.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/orca.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/psi4.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/pwmat.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/pymatgen.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/qe.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/rdkit.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/plugins/siesta.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/psi4/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/psi4/input.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/psi4/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pwmat/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pwmat/atomconfig.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pwmat/movement.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/py.typed +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pymatgen/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pymatgen/molecule.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/pymatgen/structure.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/qe/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/qe/scf.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/rdkit/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/rdkit/sanitize.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/rdkit/utils.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/siesta/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/siesta/aiMD_output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/siesta/output.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/stat.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/utils.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/vasp/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/vasp/poscar.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/xyz/__init__.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata/xyz/xyz.py +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/dependency_links.txt +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/entry_points.txt +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/requires.txt +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/dpdata.egg-info/top_level.txt +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/pyproject.toml +0 -0
- {dpdata-0.2.24 → dpdata-1.0.0}/setup.cfg +0 -0
|
@@ -6,14 +6,15 @@ on:
|
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
8
|
benchmark:
|
|
9
|
+
if: ${{ github.repository_owner == 'deepmodeling' }}
|
|
9
10
|
runs-on: ubuntu-latest
|
|
10
11
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
12
|
+
- uses: actions/checkout@v5
|
|
12
13
|
- name: Set up Python
|
|
13
|
-
uses: actions/setup-python@
|
|
14
|
+
uses: actions/setup-python@v6
|
|
14
15
|
with:
|
|
15
16
|
python-version: 3.12
|
|
16
|
-
- uses: astral-sh/setup-uv@
|
|
17
|
+
- uses: astral-sh/setup-uv@v7
|
|
17
18
|
with:
|
|
18
19
|
enable-cache: true
|
|
19
20
|
cache-dependency-glob: |
|
|
@@ -22,7 +23,8 @@ jobs:
|
|
|
22
23
|
- name: Install dependencies
|
|
23
24
|
run: uv pip install --system .[test,amber,ase,pymatgen,benchmark] rdkit openbabel-wheel
|
|
24
25
|
- name: Run benchmarks
|
|
25
|
-
uses: CodSpeedHQ/action@
|
|
26
|
+
uses: CodSpeedHQ/action@v4
|
|
26
27
|
with:
|
|
27
28
|
token: ${{ secrets.CODSPEED_TOKEN }}
|
|
29
|
+
mode: walltime
|
|
28
30
|
run: pytest benchmark/ --codspeed
|
|
@@ -9,11 +9,11 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
steps:
|
|
11
11
|
- uses: actions/checkout@master
|
|
12
|
-
- uses: actions/setup-python@
|
|
12
|
+
- uses: actions/setup-python@v6
|
|
13
13
|
with:
|
|
14
14
|
python-version: '3.12'
|
|
15
15
|
- run: pip install uv
|
|
16
|
-
- run: uv pip install --system -e .[amber,ase,pymatgen] rdkit openbabel-wheel
|
|
16
|
+
- run: uv pip install --system -e .[amber,ase,pymatgen] 'rdkit<2025.3.3' openbabel-wheel
|
|
17
17
|
- uses: jakebailey/pyright-action@v2
|
|
18
18
|
with:
|
|
19
19
|
version: 1.1.363
|
|
@@ -12,13 +12,13 @@ jobs:
|
|
|
12
12
|
python-version: ["3.8", "3.12"]
|
|
13
13
|
|
|
14
14
|
steps:
|
|
15
|
-
- uses: actions/checkout@
|
|
15
|
+
- uses: actions/checkout@v5
|
|
16
16
|
# set up conda
|
|
17
17
|
- name: Set up Python ${{ matrix.python-version }}
|
|
18
|
-
uses: actions/setup-python@
|
|
18
|
+
uses: actions/setup-python@v6
|
|
19
19
|
with:
|
|
20
20
|
python-version: ${{ matrix.python-version }}
|
|
21
|
-
- uses: astral-sh/setup-uv@
|
|
21
|
+
- uses: astral-sh/setup-uv@v7
|
|
22
22
|
with:
|
|
23
23
|
enable-cache: true
|
|
24
24
|
cache-dependency-glob: |
|
|
@@ -26,7 +26,7 @@ jobs:
|
|
|
26
26
|
**/pyproject.toml
|
|
27
27
|
cache-suffix: "py${{ matrix.python-version }}"
|
|
28
28
|
- name: Install dependencies
|
|
29
|
-
run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin rdkit openbabel-wheel
|
|
29
|
+
run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin 'rdkit<2025.3.3' openbabel-wheel 'numpy<2.3'
|
|
30
30
|
- name: Test
|
|
31
31
|
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
|
|
32
32
|
- name: Run codecov
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
5
|
+
rev: v6.0.0
|
|
6
6
|
hooks:
|
|
7
7
|
# there are many log files in tests
|
|
8
8
|
# TODO: seperate py files and log files
|
|
@@ -21,7 +21,7 @@ repos:
|
|
|
21
21
|
# Python
|
|
22
22
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
23
23
|
# Ruff version.
|
|
24
|
-
rev: v0.
|
|
24
|
+
rev: v0.14.1
|
|
25
25
|
hooks:
|
|
26
26
|
- id: ruff
|
|
27
27
|
args: ["--fix"]
|
|
@@ -36,7 +36,7 @@ repos:
|
|
|
36
36
|
args: ["--write"]
|
|
37
37
|
# Python inside docs
|
|
38
38
|
- repo: https://github.com/asottile/blacken-docs
|
|
39
|
-
rev: 1.
|
|
39
|
+
rev: 1.20.0
|
|
40
40
|
hooks:
|
|
41
41
|
- id: blacken-docs
|
|
42
42
|
ci:
|
dpdata-1.0.0/AGENTS.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# dpdata - Atomistic Data Format Manipulation
|
|
2
|
+
|
|
3
|
+
dpdata is a Python package for manipulating atomistic data from computational science software. It supports format conversion between various atomistic simulation packages including VASP, DeePMD-kit, LAMMPS, GROMACS, Gaussian, ABACUS, and many others.
|
|
4
|
+
|
|
5
|
+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
|
|
6
|
+
|
|
7
|
+
## Working Effectively
|
|
8
|
+
|
|
9
|
+
- **Bootstrap and install the repository:**
|
|
10
|
+
- `cd /home/runner/work/dpdata/dpdata` (or wherever the repo is cloned)
|
|
11
|
+
- `uv pip install -e .` -- installs dpdata in development mode with core dependencies (numpy, scipy, h5py, monty, wcmatch)
|
|
12
|
+
- Test installation: `dpdata --version` -- should show version like "dpdata v0.1.dev2+..."
|
|
13
|
+
|
|
14
|
+
- **Run tests:**
|
|
15
|
+
- `cd tests && python -m unittest discover` -- runs all 1826 tests in ~10 seconds. NEVER CANCEL.
|
|
16
|
+
- `cd tests && python -m unittest test_<module>.py` -- run specific test modules (individual modules take ~0.5 seconds)
|
|
17
|
+
- `cd tests && coverage run --source=../dpdata -m unittest discover && coverage report` -- run tests with coverage
|
|
18
|
+
|
|
19
|
+
- **Linting and formatting:**
|
|
20
|
+
- Install ruff: `uv pip install ruff`
|
|
21
|
+
- `ruff check dpdata/` -- lint the main package (takes ~1 second)
|
|
22
|
+
- `ruff format dpdata/` -- format code according to project style
|
|
23
|
+
- `ruff check --fix dpdata/` -- auto-fix linting issues where possible
|
|
24
|
+
|
|
25
|
+
- **Pre-commit hooks:**
|
|
26
|
+
- Install: `uv pip install pre-commit`
|
|
27
|
+
- `pre-commit run --all-files` -- run all hooks on all files
|
|
28
|
+
- Hooks include: ruff linting/formatting, trailing whitespace, end-of-file-fixer, yaml/json/toml checks
|
|
29
|
+
|
|
30
|
+
## Validation
|
|
31
|
+
|
|
32
|
+
- **Always test CLI functionality after making changes:**
|
|
33
|
+
- `dpdata --help` -- ensure CLI still works
|
|
34
|
+
- `dpdata --version` -- verify version is correct
|
|
35
|
+
- Test a basic conversion if sample data is available
|
|
36
|
+
|
|
37
|
+
- **Always run linting before committing:**
|
|
38
|
+
- `ruff check dpdata/` -- ensure no new linting errors
|
|
39
|
+
- `ruff format dpdata/` -- ensure code is properly formatted
|
|
40
|
+
|
|
41
|
+
- **Run relevant tests for your changes:**
|
|
42
|
+
- For format-specific changes: `cd tests && python -m unittest test_<format>*.py`
|
|
43
|
+
- For core system changes: `cd tests && python -m unittest test_system*.py test_multisystems.py`
|
|
44
|
+
- For CLI changes: `cd tests && python -m unittest test_cli.py` (if exists)
|
|
45
|
+
|
|
46
|
+
## Build and Documentation
|
|
47
|
+
|
|
48
|
+
- **Documentation:**
|
|
49
|
+
- `cd docs && make help` -- see all available build targets
|
|
50
|
+
- `cd docs && make html` -- build HTML documentation (requires additional dependencies)
|
|
51
|
+
- Documentation source is in `docs/` directory using Sphinx
|
|
52
|
+
- **NOTE:** Full docs build requires additional dependencies like `deepmodeling-sphinx` that may not be readily available
|
|
53
|
+
|
|
54
|
+
- **Package building:**
|
|
55
|
+
- Uses setuptools with pyproject.toml configuration
|
|
56
|
+
- `uv pip install build && python -m build` -- create source and wheel distributions
|
|
57
|
+
- Version is managed by setuptools_scm from git tags
|
|
58
|
+
|
|
59
|
+
## Common Tasks
|
|
60
|
+
|
|
61
|
+
The following are outputs from frequently run commands. Reference them instead of re-running to save time.
|
|
62
|
+
|
|
63
|
+
### Repository structure
|
|
64
|
+
```
|
|
65
|
+
/home/runner/work/dpdata/dpdata/
|
|
66
|
+
├── dpdata/ # Main package code
|
|
67
|
+
│ ├── __init__.py
|
|
68
|
+
│ ├── cli.py # Command-line interface
|
|
69
|
+
│ ├── system.py # Core System classes
|
|
70
|
+
│ ├── format.py # Format registry
|
|
71
|
+
│ ├── abacus/ # ABACUS format support
|
|
72
|
+
│ ├── amber/ # AMBER format support
|
|
73
|
+
│ ├── deepmd/ # DeePMD format support
|
|
74
|
+
│ ├── vasp/ # VASP format support
|
|
75
|
+
│ ├── xyz/ # XYZ format support
|
|
76
|
+
│ └── ... # Other format modules
|
|
77
|
+
├── tests/ # Test suite (91 test files)
|
|
78
|
+
├── docs/ # Sphinx documentation
|
|
79
|
+
├── plugin_example/ # Example plugin
|
|
80
|
+
├── pyproject.toml # Project configuration
|
|
81
|
+
└── README.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Key dependencies
|
|
85
|
+
- Core: numpy>=1.14.3, scipy, h5py, monty, wcmatch
|
|
86
|
+
- Optional: ase (ASE integration), parmed (AMBER), pymatgen (Materials Project), rdkit (molecular analysis)
|
|
87
|
+
- Testing: unittest (built-in), coverage
|
|
88
|
+
- Linting: ruff
|
|
89
|
+
- Docs: sphinx with various extensions
|
|
90
|
+
|
|
91
|
+
### Test timing expectations
|
|
92
|
+
- Full test suite: ~10 seconds (1826 tests). NEVER CANCEL.
|
|
93
|
+
- Individual test modules: ~0.5 seconds
|
|
94
|
+
- Linting with ruff: ~1 second
|
|
95
|
+
- Documentation build: ~30 seconds
|
|
96
|
+
|
|
97
|
+
### Common workflows
|
|
98
|
+
1. **Adding a new format:**
|
|
99
|
+
- Create module in `dpdata/<format>/`
|
|
100
|
+
- Implement format classes inheriting from appropriate base classes
|
|
101
|
+
- Add tests in `tests/test_<format>*.py`
|
|
102
|
+
- Register format in the plugin system
|
|
103
|
+
|
|
104
|
+
2. **Fixing bugs:**
|
|
105
|
+
- Write test that reproduces the bug first
|
|
106
|
+
- Make minimal fix to pass the test
|
|
107
|
+
- Run full test suite to ensure no regressions
|
|
108
|
+
- Run linting to ensure code style compliance
|
|
109
|
+
|
|
110
|
+
3. **CLI changes:**
|
|
111
|
+
- Modify `dpdata/cli.py`
|
|
112
|
+
- Test with `dpdata --help` and specific commands
|
|
113
|
+
- Add/update tests if needed
|
|
114
|
+
|
|
115
|
+
## Troubleshooting
|
|
116
|
+
|
|
117
|
+
- **Installation timeouts:** Network timeouts during `uv pip install` are common. If this occurs, try:
|
|
118
|
+
- Individual package installation: `uv pip install numpy scipy h5py monty wcmatch`
|
|
119
|
+
- Use `--timeout` option: `uv pip install --timeout 300 -e .`
|
|
120
|
+
- Verify existing installation works: `dpdata --version` should work even if reinstall fails
|
|
121
|
+
|
|
122
|
+
- **Optional dependency errors:** Many tests will skip or fail if optional dependencies (ase, parmed, pymatgen, rdkit) are not installed. This is expected. Core functionality will work with just the basic dependencies.
|
|
123
|
+
|
|
124
|
+
- **Documentation build failures:** The docs build requires specific dependencies like `deepmodeling-sphinx` that may not be readily available. Use `make help` to see available targets, but expect build failures without full doc dependencies.
|
|
125
|
+
|
|
126
|
+
- **Test artifacts:** The test suite generates temporary files (`tests/data_*`, `tests/tmp.*`, `tests/.coverage`). These are excluded by `.gitignore` and should not be committed.
|
|
127
|
+
|
|
128
|
+
- **Import errors:** If you see import errors for specific modules, check if the corresponding optional dependency is installed. For example, ASE functionality requires `uv pip install ase`.
|
|
129
|
+
|
|
130
|
+
## Critical Notes
|
|
131
|
+
|
|
132
|
+
- **NEVER CANCEL** test runs or builds - they complete quickly (10 seconds for tests, 30 seconds for docs)
|
|
133
|
+
- Always run `ruff check` and `ruff format` before committing
|
|
134
|
+
- Test artifacts in `tests/` directory are excluded by `.gitignore` - don't commit them
|
|
135
|
+
- Optional dependencies are required for some formats but core functionality works without them
|
|
136
|
+
- The CLI tool `dpdata` is the main user interface for format conversion
|
|
137
|
+
|
|
138
|
+
## Commit and PR Guidelines
|
|
139
|
+
|
|
140
|
+
- **Use semantic commit messages** for all commits and PR titles following the format: `type(scope): description`
|
|
141
|
+
- **Types:** `feat` (new feature), `fix` (bug fix), `docs` (documentation), `style` (formatting), `refactor` (code restructuring), `test` (testing), `chore` (maintenance)
|
|
142
|
+
- **Examples:**
|
|
143
|
+
- `feat(vasp): add support for POSCAR format`
|
|
144
|
+
- `fix(cli): resolve parsing error for multi-frame files`
|
|
145
|
+
- `docs: update installation instructions`
|
|
146
|
+
- `test(amber): add tests for trajectory parsing`
|
|
147
|
+
- **PR titles** must follow semantic commit format
|
|
148
|
+
- **Commit messages** should be concise but descriptive of the actual changes made
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dpdata
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Manipulating data formats of DeePMD-kit, VASP, QE, PWmat, and LAMMPS, etc.
|
|
5
5
|
Author: DeepModeling
|
|
6
6
|
Author-email: Han Wang <wang_han@iapcm.ac.cn>
|
|
@@ -215,12 +215,19 @@ Dynamic: license-file
|
|
|
215
215
|
|
|
216
216
|
# dpdata
|
|
217
217
|
|
|
218
|
+
[](https://doi.org/10.1021/acs.jcim.5c01767)
|
|
218
219
|
[](https://anaconda.org/conda-forge/dpdata)
|
|
219
220
|
[](https://pypi.org/project/dpdata)
|
|
220
221
|
[](https://dpdata.readthedocs.io/)
|
|
221
222
|
|
|
222
223
|
**dpdata** is a Python package for manipulating atomistic data of software in computational science.
|
|
223
224
|
|
|
225
|
+
## Credits
|
|
226
|
+
|
|
227
|
+
If you use this software, please cite the following paper:
|
|
228
|
+
|
|
229
|
+
- Jinzhe Zeng, Xingliang Peng, Yong-Bin Zhuang, Haidi Wang, Fengbo Yuan, Duo Zhang, Renxi Liu, Yingze Wang, Ping Tuo, Yuzhi Zhang, Yixiao Chen, Yifan Li, Cao Thang Nguyen, Jiameng Huang, Anyang Peng, Marián Rynik, Wei-Hong Xu, Zezhong Zhang, Xu-Yuan Zhou, Tao Chen, Jiahao Fan, Wanrun Jiang, Bowen Li, Denan Li, Haoxi Li, Wenshuo Liang, Ruihao Liao, Liping Liu, Chenxing Luo, Logan Ward, Kaiwei Wan, Junjie Wang, Pan Xiang, Chengqian Zhang, Jinchao Zhang, Rui Zhou, Jia-Xin Zhu, Linfeng Zhang, Han Wang, dpdata: A Scalable Python Toolkit for Atomistic Machine Learning Data Sets, *J. Chem. Inf. Model.*, 2025, DOI: [10.1021/acs.jcim.5c01767](https://doi.org/10.1021/acs.jcim.5c01767). [](https://badge.dimensions.ai/details/doi/10.1021/acs.jcim.5c01767)
|
|
230
|
+
|
|
224
231
|
## Installation
|
|
225
232
|
|
|
226
233
|
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:
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# dpdata
|
|
2
2
|
|
|
3
|
+
[](https://doi.org/10.1021/acs.jcim.5c01767)
|
|
3
4
|
[](https://anaconda.org/conda-forge/dpdata)
|
|
4
5
|
[](https://pypi.org/project/dpdata)
|
|
5
6
|
[](https://dpdata.readthedocs.io/)
|
|
6
7
|
|
|
7
8
|
**dpdata** is a Python package for manipulating atomistic data of software in computational science.
|
|
8
9
|
|
|
10
|
+
## Credits
|
|
11
|
+
|
|
12
|
+
If you use this software, please cite the following paper:
|
|
13
|
+
|
|
14
|
+
- Jinzhe Zeng, Xingliang Peng, Yong-Bin Zhuang, Haidi Wang, Fengbo Yuan, Duo Zhang, Renxi Liu, Yingze Wang, Ping Tuo, Yuzhi Zhang, Yixiao Chen, Yifan Li, Cao Thang Nguyen, Jiameng Huang, Anyang Peng, Marián Rynik, Wei-Hong Xu, Zezhong Zhang, Xu-Yuan Zhou, Tao Chen, Jiahao Fan, Wanrun Jiang, Bowen Li, Denan Li, Haoxi Li, Wenshuo Liang, Ruihao Liao, Liping Liu, Chenxing Luo, Logan Ward, Kaiwei Wan, Junjie Wang, Pan Xiang, Chengqian Zhang, Jinchao Zhang, Rui Zhou, Jia-Xin Zhu, Linfeng Zhang, Han Wang, dpdata: A Scalable Python Toolkit for Atomistic Machine Learning Data Sets, *J. Chem. Inf. Model.*, 2025, DOI: [10.1021/acs.jcim.5c01767](https://doi.org/10.1021/acs.jcim.5c01767). [](https://badge.dimensions.ai/details/doi/10.1021/acs.jcim.5c01767)
|
|
15
|
+
|
|
9
16
|
## Installation
|
|
10
17
|
|
|
11
18
|
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:
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
# file generated by setuptools-scm
|
|
2
2
|
# don't change, don't track in version control
|
|
3
3
|
|
|
4
|
-
__all__ = [
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
5
12
|
|
|
6
13
|
TYPE_CHECKING = False
|
|
7
14
|
if TYPE_CHECKING:
|
|
@@ -9,13 +16,19 @@ if TYPE_CHECKING:
|
|
|
9
16
|
from typing import Union
|
|
10
17
|
|
|
11
18
|
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
12
20
|
else:
|
|
13
21
|
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
14
23
|
|
|
15
24
|
version: str
|
|
16
25
|
__version__: str
|
|
17
26
|
__version_tuple__: VERSION_TUPLE
|
|
18
27
|
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
19
30
|
|
|
20
|
-
__version__ = version = '0.
|
|
21
|
-
__version_tuple__ = version_tuple = (
|
|
31
|
+
__version__ = version = '1.0.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 0, 0)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = 'g8b6a0a7ab'
|
|
@@ -45,7 +45,10 @@ def get_path_out(fname, inlines):
|
|
|
45
45
|
def get_energy(outlines):
|
|
46
46
|
Etot = None
|
|
47
47
|
for line in reversed(outlines):
|
|
48
|
-
if "final etot is" in line:
|
|
48
|
+
if "final etot is" in line: # for LTS
|
|
49
|
+
Etot = float(line.split()[-2]) # in eV
|
|
50
|
+
return Etot, True
|
|
51
|
+
elif "TOTAL ENERGY" in line: # for develop
|
|
49
52
|
Etot = float(line.split()[-2]) # in eV
|
|
50
53
|
return Etot, True
|
|
51
54
|
elif "convergence has NOT been achieved!" in line:
|
|
@@ -59,7 +62,8 @@ def get_energy(outlines):
|
|
|
59
62
|
def collect_force(outlines):
|
|
60
63
|
force = []
|
|
61
64
|
for i, line in enumerate(outlines):
|
|
62
|
-
if "TOTAL-FORCE (eV/Angstrom)" in line:
|
|
65
|
+
# if "TOTAL-FORCE (eV/Angstrom)" in line:
|
|
66
|
+
if "TOTAL-FORCE" in line:
|
|
63
67
|
value_pattern = re.compile(
|
|
64
68
|
r"^\s*[A-Z][a-z]?[1-9][0-9]*\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
|
|
65
69
|
)
|
|
@@ -95,7 +99,8 @@ def get_force(outlines, natoms):
|
|
|
95
99
|
def collect_stress(outlines):
|
|
96
100
|
stress = []
|
|
97
101
|
for i, line in enumerate(outlines):
|
|
98
|
-
if "TOTAL-STRESS (KBAR)" in line:
|
|
102
|
+
# if "TOTAL-STRESS (KBAR)" in line:
|
|
103
|
+
if "TOTAL-STRESS" in line:
|
|
99
104
|
value_pattern = re.compile(
|
|
100
105
|
r"^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s+[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$"
|
|
101
106
|
)
|
|
@@ -314,7 +314,7 @@ def get_atom_mag_cartesian(atommag, angle1, angle2):
|
|
|
314
314
|
]
|
|
315
315
|
|
|
316
316
|
|
|
317
|
-
def
|
|
317
|
+
def get_cartesian_coords(coords, coord_type, celldm, cell):
|
|
318
318
|
"""Transform the atomic coordinates to cartesian coordinates.
|
|
319
319
|
|
|
320
320
|
Args:
|
|
@@ -378,7 +378,7 @@ def parse_pos(coords_lines, atom_names, celldm, cell):
|
|
|
378
378
|
parse_pos_oneline(coords_lines[line_idx])
|
|
379
379
|
)
|
|
380
380
|
|
|
381
|
-
coords.append(
|
|
381
|
+
coords.append(get_cartesian_coords(np.array(pos), coord_type, celldm, cell))
|
|
382
382
|
|
|
383
383
|
move.append(imove)
|
|
384
384
|
velocity.append(ivelocity)
|
|
@@ -422,6 +422,25 @@ def parse_pos(coords_lines, atom_names, celldm, cell):
|
|
|
422
422
|
return atom_numbs, coords, move, mags, velocity, sc, lambda_
|
|
423
423
|
|
|
424
424
|
|
|
425
|
+
def right_hand_rule(
|
|
426
|
+
cell: np.ndarray, coord: np.ndarray
|
|
427
|
+
) -> tuple[np.ndarray, np.ndarray]:
|
|
428
|
+
"""Rotate the cell and coord to make the cell fit the right-hand rule.
|
|
429
|
+
|
|
430
|
+
Args:
|
|
431
|
+
cell (np.ndarray): the cell vectors.
|
|
432
|
+
coord (np.ndarray): the atomic coordinates in cartesian.
|
|
433
|
+
|
|
434
|
+
Returns
|
|
435
|
+
-------
|
|
436
|
+
tuple: the rotated cell and coord.
|
|
437
|
+
"""
|
|
438
|
+
if np.linalg.det(cell) < 0:
|
|
439
|
+
cell = -cell
|
|
440
|
+
coord = -coord
|
|
441
|
+
return cell, coord
|
|
442
|
+
|
|
443
|
+
|
|
425
444
|
def get_frame_from_stru(stru):
|
|
426
445
|
"""Read the ABACUS STRU file and return the dpdata frame.
|
|
427
446
|
|
|
@@ -473,6 +492,7 @@ def get_frame_from_stru(stru):
|
|
|
473
492
|
blocks["ATOMIC_POSITIONS"], atom_names, celldm, cell
|
|
474
493
|
)
|
|
475
494
|
|
|
495
|
+
cell, coords = right_hand_rule(cell, coords)
|
|
476
496
|
data = {
|
|
477
497
|
"atom_names": atom_names,
|
|
478
498
|
"atom_numbs": atom_numbs,
|
|
@@ -731,66 +751,68 @@ def make_unlabeled_stru(
|
|
|
731
751
|
out += "0.0\n"
|
|
732
752
|
out += str(data["atom_numbs"][iele]) + "\n"
|
|
733
753
|
for iatom in range(data["atom_numbs"][iele]):
|
|
734
|
-
iatomtype = np.nonzero(data["atom_types"] == iele)[0][
|
|
754
|
+
iatomtype = np.nonzero(data["atom_types"] == iele)[0][
|
|
755
|
+
iatom
|
|
756
|
+
] # it is the atom index
|
|
735
757
|
iout = f"{data['coords'][frame_idx][iatomtype, 0]:.12f} {data['coords'][frame_idx][iatomtype, 1]:.12f} {data['coords'][frame_idx][iatomtype, 2]:.12f}"
|
|
736
758
|
# add flags for move, velocity, mag, angle1, angle2, and sc
|
|
737
759
|
if move is not None:
|
|
738
760
|
if (
|
|
739
|
-
isinstance(ndarray2list(move[
|
|
740
|
-
and len(move[
|
|
761
|
+
isinstance(ndarray2list(move[iatomtype]), (list, tuple))
|
|
762
|
+
and len(move[iatomtype]) == 3
|
|
741
763
|
):
|
|
742
764
|
iout += " " + " ".join(
|
|
743
|
-
["1" if ii else "0" for ii in move[
|
|
765
|
+
["1" if ii else "0" for ii in move[iatomtype]]
|
|
744
766
|
)
|
|
745
|
-
elif isinstance(ndarray2list(move[
|
|
746
|
-
iout += " 1 1 1" if move[
|
|
767
|
+
elif isinstance(ndarray2list(move[iatomtype]), (int, float, bool)):
|
|
768
|
+
iout += " 1 1 1" if move[iatomtype] else " 0 0 0"
|
|
747
769
|
else:
|
|
748
770
|
iout += " 1 1 1"
|
|
749
771
|
|
|
750
772
|
if (
|
|
751
773
|
velocity is not None
|
|
752
|
-
and isinstance(ndarray2list(velocity[
|
|
753
|
-
and len(velocity[
|
|
774
|
+
and isinstance(ndarray2list(velocity[iatomtype]), (list, tuple))
|
|
775
|
+
and len(velocity[iatomtype]) == 3
|
|
754
776
|
):
|
|
755
|
-
iout += " v " + " ".join([f"{ii:.12f}" for ii in velocity[
|
|
777
|
+
iout += " v " + " ".join([f"{ii:.12f}" for ii in velocity[iatomtype]])
|
|
756
778
|
|
|
757
779
|
if mag is not None:
|
|
758
|
-
if isinstance(ndarray2list(mag[
|
|
759
|
-
mag[
|
|
780
|
+
if isinstance(ndarray2list(mag[iatomtype]), (list, tuple)) and len(
|
|
781
|
+
mag[iatomtype]
|
|
760
782
|
) in [1, 3]:
|
|
761
|
-
iout += " mag " + " ".join([f"{ii:.12f}" for ii in mag[
|
|
762
|
-
elif isinstance(ndarray2list(mag[
|
|
763
|
-
iout += " mag " + f"{mag[
|
|
783
|
+
iout += " mag " + " ".join([f"{ii:.12f}" for ii in mag[iatomtype]])
|
|
784
|
+
elif isinstance(ndarray2list(mag[iatomtype]), (int, float)):
|
|
785
|
+
iout += " mag " + f"{mag[iatomtype]:.12f}"
|
|
764
786
|
|
|
765
787
|
if angle1 is not None and isinstance(
|
|
766
|
-
ndarray2list(angle1[
|
|
788
|
+
ndarray2list(angle1[iatomtype]), (int, float)
|
|
767
789
|
):
|
|
768
|
-
iout += " angle1 " + f"{angle1[
|
|
790
|
+
iout += " angle1 " + f"{angle1[iatomtype]:.12f}"
|
|
769
791
|
|
|
770
792
|
if angle2 is not None and isinstance(
|
|
771
|
-
ndarray2list(angle2[
|
|
793
|
+
ndarray2list(angle2[iatomtype]), (int, float)
|
|
772
794
|
):
|
|
773
|
-
iout += " angle2 " + f"{angle2[
|
|
795
|
+
iout += " angle2 " + f"{angle2[iatomtype]:.12f}"
|
|
774
796
|
|
|
775
797
|
if sc is not None:
|
|
776
|
-
if isinstance(ndarray2list(sc[
|
|
777
|
-
sc[
|
|
798
|
+
if isinstance(ndarray2list(sc[iatomtype]), (list, tuple)) and len(
|
|
799
|
+
sc[iatomtype]
|
|
778
800
|
) in [1, 3]:
|
|
779
801
|
iout += " sc " + " ".join(
|
|
780
|
-
["1" if ii else "0" for ii in sc[
|
|
802
|
+
["1" if ii else "0" for ii in sc[iatomtype]]
|
|
781
803
|
)
|
|
782
|
-
elif isinstance(ndarray2list(sc[
|
|
783
|
-
iout += " sc " + "1" if sc[
|
|
804
|
+
elif isinstance(ndarray2list(sc[iatomtype]), (int, float, bool)):
|
|
805
|
+
iout += " sc " + "1" if sc[iatomtype] else "0"
|
|
784
806
|
|
|
785
807
|
if lambda_ is not None:
|
|
786
|
-
if isinstance(ndarray2list(lambda_[
|
|
787
|
-
lambda_[
|
|
808
|
+
if isinstance(ndarray2list(lambda_[iatomtype]), (list, tuple)) and len(
|
|
809
|
+
lambda_[iatomtype]
|
|
788
810
|
) in [1, 3]:
|
|
789
811
|
iout += " lambda " + " ".join(
|
|
790
|
-
[f"{ii:.12f}" for ii in lambda_[
|
|
812
|
+
[f"{ii:.12f}" for ii in lambda_[iatomtype]]
|
|
791
813
|
)
|
|
792
|
-
elif isinstance(ndarray2list(lambda_[
|
|
793
|
-
iout += " lambda " + f"{lambda_[
|
|
814
|
+
elif isinstance(ndarray2list(lambda_[iatomtype]), (int, float)):
|
|
815
|
+
iout += " lambda " + f"{lambda_[iatomtype]:.12f}"
|
|
794
816
|
|
|
795
817
|
out += iout + "\n"
|
|
796
818
|
natom_tot += 1
|
|
@@ -64,6 +64,43 @@ class DataType:
|
|
|
64
64
|
self.required = required
|
|
65
65
|
self.deepmd_name = name if deepmd_name is None else deepmd_name
|
|
66
66
|
|
|
67
|
+
def __eq__(self, other) -> bool:
|
|
68
|
+
"""Check if two DataType instances are equal.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
other : object
|
|
73
|
+
object to compare with
|
|
74
|
+
|
|
75
|
+
Returns
|
|
76
|
+
-------
|
|
77
|
+
bool
|
|
78
|
+
True if equal, False otherwise
|
|
79
|
+
"""
|
|
80
|
+
if not isinstance(other, DataType):
|
|
81
|
+
return False
|
|
82
|
+
return (
|
|
83
|
+
self.name == other.name
|
|
84
|
+
and self.dtype == other.dtype
|
|
85
|
+
and self.shape == other.shape
|
|
86
|
+
and self.required == other.required
|
|
87
|
+
and self.deepmd_name == other.deepmd_name
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def __repr__(self) -> str:
|
|
91
|
+
"""Return string representation of DataType.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
str
|
|
96
|
+
string representation
|
|
97
|
+
"""
|
|
98
|
+
return (
|
|
99
|
+
f"DataType(name='{self.name}', dtype={self.dtype.__name__}, "
|
|
100
|
+
f"shape={self.shape}, required={self.required}, "
|
|
101
|
+
f"deepmd_name='{self.deepmd_name}')"
|
|
102
|
+
)
|
|
103
|
+
|
|
67
104
|
def real_shape(self, system: System) -> tuple[int]:
|
|
68
105
|
"""Returns expected real shape of a system."""
|
|
69
106
|
assert self.shape is not None
|
|
@@ -4,6 +4,8 @@ import copy
|
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
|
|
7
|
+
import dpdata
|
|
8
|
+
|
|
7
9
|
from .comp import dump as comp_dump
|
|
8
10
|
from .comp import to_system_data as comp_to_system_data
|
|
9
11
|
|
|
@@ -27,10 +29,32 @@ def to_system_data(folder, type_map=None, labels=True):
|
|
|
27
29
|
all_real_atom_types_concat = index_map[all_real_atom_types_concat]
|
|
28
30
|
all_cells_concat = data["cells"]
|
|
29
31
|
all_coords_concat = data["coords"]
|
|
32
|
+
|
|
33
|
+
# handle custom registered data types
|
|
30
34
|
if labels:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
dtypes = dpdata.system.LabeledSystem.DTYPES
|
|
36
|
+
else:
|
|
37
|
+
dtypes = dpdata.system.System.DTYPES
|
|
38
|
+
reserved = {
|
|
39
|
+
"atom_numbs",
|
|
40
|
+
"atom_names",
|
|
41
|
+
"atom_types",
|
|
42
|
+
"real_atom_names",
|
|
43
|
+
"real_atom_types",
|
|
44
|
+
"cells",
|
|
45
|
+
"coords",
|
|
46
|
+
"orig",
|
|
47
|
+
"nopbc",
|
|
48
|
+
}
|
|
49
|
+
extra_data = {}
|
|
50
|
+
for dtype in dtypes:
|
|
51
|
+
name = dtype.name
|
|
52
|
+
if name in reserved:
|
|
53
|
+
continue
|
|
54
|
+
if not (len(dtype.shape) and dtype.shape[0] == dpdata.system.Axis.NFRAMES):
|
|
55
|
+
continue
|
|
56
|
+
if name in data:
|
|
57
|
+
extra_data[name] = data.pop(name)
|
|
34
58
|
|
|
35
59
|
data_list = []
|
|
36
60
|
while True:
|
|
@@ -56,16 +80,12 @@ def to_system_data(folder, type_map=None, labels=True):
|
|
|
56
80
|
all_cells_concat = all_cells_concat[rest_idx]
|
|
57
81
|
temp_data["coords"] = all_coords_concat[temp_idx]
|
|
58
82
|
all_coords_concat = all_coords_concat[rest_idx]
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
all_forces_concat = all_forces_concat[rest_idx]
|
|
66
|
-
if all_virs_concat is not None and all_virs_concat.size > 0:
|
|
67
|
-
temp_data["virials"] = all_virs_concat[temp_idx]
|
|
68
|
-
all_virs_concat = all_virs_concat[rest_idx]
|
|
83
|
+
|
|
84
|
+
for name in extra_data:
|
|
85
|
+
all_dtype_concat = extra_data[name]
|
|
86
|
+
temp_data[name] = all_dtype_concat[temp_idx]
|
|
87
|
+
extra_data[name] = all_dtype_concat[rest_idx]
|
|
88
|
+
|
|
69
89
|
data_list.append(temp_data)
|
|
70
90
|
return data_list
|
|
71
91
|
|