dpdata 1.0.0__tar.gz → 1.0.1__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.
Files changed (144) hide show
  1. {dpdata-1.0.0 → dpdata-1.0.1}/.github/dependabot.yml +0 -1
  2. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/benchmark.yml +1 -1
  3. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/pyright.yml +2 -2
  4. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/test.yml +8 -4
  5. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/test_import.yml +1 -1
  6. {dpdata-1.0.0 → dpdata-1.0.1}/.pre-commit-config.yaml +15 -7
  7. {dpdata-1.0.0 → dpdata-1.0.1}/AGENTS.md +19 -2
  8. {dpdata-1.0.0 → dpdata-1.0.1}/PKG-INFO +3 -1
  9. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/_version.py +3 -3
  10. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/cp2k/output.py +1 -1
  11. dpdata-1.0.1/dpdata/deepmd/mixed.py +299 -0
  12. dpdata-1.0.1/dpdata/lmdb/__init__.py +5 -0
  13. dpdata-1.0.1/dpdata/lmdb/format.py +286 -0
  14. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/deepmd.py +24 -2
  15. dpdata-1.0.1/dpdata/plugins/lmdb.py +6 -0
  16. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/system.py +8 -0
  17. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/PKG-INFO +3 -1
  18. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/SOURCES.txt +6 -1
  19. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/requires.txt +2 -0
  20. {dpdata-1.0.0 → dpdata-1.0.1}/pyproject.toml +2 -0
  21. dpdata-1.0.1/skills/dpdata-cli/README.md +71 -0
  22. dpdata-1.0.1/skills/dpdata-cli/SKILL.md +188 -0
  23. dpdata-1.0.0/dpdata/deepmd/mixed.py +0 -157
  24. {dpdata-1.0.0 → dpdata-1.0.1}/.git-blame-ignore-revs +0 -0
  25. {dpdata-1.0.0 → dpdata-1.0.1}/.git_archival.txt +0 -0
  26. {dpdata-1.0.0 → dpdata-1.0.1}/.gitattributes +0 -0
  27. {dpdata-1.0.0 → dpdata-1.0.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  28. {dpdata-1.0.0 → dpdata-1.0.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  29. {dpdata-1.0.0 → dpdata-1.0.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  30. {dpdata-1.0.0 → dpdata-1.0.1}/.github/ISSUE_TEMPLATE/generic-issue.yml +0 -0
  31. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/mirror_gitee.yml +0 -0
  32. {dpdata-1.0.0 → dpdata-1.0.1}/.github/workflows/pub-pypi.yml +0 -0
  33. {dpdata-1.0.0 → dpdata-1.0.1}/.gitignore +0 -0
  34. {dpdata-1.0.0 → dpdata-1.0.1}/.readthedocs.yaml +0 -0
  35. {dpdata-1.0.0 → dpdata-1.0.1}/LICENSE +0 -0
  36. {dpdata-1.0.0 → dpdata-1.0.1}/MANIFEST.in +0 -0
  37. {dpdata-1.0.0 → dpdata-1.0.1}/README.md +0 -0
  38. {dpdata-1.0.0 → dpdata-1.0.1}/benchmark/__init__.py +0 -0
  39. {dpdata-1.0.0 → dpdata-1.0.1}/benchmark/test_import.py +0 -0
  40. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/__about__.py +0 -0
  41. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/__init__.py +0 -0
  42. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/__main__.py +0 -0
  43. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/abacus/__init__.py +0 -0
  44. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/abacus/md.py +0 -0
  45. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/abacus/relax.py +0 -0
  46. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/abacus/scf.py +0 -0
  47. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/abacus/stru.py +0 -0
  48. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/amber/__init__.py +0 -0
  49. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/amber/mask.py +0 -0
  50. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/amber/md.py +0 -0
  51. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/amber/sqm.py +0 -0
  52. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/ase_calculator.py +0 -0
  53. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/bond_order_system.py +0 -0
  54. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/cli.py +0 -0
  55. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/cp2k/__init__.py +0 -0
  56. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/cp2k/cell.py +0 -0
  57. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/data_type.py +0 -0
  58. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/deepmd/__init__.py +0 -0
  59. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/deepmd/comp.py +0 -0
  60. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/deepmd/hdf5.py +0 -0
  61. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/deepmd/raw.py +0 -0
  62. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/dftbplus/__init__.py +0 -0
  63. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/dftbplus/output.py +0 -0
  64. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/driver.py +0 -0
  65. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/fhi_aims/__init__.py +0 -0
  66. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/fhi_aims/output.py +0 -0
  67. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/format.py +0 -0
  68. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gaussian/__init__.py +0 -0
  69. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gaussian/fchk.py +0 -0
  70. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gaussian/gjf.py +0 -0
  71. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gaussian/log.py +0 -0
  72. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gromacs/__init__.py +0 -0
  73. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/gromacs/gro.py +0 -0
  74. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/lammps/__init__.py +0 -0
  75. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/lammps/dump.py +0 -0
  76. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/lammps/lmp.py +0 -0
  77. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/md/__init__.py +0 -0
  78. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/md/msd.py +0 -0
  79. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/md/pbc.py +0 -0
  80. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/md/rdf.py +0 -0
  81. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/md/water.py +0 -0
  82. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/openmx/__init__.py +0 -0
  83. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/openmx/omx.py +0 -0
  84. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/orca/__init__.py +0 -0
  85. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/orca/output.py +0 -0
  86. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/periodic_table.json +0 -0
  87. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/periodic_table.py +0 -0
  88. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugin.py +0 -0
  89. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/3dmol.py +0 -0
  90. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/__init__.py +0 -0
  91. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/abacus.py +0 -0
  92. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/amber.py +0 -0
  93. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/ase.py +0 -0
  94. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/cp2k.py +0 -0
  95. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/dftbplus.py +0 -0
  96. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/fhi_aims.py +0 -0
  97. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/gaussian.py +0 -0
  98. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/gromacs.py +0 -0
  99. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/lammps.py +0 -0
  100. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/list.py +0 -0
  101. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/n2p2.py +0 -0
  102. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/openmx.py +0 -0
  103. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/orca.py +0 -0
  104. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/psi4.py +0 -0
  105. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/pwmat.py +0 -0
  106. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/pymatgen.py +0 -0
  107. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/qe.py +0 -0
  108. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/rdkit.py +0 -0
  109. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/siesta.py +0 -0
  110. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/vasp.py +0 -0
  111. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/plugins/xyz.py +0 -0
  112. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/psi4/__init__.py +0 -0
  113. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/psi4/input.py +0 -0
  114. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/psi4/output.py +0 -0
  115. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pwmat/__init__.py +0 -0
  116. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pwmat/atomconfig.py +0 -0
  117. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pwmat/movement.py +0 -0
  118. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/py.typed +0 -0
  119. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pymatgen/__init__.py +0 -0
  120. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pymatgen/molecule.py +0 -0
  121. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/pymatgen/structure.py +0 -0
  122. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/qe/__init__.py +0 -0
  123. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/qe/scf.py +0 -0
  124. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/qe/traj.py +0 -0
  125. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/rdkit/__init__.py +0 -0
  126. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/rdkit/sanitize.py +0 -0
  127. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/rdkit/utils.py +0 -0
  128. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/siesta/__init__.py +0 -0
  129. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/siesta/aiMD_output.py +0 -0
  130. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/siesta/output.py +0 -0
  131. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/stat.py +0 -0
  132. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/unit.py +0 -0
  133. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/utils.py +0 -0
  134. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/vasp/__init__.py +0 -0
  135. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/vasp/outcar.py +0 -0
  136. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/vasp/poscar.py +0 -0
  137. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/vasp/xml.py +0 -0
  138. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/xyz/__init__.py +0 -0
  139. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/xyz/quip_gap_xyz.py +0 -0
  140. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata/xyz/xyz.py +0 -0
  141. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/dependency_links.txt +0 -0
  142. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/entry_points.txt +0 -0
  143. {dpdata-1.0.0 → dpdata-1.0.1}/dpdata.egg-info/top_level.txt +0 -0
  144. {dpdata-1.0.0 → dpdata-1.0.1}/setup.cfg +0 -0
@@ -4,4 +4,3 @@ updates:
4
4
  directory: "/"
5
5
  schedule:
6
6
  interval: "weekly"
7
- target-branch: "devel"
@@ -9,7 +9,7 @@ jobs:
9
9
  if: ${{ github.repository_owner == 'deepmodeling' }}
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v5
12
+ - uses: actions/checkout@v6
13
13
  - name: Set up Python
14
14
  uses: actions/setup-python@v6
15
15
  with:
@@ -13,7 +13,7 @@ jobs:
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<2025.3.3' openbabel-wheel
17
- - uses: jakebailey/pyright-action@v2
16
+ - run: uv pip install --system -e .[amber,ase,pymatgen] rdkit openbabel-wheel
17
+ - uses: jakebailey/pyright-action@v3
18
18
  with:
19
19
  version: 1.1.363
@@ -1,8 +1,8 @@
1
1
  name: Python package
2
2
 
3
3
  on:
4
- - push
5
- - pull_request
4
+ - push
5
+ - pull_request
6
6
 
7
7
  jobs:
8
8
  build:
@@ -12,7 +12,7 @@ jobs:
12
12
  python-version: ["3.8", "3.12"]
13
13
 
14
14
  steps:
15
- - uses: actions/checkout@v5
15
+ - uses: actions/checkout@v6
16
16
  # set up conda
17
17
  - name: Set up Python ${{ matrix.python-version }}
18
18
  uses: actions/setup-python@v6
@@ -26,13 +26,15 @@ 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<2025.3.3' openbabel-wheel 'numpy<2.3'
29
+ run: uv pip install --system .[test,amber,ase,pymatgen] coverage ./tests/plugin rdkit openbabel-wheel
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
33
33
  uses: codecov/codecov-action@v5
34
34
  env:
35
35
  CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
36
+ with:
37
+ use_oidc: true
36
38
  pass:
37
39
  needs: [build]
38
40
  runs-on: ubuntu-latest
@@ -42,3 +44,5 @@ jobs:
42
44
  uses: re-actors/alls-green@release/v1
43
45
  with:
44
46
  jobs: ${{ toJSON(needs) }}
47
+ permissions:
48
+ id-token: write
@@ -8,7 +8,7 @@ jobs:
8
8
  build:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
- - uses: actions/checkout@v5
11
+ - uses: actions/checkout@v6
12
12
  - uses: actions/setup-python@v6
13
13
  with:
14
14
  python-version: '3.9'
@@ -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.14.1
24
+ rev: v0.15.2
25
25
  hooks:
26
26
  - id: ruff
27
27
  args: ["--fix"]
@@ -34,10 +34,18 @@ repos:
34
34
  hooks:
35
35
  - id: velin
36
36
  args: ["--write"]
37
- # Python inside docs
38
- - repo: https://github.com/asottile/blacken-docs
39
- rev: 1.20.0
37
+ # markdown
38
+ - repo: https://github.com/hukkin/mdformat
39
+ rev: 1.0.0
40
40
  hooks:
41
- - id: blacken-docs
42
- ci:
43
- autoupdate_branch: devel
41
+ - id: mdformat
42
+ exclude: "^tests/.*$"
43
+ additional_dependencies:
44
+ # - mdformat-myst==0.3.0
45
+ # See https://github.com/executablebooks/mdformat-myst/issues/13
46
+ - "git+https://github.com/njzjz-bothub/mdformat-myst@d9c414e#egg=mdformat-myst"
47
+ - mdformat-ruff==0.1.3
48
+ - mdformat-web==0.2.0
49
+ - mdformat-config==0.2.1
50
+ - mdformat-beautysh==1.0.0
51
+ - mdformat-gfm-alerts==2.0.0
@@ -7,22 +7,26 @@ Always reference these instructions first and fallback to search or bash command
7
7
  ## Working Effectively
8
8
 
9
9
  - **Bootstrap and install the repository:**
10
+
10
11
  - `cd /home/runner/work/dpdata/dpdata` (or wherever the repo is cloned)
11
12
  - `uv pip install -e .` -- installs dpdata in development mode with core dependencies (numpy, scipy, h5py, monty, wcmatch)
12
13
  - Test installation: `dpdata --version` -- should show version like "dpdata v0.1.dev2+..."
13
14
 
14
15
  - **Run tests:**
16
+
15
17
  - `cd tests && python -m unittest discover` -- runs all 1826 tests in ~10 seconds. NEVER CANCEL.
16
18
  - `cd tests && python -m unittest test_<module>.py` -- run specific test modules (individual modules take ~0.5 seconds)
17
19
  - `cd tests && coverage run --source=../dpdata -m unittest discover && coverage report` -- run tests with coverage
18
20
 
19
21
  - **Linting and formatting:**
22
+
20
23
  - Install ruff: `uv pip install ruff`
21
24
  - `ruff check dpdata/` -- lint the main package (takes ~1 second)
22
25
  - `ruff format dpdata/` -- format code according to project style
23
26
  - `ruff check --fix dpdata/` -- auto-fix linting issues where possible
24
27
 
25
28
  - **Pre-commit hooks:**
29
+
26
30
  - Install: `uv pip install pre-commit`
27
31
  - `pre-commit run --all-files` -- run all hooks on all files
28
32
  - Hooks include: ruff linting/formatting, trailing whitespace, end-of-file-fixer, yaml/json/toml checks
@@ -30,15 +34,18 @@ Always reference these instructions first and fallback to search or bash command
30
34
  ## Validation
31
35
 
32
36
  - **Always test CLI functionality after making changes:**
37
+
33
38
  - `dpdata --help` -- ensure CLI still works
34
39
  - `dpdata --version` -- verify version is correct
35
40
  - Test a basic conversion if sample data is available
36
41
 
37
42
  - **Always run linting before committing:**
43
+
38
44
  - `ruff check dpdata/` -- ensure no new linting errors
39
45
  - `ruff format dpdata/` -- ensure code is properly formatted
40
46
 
41
47
  - **Run relevant tests for your changes:**
48
+
42
49
  - For format-specific changes: `cd tests && python -m unittest test_<format>*.py`
43
50
  - For core system changes: `cd tests && python -m unittest test_system*.py test_multisystems.py`
44
51
  - For CLI changes: `cd tests && python -m unittest test_cli.py` (if exists)
@@ -46,12 +53,14 @@ Always reference these instructions first and fallback to search or bash command
46
53
  ## Build and Documentation
47
54
 
48
55
  - **Documentation:**
56
+
49
57
  - `cd docs && make help` -- see all available build targets
50
58
  - `cd docs && make html` -- build HTML documentation (requires additional dependencies)
51
59
  - Documentation source is in `docs/` directory using Sphinx
52
60
  - **NOTE:** Full docs build requires additional dependencies like `deepmodeling-sphinx` that may not be readily available
53
61
 
54
62
  - **Package building:**
63
+
55
64
  - Uses setuptools with pyproject.toml configuration
56
65
  - `uv pip install build && python -m build` -- create source and wheel distributions
57
66
  - Version is managed by setuptools_scm from git tags
@@ -61,6 +70,7 @@ Always reference these instructions first and fallback to search or bash command
61
70
  The following are outputs from frequently run commands. Reference them instead of re-running to save time.
62
71
 
63
72
  ### Repository structure
73
+
64
74
  ```
65
75
  /home/runner/work/dpdata/dpdata/
66
76
  ├── dpdata/ # Main package code
@@ -82,6 +92,7 @@ The following are outputs from frequently run commands. Reference them instead o
82
92
  ```
83
93
 
84
94
  ### Key dependencies
95
+
85
96
  - Core: numpy>=1.14.3, scipy, h5py, monty, wcmatch
86
97
  - Optional: ase (ASE integration), parmed (AMBER), pymatgen (Materials Project), rdkit (molecular analysis)
87
98
  - Testing: unittest (built-in), coverage
@@ -89,25 +100,30 @@ The following are outputs from frequently run commands. Reference them instead o
89
100
  - Docs: sphinx with various extensions
90
101
 
91
102
  ### Test timing expectations
103
+
92
104
  - Full test suite: ~10 seconds (1826 tests). NEVER CANCEL.
93
105
  - Individual test modules: ~0.5 seconds
94
106
  - Linting with ruff: ~1 second
95
107
  - Documentation build: ~30 seconds
96
108
 
97
109
  ### Common workflows
110
+
98
111
  1. **Adding a new format:**
112
+
99
113
  - Create module in `dpdata/<format>/`
100
114
  - Implement format classes inheriting from appropriate base classes
101
115
  - Add tests in `tests/test_<format>*.py`
102
116
  - Register format in the plugin system
103
117
 
104
- 2. **Fixing bugs:**
118
+ 1. **Fixing bugs:**
119
+
105
120
  - Write test that reproduces the bug first
106
121
  - Make minimal fix to pass the test
107
122
  - Run full test suite to ensure no regressions
108
123
  - Run linting to ensure code style compliance
109
124
 
110
- 3. **CLI changes:**
125
+ 1. **CLI changes:**
126
+
111
127
  - Modify `dpdata/cli.py`
112
128
  - Test with `dpdata --help` and specific commands
113
129
  - Add/update tests if needed
@@ -115,6 +131,7 @@ The following are outputs from frequently run commands. Reference them instead o
115
131
  ## Troubleshooting
116
132
 
117
133
  - **Installation timeouts:** Network timeouts during `uv pip install` are common. If this occurs, try:
134
+
118
135
  - Individual package installation: `uv pip install numpy scipy h5py monty wcmatch`
119
136
  - Use `--timeout` option: `uv pip install --timeout 300 -e .`
120
137
  - Verify existing installation works: `dpdata --version` should work even if reinstall fails
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dpdata
3
- Version: 1.0.0
3
+ Version: 1.0.1
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>
@@ -187,6 +187,8 @@ Requires-Dist: monty
187
187
  Requires-Dist: scipy
188
188
  Requires-Dist: h5py
189
189
  Requires-Dist: wcmatch
190
+ Requires-Dist: lmdb
191
+ Requires-Dist: msgpack-numpy
190
192
  Requires-Dist: importlib_metadata>=1.4; python_version < "3.8"
191
193
  Requires-Dist: typing_extensions; python_version < "3.8"
192
194
  Provides-Extra: test
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '1.0.0'
32
- __version_tuple__ = version_tuple = (1, 0, 0)
31
+ __version__ = version = '1.0.1'
32
+ __version_tuple__ = version_tuple = (1, 0, 1)
33
33
 
34
- __commit_id__ = commit_id = 'g8b6a0a7ab'
34
+ __commit_id__ = commit_id = 'gae134fe29'
@@ -65,7 +65,7 @@ class Cp2kSystems:
65
65
  # assert all(eq2), (log_info_dict,xyz_info_dict,'There may be errors in the file. If it is a restart task; use restart=True')
66
66
  # assert all(eq3), (log_info_dict,xyz_info_dict,'There may be errors in the file. If it is a restart task; use restart=True')
67
67
  assert math.isclose(
68
- log_info_dict["energies"], xyz_info_dict["energies"], abs_tol=1.0e-6
68
+ log_info_dict["energies"][0], xyz_info_dict["energies"][0], abs_tol=1.0e-6
69
69
  ), (
70
70
  log_info_dict["energies"],
71
71
  xyz_info_dict["energies"],
@@ -0,0 +1,299 @@
1
+ from __future__ import annotations
2
+
3
+ import copy
4
+ import math
5
+
6
+ import numpy as np
7
+
8
+ import dpdata
9
+ from dpdata.data_type import Axis
10
+
11
+ from .comp import dump as comp_dump
12
+ from .comp import to_system_data as comp_to_system_data
13
+
14
+
15
+ def _pad_to(sys_data, target_natoms, dtypes):
16
+ """Pad system data dict so that NATOMS dimension becomes target_natoms.
17
+
18
+ Virtual atoms get real_atom_types = -1, and all other per-atom data is
19
+ padded with zeros.
20
+
21
+ Parameters
22
+ ----------
23
+ sys_data : dict
24
+ System data dict, already in mixed-type format.
25
+ target_natoms : int
26
+ Target number of atoms after padding.
27
+ dtypes : tuple[DataType, ...]
28
+ Registered data types to iterate for generic per-atom padding.
29
+ """
30
+ natoms = sys_data["atom_types"].shape[0]
31
+ npad = target_natoms - natoms
32
+ if npad <= 0:
33
+ return
34
+ nframes = sys_data["coords"].shape[0]
35
+
36
+ # Pad atom_types (all MIXED_TOKEN = 0)
37
+ sys_data["atom_types"] = np.concatenate(
38
+ [sys_data["atom_types"], np.zeros(npad, dtype=int)]
39
+ )
40
+ sys_data["atom_numbs"] = [target_natoms]
41
+
42
+ # Pad real_atom_types with -1 (virtual atom sentinel)
43
+ sys_data["real_atom_types"] = np.concatenate(
44
+ [
45
+ sys_data["real_atom_types"],
46
+ -np.ones((nframes, npad), dtype=sys_data["real_atom_types"].dtype),
47
+ ],
48
+ axis=1,
49
+ )
50
+
51
+ # Pad coords and all other per-atom data generically
52
+ reserved = {
53
+ "atom_numbs",
54
+ "atom_names",
55
+ "atom_types",
56
+ "orig",
57
+ "cells",
58
+ "real_atom_names",
59
+ "real_atom_types",
60
+ "nopbc",
61
+ }
62
+ for dtype in dtypes:
63
+ if dtype.name in reserved:
64
+ continue
65
+ if dtype.name not in sys_data:
66
+ continue
67
+ if not (
68
+ len(dtype.shape) >= 2
69
+ and dtype.shape[0] == Axis.NFRAMES
70
+ and Axis.NATOMS in dtype.shape
71
+ ):
72
+ continue
73
+ axis_natoms = list(dtype.shape).index(Axis.NATOMS)
74
+ arr = sys_data[dtype.name]
75
+ pad_width = [(0, 0)] * len(arr.shape)
76
+ pad_width[axis_natoms] = (0, npad)
77
+ sys_data[dtype.name] = np.pad(
78
+ arr, pad_width, mode="constant", constant_values=0
79
+ )
80
+
81
+
82
+ def _strip_virtual_atoms(atom_types_row, coords, extra_data, dtypes):
83
+ """Strip virtual atoms (type -1) from a group of frames.
84
+
85
+ Parameters
86
+ ----------
87
+ atom_types_row : np.ndarray
88
+ 1-D array of atom type indices for the group (same for all frames).
89
+ coords : np.ndarray
90
+ Coordinates array, shape (nframes, natoms_padded, 3).
91
+ extra_data : dict
92
+ Dict of {name: array} for this group, arrays already frame-sliced.
93
+ dtypes : tuple[DataType, ...]
94
+ Registered data types.
95
+
96
+ Returns
97
+ -------
98
+ atom_types : np.ndarray
99
+ Atom types with virtual atoms removed.
100
+ coords : np.ndarray
101
+ Coords with virtual atoms removed.
102
+ extra_data : dict
103
+ Extra data with virtual atoms removed.
104
+ """
105
+ real_mask = atom_types_row >= 0
106
+ if real_mask.all():
107
+ return atom_types_row, coords, extra_data
108
+
109
+ atom_types = atom_types_row[real_mask]
110
+ coords = coords[:, real_mask, :]
111
+
112
+ stripped = {}
113
+ for name, arr in extra_data.items():
114
+ for dtype in dtypes:
115
+ if dtype.name == name and Axis.NATOMS in dtype.shape:
116
+ axis_natoms = list(dtype.shape).index(Axis.NATOMS)
117
+ idx = [slice(None)] * len(arr.shape)
118
+ idx[axis_natoms] = real_mask
119
+ arr = arr[tuple(idx)]
120
+ break
121
+ stripped[name] = arr
122
+
123
+ return atom_types, coords, stripped
124
+
125
+
126
+ def to_system_data(folder, type_map=None, labels=True):
127
+ data = comp_to_system_data(folder, type_map, labels)
128
+ # data is empty
129
+ old_type_map = data["atom_names"].copy()
130
+ if type_map is not None:
131
+ assert isinstance(type_map, list)
132
+ missing_type = [i for i in old_type_map if i not in type_map]
133
+ assert not missing_type, (
134
+ f"These types are missing in selected type_map: {missing_type} !"
135
+ )
136
+ index_map = np.array([type_map.index(i) for i in old_type_map])
137
+ data["atom_names"] = type_map.copy()
138
+ else:
139
+ index_map = None
140
+ all_real_atom_types_concat = data.pop("real_atom_types").astype(int)
141
+ if index_map is not None:
142
+ # Preserve -1 (virtual atom sentinel) during remapping
143
+ valid = all_real_atom_types_concat >= 0
144
+ remapped = np.full_like(all_real_atom_types_concat, -1)
145
+ remapped[valid] = index_map[all_real_atom_types_concat[valid]]
146
+ all_real_atom_types_concat = remapped
147
+ all_cells_concat = data["cells"]
148
+ all_coords_concat = data["coords"]
149
+
150
+ # handle custom registered data types
151
+ if labels:
152
+ dtypes = dpdata.system.LabeledSystem.DTYPES
153
+ else:
154
+ dtypes = dpdata.system.System.DTYPES
155
+ reserved = {
156
+ "atom_numbs",
157
+ "atom_names",
158
+ "atom_types",
159
+ "real_atom_names",
160
+ "real_atom_types",
161
+ "cells",
162
+ "coords",
163
+ "orig",
164
+ "nopbc",
165
+ }
166
+ extra_data = {}
167
+ for dtype in dtypes:
168
+ name = dtype.name
169
+ if name in reserved:
170
+ continue
171
+ if not (len(dtype.shape) and dtype.shape[0] == dpdata.system.Axis.NFRAMES):
172
+ continue
173
+ if name in data:
174
+ extra_data[name] = data.pop(name)
175
+
176
+ data_list = []
177
+ while True:
178
+ if all_real_atom_types_concat.size == 0:
179
+ break
180
+ # temp_formula = formula(data['atom_names'], temp_atom_numbs)
181
+ temp_idx = np.arange(all_real_atom_types_concat.shape[0])[
182
+ (all_real_atom_types_concat == all_real_atom_types_concat[0]).all(-1)
183
+ ]
184
+ rest_idx = np.arange(all_real_atom_types_concat.shape[0])[
185
+ (all_real_atom_types_concat != all_real_atom_types_concat[0]).any(-1)
186
+ ]
187
+
188
+ # Extract data for this group
189
+ group_atom_types = all_real_atom_types_concat[0]
190
+ group_coords = all_coords_concat[temp_idx]
191
+ group_extra = {}
192
+ for name in extra_data:
193
+ group_extra[name] = extra_data[name][temp_idx]
194
+ extra_data[name] = extra_data[name][rest_idx]
195
+
196
+ # Strip virtual atoms (type -1) introduced by padding
197
+ group_atom_types, group_coords, group_extra = _strip_virtual_atoms(
198
+ group_atom_types, group_coords, group_extra, dtypes
199
+ )
200
+
201
+ temp_atom_numbs = [
202
+ np.count_nonzero(group_atom_types == i)
203
+ for i in range(len(data["atom_names"]))
204
+ ]
205
+
206
+ temp_data = data.copy()
207
+ temp_data["atom_names"] = data["atom_names"].copy()
208
+ temp_data["atom_numbs"] = temp_atom_numbs
209
+ temp_data["atom_types"] = group_atom_types
210
+ all_real_atom_types_concat = all_real_atom_types_concat[rest_idx]
211
+ temp_data["cells"] = all_cells_concat[temp_idx]
212
+ all_cells_concat = all_cells_concat[rest_idx]
213
+ temp_data["coords"] = group_coords
214
+ all_coords_concat = all_coords_concat[rest_idx]
215
+
216
+ for name in group_extra:
217
+ temp_data[name] = group_extra[name]
218
+
219
+ data_list.append(temp_data)
220
+ return data_list
221
+
222
+
223
+ def dump(folder, data, set_size=2000, comp_prec=np.float32, remove_sets=True):
224
+ # if not converted to mixed
225
+ if "real_atom_types" not in data:
226
+ from dpdata import LabeledSystem, System
227
+
228
+ # not change the original content
229
+ data = copy.deepcopy(data)
230
+
231
+ if "energies" in data:
232
+ temp_sys = LabeledSystem(data=data)
233
+ else:
234
+ temp_sys = System(data=data)
235
+ temp_sys.convert_to_mixed_type()
236
+
237
+ data = data.copy()
238
+ data["atom_names"] = data.pop("real_atom_names")
239
+ comp_dump(folder, data, set_size, comp_prec, remove_sets)
240
+
241
+
242
+ def mix_system(*system, type_map, atom_numb_pad=None, **kwargs):
243
+ """Mix the systems into mixed_type ones according to the unified given type_map.
244
+
245
+ Parameters
246
+ ----------
247
+ *system : System
248
+ The systems to mix
249
+ type_map : list of str
250
+ Maps atom type to name
251
+ atom_numb_pad : int, optional
252
+ If provided, pad atom counts to the next multiple of this number
253
+ using virtual atoms (type -1 in real_atom_types). This reduces the
254
+ number of subdirectories when systems have many different atom counts.
255
+ For example, atom_numb_pad=8 groups systems into multiples of 8.
256
+ **kwargs : dict
257
+ Other parameters
258
+
259
+ Returns
260
+ -------
261
+ mixed_systems: dict
262
+ dict of mixed system with key 'atom_numbs'
263
+ """
264
+ mixed_systems = {}
265
+ temp_systems = {}
266
+ atom_numbs_frame_index = {} # index of frames in cur sys
267
+ # Use LabeledSystem DTYPES as superset for generic per-atom padding
268
+ dtypes = dpdata.system.LabeledSystem.DTYPES
269
+ for sys in system:
270
+ tmp_sys = sys.copy()
271
+ natom = tmp_sys.get_natoms()
272
+ tmp_sys.convert_to_mixed_type(type_map=type_map)
273
+ if atom_numb_pad is not None and atom_numb_pad > 1:
274
+ padded_natom = math.ceil(natom / atom_numb_pad) * atom_numb_pad
275
+ _pad_to(tmp_sys.data, padded_natom, dtypes)
276
+ group_key = str(padded_natom)
277
+ else:
278
+ group_key = str(natom)
279
+ if group_key not in atom_numbs_frame_index:
280
+ atom_numbs_frame_index[group_key] = 0
281
+ atom_numbs_frame_index[group_key] += tmp_sys.get_nframes()
282
+ if group_key not in temp_systems or not temp_systems[group_key]:
283
+ temp_systems[group_key] = tmp_sys
284
+ else:
285
+ temp_systems[group_key].append(tmp_sys)
286
+ for natom_key in temp_systems:
287
+ if atom_numbs_frame_index[natom_key] > 0:
288
+ mixed_systems[natom_key] = temp_systems[natom_key]
289
+ return mixed_systems
290
+
291
+
292
+ def split_system(sys, split_num=10000):
293
+ rest = sys.get_nframes() - split_num
294
+ if rest <= 0:
295
+ return sys, None, 0
296
+ else:
297
+ split_sys = sys.sub_system(range(split_num))
298
+ rest_sys = sys.sub_system(range(split_num, sys.get_nframes()))
299
+ return split_sys, rest_sys, rest
@@ -0,0 +1,5 @@
1
+ from __future__ import annotations
2
+
3
+ from .format import LMDBFormat
4
+
5
+ __all__ = ["LMDBFormat"]