Skip to content

Commit c09e0ee

Browse files
[pre-commit.ci] pre-commit autoupdate (#453)
<!--pre-commit.ci start--> updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.243 → v0.0.262](astral-sh/ruff-pre-commit@v0.0.243...v0.0.262) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3c09356 commit c09e0ee

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
- id: black-jupyter
2424
- repo: https://github.com/charliermarsh/ruff-pre-commit
2525
# Ruff version.
26-
rev: v0.0.243
26+
rev: v0.0.262
2727
hooks:
2828
- id: ruff
2929
args: ["--fix"]

dpdata/plugins/ase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def from_multi_systems(
140140
yield from frames
141141

142142
def to_system(self, data, **kwargs):
143-
"""convert System to ASE Atom obj."""
143+
"""Convert System to ASE Atom obj."""
144144
from ase import Atoms
145145

146146
structures = []

dpdata/plugins/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@Format.register("list")
55
class ListFormat(Format):
66
def to_system(self, data, **kwargs):
7-
"""convert system to list, usefull for data collection."""
7+
"""Convert system to list, usefull for data collection."""
88
from dpdata import LabeledSystem, System
99

1010
if "forces" in data:

dpdata/plugins/pymatgen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@Format.register("pymatgen/structure")
88
class PyMatgenStructureFormat(Format):
99
def to_system(self, data, **kwargs):
10-
"""convert System to Pymatgen Structure obj."""
10+
"""Convert System to Pymatgen Structure obj."""
1111
structures = []
1212
try:
1313
from pymatgen.core import Structure
@@ -40,7 +40,7 @@ def from_system(self, file_name, **kwargs):
4040
return dpdata.pymatgen.molecule.to_system_data(file_name)
4141

4242
def to_system(self, data, **kwargs):
43-
"""convert System to Pymatgen Molecule obj."""
43+
"""Convert System to Pymatgen Molecule obj."""
4444
molecules = []
4545
try:
4646
from pymatgen.core import Molecule
@@ -61,7 +61,7 @@ def to_system(self, data, **kwargs):
6161
@Format.register_to("to_pymatgen_ComputedStructureEntry")
6262
class PyMatgenCSEFormat(Format):
6363
def to_labeled_system(self, data, *args, **kwargs):
64-
"""convert System to Pymagen ComputedStructureEntry obj."""
64+
"""Convert System to Pymagen ComputedStructureEntry obj."""
6565
try:
6666
from pymatgen.entries.computed_entries import ComputedStructureEntry
6767
except ModuleNotFoundError as e:

dpdata/system.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ def check(self, system: "System"):
116116
pass
117117
elif not isinstance(data, self.dtype):
118118
raise DataError(
119-
"Type of %s is %s, but expected %s"
120-
% (self.name, type(data).__name__, self.dtype.__name__)
119+
f"Type of {self.name} is {type(data).__name__}, but expected {self.dtype.__name__}"
121120
)
122121
# check shape
123122
if self.shape is not None:
@@ -126,8 +125,7 @@ def check(self, system: "System"):
126125
if isinstance(data, np.ndarray):
127126
if data.size and shape != data.shape:
128127
raise DataError(
129-
"Shape of %s is %s, but expected %s"
130-
% (self.name, data.shape, shape)
128+
f"Shape of {self.name} is {data.shape}, but expected {shape}"
131129
)
132130
elif isinstance(data, list):
133131
if len(shape) and shape[0] != len(data):
@@ -381,7 +379,7 @@ def __len__(self):
381379
return self.get_nframes()
382380

383381
def __add__(self, others):
384-
"""magic method "+" operation."""
382+
"""Magic method "+" operation."""
385383
self_copy = self.copy()
386384
if isinstance(others, System):
387385
other_copy = others.copy()
@@ -396,7 +394,7 @@ def __add__(self, others):
396394
return self.__class__.from_dict({"data": self_copy.data})
397395

398396
def dump(self, filename, indent=4):
399-
"""dump .json or .yaml file."""
397+
"""Dump .json or .yaml file."""
400398
dumpfn(self.as_dict(), filename, indent=indent)
401399

402400
def map_atom_types(self, type_map=None) -> np.ndarray:
@@ -439,7 +437,7 @@ def map_atom_types(self, type_map=None) -> np.ndarray:
439437

440438
@staticmethod
441439
def load(filename):
442-
"""rebuild System obj. from .json or .yaml file."""
440+
"""Rebuild System obj. from .json or .yaml file."""
443441
return loadfn(filename)
444442

445443
def as_dict(self):
@@ -527,8 +525,7 @@ def append(self, system):
527525
return False
528526
if system.uniq_formula != self.uniq_formula:
529527
raise RuntimeError(
530-
"systems with inconsistent formula could not be append: %s v.s. %s"
531-
% (self.uniq_formula, system.uniq_formula)
528+
f"systems with inconsistent formula could not be append: {self.uniq_formula} v.s. {system.uniq_formula}"
532529
)
533530
if system.data["atom_names"] != self.data["atom_names"]:
534531
# allow to append a system with different atom_names order
@@ -1193,7 +1190,7 @@ def __str__(self):
11931190
return ret
11941191

11951192
def __add__(self, others):
1196-
"""magic method "+" operation."""
1193+
"""Magic method "+" operation."""
11971194
self_copy = self.copy()
11981195
if isinstance(others, LabeledSystem):
11991196
other_copy = others.copy()
@@ -1389,7 +1386,7 @@ def __str__(self):
13891386
)
13901387

13911388
def __add__(self, others):
1392-
"""magic method "+" operation."""
1389+
"""Magic method "+" operation."""
13931390
self_copy = deepcopy(self)
13941391
if isinstance(others, System) or isinstance(others, MultiSystems):
13951392
return self.__class__(self, others)

0 commit comments

Comments
 (0)