Skip to content

Commit b826633

Browse files
[pre-commit.ci] pre-commit autoupdate (#779)
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.6...v0.9.1) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 46251a7 commit b826633

File tree

8 files changed

+40
-40
lines changed

8 files changed

+40
-40
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
# Python
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
2323
# Ruff version.
24-
rev: v0.8.6
24+
rev: v0.9.1
2525
hooks:
2626
- id: ruff
2727
args: ["--fix"]

dpdata/abacus/md.py

Lines changed: 3 additions & 3 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

dpdata/deepmd/mixed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def to_system_data(folder, type_map=None, labels=True):
1515
if type_map is not None:
1616
assert isinstance(type_map, list)
1717
missing_type = [i for i in old_type_map if i not in type_map]
18-
assert (
19-
not missing_type
20-
), f"These types are missing in selected type_map: {missing_type} !"
18+
assert not missing_type, (
19+
f"These types are missing in selected type_map: {missing_type} !"
20+
)
2121
index_map = np.array([type_map.index(i) for i in old_type_map])
2222
data["atom_names"] = type_map.copy()
2323
else:

dpdata/plugins/n2p2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ def from_labeled_system(self, file_name: FileType, **kwargs):
8585
energy = None
8686
elif line.lower() == "end":
8787
# If we are at the end of a section, process the section
88-
assert (
89-
len(coord) == len(atype) == len(force)
90-
), "Number of atoms, atom types, and forces must match."
88+
assert len(coord) == len(atype) == len(force), (
89+
"Number of atoms, atom types, and forces must match."
90+
)
9191

9292
# Check if the number of atoms is consistent across all frames
9393
natom = len(coord)
9494
if natom0 is None:
9595
natom0 = natom
9696
else:
97-
assert (
98-
natom == natom0
99-
), "The number of atoms in all frames must be the same."
97+
assert natom == natom0, (
98+
"The number of atoms in all frames must be the same."
99+
)
100100

101101
# Check if the number of atoms of each type is consistent across all frames
102102
atype = np.array(atype)
@@ -108,9 +108,9 @@ def from_labeled_system(self, file_name: FileType, **kwargs):
108108
if natoms0 is None:
109109
natoms0 = natoms
110110
else:
111-
assert (
112-
natoms == natoms0
113-
), "The number of atoms of each type in all frames must be the same."
111+
assert natoms == natoms0, (
112+
"The number of atoms of each type in all frames must be the same."
113+
)
114114
if atom_types0 is None:
115115
atom_types0 = atype
116116
atom_order = match_indices(atom_types0, atype)

dpdata/stat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ class ErrorsBase(metaclass=ABCMeta):
5555
SYSTEM_TYPE = object
5656

5757
def __init__(self, system_1: SYSTEM_TYPE, system_2: SYSTEM_TYPE) -> None:
58-
assert isinstance(
59-
system_1, self.SYSTEM_TYPE
60-
), f"system_1 should be {self.SYSTEM_TYPE.__name__}"
61-
assert isinstance(
62-
system_2, self.SYSTEM_TYPE
63-
), f"system_2 should be {self.SYSTEM_TYPE.__name__}"
58+
assert isinstance(system_1, self.SYSTEM_TYPE), (
59+
f"system_1 should be {self.SYSTEM_TYPE.__name__}"
60+
)
61+
assert isinstance(system_2, self.SYSTEM_TYPE), (
62+
f"system_2 should be {self.SYSTEM_TYPE.__name__}"
63+
)
6464
self.system_1 = system_1
6565
self.system_2 = system_2
6666

dpdata/vasp/outcar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ def analyze_block(lines, ntot, nelm, ml=False):
161161
not lines[idx + in_kB_index].split()[0:2] == ["in", "kB"]
162162
):
163163
in_kB_index += 1
164-
assert idx + in_kB_index < len(
165-
lines
166-
), 'ERROR: "in kB" is not found in OUTCAR. Unable to extract virial.'
164+
assert idx + in_kB_index < len(lines), (
165+
'ERROR: "in kB" is not found in OUTCAR. Unable to extract virial.'
166+
)
167167
tmp_v = [float(ss) for ss in lines[idx + in_kB_index].split()[2:8]]
168168
virial = np.zeros([3, 3])
169169
virial[0][0] = tmp_v[0]

dpdata/vasp/xml.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88

99
def check_name(item, name):
10-
assert (
11-
item.attrib["name"] == name
12-
), "item attrib '{}' dose not math required '{}'".format(item.attrib["name"], name)
10+
assert item.attrib["name"] == name, (
11+
"item attrib '{}' dose not math required '{}'".format(item.attrib["name"], name)
12+
)
1313

1414

1515
def get_varray(varray):

tests/comp_sys.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ def _make_comp_ms_test_func(comp_sys_test_func):
118118
"""
119119

120120
def comp_ms_test_func(iobj):
121-
assert hasattr(iobj, "ms_1") and hasattr(
122-
iobj, "ms_2"
123-
), "Multi-system objects must be present"
121+
assert hasattr(iobj, "ms_1") and hasattr(iobj, "ms_2"), (
122+
"Multi-system objects must be present"
123+
)
124124
iobj.assertEqual(len(iobj.ms_1), len(iobj.ms_2))
125125
keys = [ii.formula for ii in iobj.ms_1]
126126
keys_2 = [ii.formula for ii in iobj.ms_2]
127-
assert sorted(keys) == sorted(
128-
keys_2
129-
), f"Keys of two MS are not equal: {keys} != {keys_2}"
127+
assert sorted(keys) == sorted(keys_2), (
128+
f"Keys of two MS are not equal: {keys} != {keys_2}"
129+
)
130130
for kk in keys:
131131
iobj.system_1 = iobj.ms_1[kk]
132132
iobj.system_2 = iobj.ms_2[kk]
@@ -197,17 +197,17 @@ def test_is_nopbc(self):
197197

198198
class MSAllIsPBC:
199199
def test_is_pbc(self):
200-
assert hasattr(self, "ms_1") and hasattr(
201-
self, "ms_2"
202-
), "Multi-system objects must be present and iterable"
200+
assert hasattr(self, "ms_1") and hasattr(self, "ms_2"), (
201+
"Multi-system objects must be present and iterable"
202+
)
203203
self.assertTrue(all([not ss.nopbc for ss in self.ms_1]))
204204
self.assertTrue(all([not ss.nopbc for ss in self.ms_2]))
205205

206206

207207
class MSAllIsNoPBC:
208208
def test_is_nopbc(self):
209-
assert hasattr(self, "ms_1") and hasattr(
210-
self, "ms_2"
211-
), "Multi-system objects must be present and iterable"
209+
assert hasattr(self, "ms_1") and hasattr(self, "ms_2"), (
210+
"Multi-system objects must be present and iterable"
211+
)
212212
self.assertTrue(all([ss.nopbc for ss in self.ms_1]))
213213
self.assertTrue(all([ss.nopbc for ss in self.ms_2]))

0 commit comments

Comments
 (0)