Skip to content

Commit 658a511

Browse files
authored
merge devel to master for v0.2.18 (#628)
2 parents e2f235f + 4daf372 commit 658a511

Some content is hidden

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

69 files changed

+9323
-68
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
target-branch: "devel"

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: [3.7, 3.8, 3.9]
12+
python-version: ["3.7", "3.8", "3.12"]
1313

1414
steps:
1515
- uses: actions/checkout@v2
@@ -26,7 +26,9 @@ jobs:
2626
- name: Test
2727
run: cd tests && coverage run --source=../dpdata -m unittest && cd .. && coverage combine tests/.coverage && coverage report
2828
- name: Run codecov
29-
uses: codecov/codecov-action@v3
29+
uses: codecov/codecov-action@v4
30+
env:
31+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3032
pass:
3133
needs: [build]
3234
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ docs/drivers.csv
2828
docs/minimizers.csv
2929
docs/api/
3030
docs/formats/
31+
.DS_Store

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ repos:
1717
- id: check-symlinks
1818
- id: check-toml
1919
# Python
20-
- repo: https://github.com/psf/black
21-
rev: 23.10.1
22-
hooks:
23-
- id: black-jupyter
2420
- repo: https://github.com/astral-sh/ruff-pre-commit
2521
# Ruff version.
26-
rev: v0.1.3
22+
rev: v0.3.5
2723
hooks:
2824
- id: ruff
2925
args: ["--fix"]
26+
types_or: [python, pyi, jupyter]
27+
- id: ruff-format
28+
types_or: [python, pyi, jupyter]
3029
# numpydoc
3130
- repo: https://github.com/Carreau/velin
3231
rev: 0.0.12

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
prune docs
2+
prune tests
3+
prune plugin_example

docs/make_format.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,9 @@ def generate_sub_format_pages(formats: dict):
224224
buff.append(""" :noindex:""")
225225
buff.append("")
226226
if docstring is None or method not in format.__dict__:
227-
docstring = """ Convert this format to :class:`%s`.""" % (
228-
method_classes[method]
227+
docstring = (
228+
""" Convert this format to :class:`%s`."""
229+
% (method_classes[method])
229230
)
230231
doc_obj = SphinxDocString(docstring)
231232
if len(doc_obj["Parameters"]) > 0:
@@ -293,8 +294,8 @@ def generate_sub_format_pages(formats: dict):
293294
and "to_system" in format.__dict__
294295
)
295296
):
296-
docstring = "Convert :class:`%s` to this format." % (
297-
method_classes[method]
297+
docstring = (
298+
"Convert :class:`%s` to this format." % (method_classes[method])
298299
)
299300
doc_obj = SphinxDocString(docstring)
300301
if len(doc_obj["Parameters"]) > 0:

dpdata/abacus/scf.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
ry2ev = EnergyConversion("rydberg", "eV").value()
1111
kbar2evperang3 = PressureConversion("kbar", "eV/angstrom^3").value()
1212

13+
ABACUS_STRU_KEYS = [
14+
"ATOMIC_SPECIES",
15+
"NUMERICAL_ORBITAL",
16+
"LATTICE_CONSTANT",
17+
"LATTICE_VECTORS",
18+
"ATOMIC_POSITIONS",
19+
"NUMERICAL_DESCRIPTOR",
20+
"PAW_FILES",
21+
]
22+
1323

1424
def CheckFile(ifile):
1525
if not os.path.isfile(ifile):
@@ -43,6 +53,29 @@ def get_block(lines, keyword, skip=0, nlines=None):
4353
return ret
4454

4555

56+
def get_stru_block(lines, keyword):
57+
# return the block of lines after keyword in STRU file, and skip the blank lines
58+
59+
def clean_comment(line):
60+
return re.split("[#]", line)[0]
61+
62+
ret = []
63+
found = False
64+
for i in range(len(lines)):
65+
if clean_comment(lines[i]).strip() == keyword:
66+
found = True
67+
for j in range(i + 1, len(lines)):
68+
if clean_comment(lines[j]).strip() == "":
69+
continue
70+
elif clean_comment(lines[j]).strip() in ABACUS_STRU_KEYS:
71+
break
72+
else:
73+
ret.append(clean_comment(lines[j]))
74+
if not found:
75+
return None
76+
return ret
77+
78+
4679
def get_geometry_in(fname, inlines):
4780
geometry_path_in = os.path.join(fname, "STRU")
4881
for line in inlines:
@@ -64,8 +97,8 @@ def get_path_out(fname, inlines):
6497

6598

6699
def get_cell(geometry_inlines):
67-
cell_lines = get_block(geometry_inlines, "LATTICE_VECTORS", skip=0, nlines=3)
68-
celldm_lines = get_block(geometry_inlines, "LATTICE_CONSTANT", skip=0, nlines=1)
100+
cell_lines = get_stru_block(geometry_inlines, "LATTICE_VECTORS")
101+
celldm_lines = get_stru_block(geometry_inlines, "LATTICE_CONSTANT")
69102

70103
celldm = float(celldm_lines[0].split()[0]) * bohr2ang # lattice const is in Bohr
71104
cell = []
@@ -76,7 +109,7 @@ def get_cell(geometry_inlines):
76109

77110

78111
def get_coords(celldm, cell, geometry_inlines, inlines=None):
79-
coords_lines = get_block(geometry_inlines, "ATOMIC_POSITIONS", skip=0)
112+
coords_lines = get_stru_block(geometry_inlines, "ATOMIC_POSITIONS")
80113
# assuming that ATOMIC_POSITIONS is at the bottom of the STRU file
81114
coord_type = coords_lines[0].split()[0].lower() # cartisan or direct
82115
atom_names = [] # element abbr in periodic table

dpdata/amber/mask.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Amber mask."""
2+
23
try:
34
import parmed
45
except ImportError:

dpdata/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Command line interface for dpdata."""
2+
23
import argparse
34
from typing import Optional
45

dpdata/cp2k/output.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def get_xyz_block_generator(self):
117117
lines.append(self.xyz_file_object.readline())
118118
if not lines[-1]:
119119
raise RuntimeError(
120-
"this xyz file may lack of lines, should be {};lines:{}".format(
121-
atom_num + 2, lines
122-
)
120+
f"this xyz file may lack of lines, should be {atom_num + 2};lines:{lines}"
123121
)
124122
yield lines
125123

0 commit comments

Comments
 (0)