From 45b4200fcd9aca3fbf124591a07fc388dfdfa16b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 02:51:51 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.0.243 → v0.0.262](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.243...v0.0.262) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf83ade3b..186290bce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: - id: black-jupyter - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. - rev: v0.0.243 + rev: v0.0.262 hooks: - id: ruff args: ["--fix"] From d024589829b571d0cfd4501d5518256b96b6f4b9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 02:52:13 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/plugins/ase.py | 2 +- dpdata/plugins/list.py | 2 +- dpdata/plugins/pymatgen.py | 6 +++--- dpdata/system.py | 19 ++++++++----------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/dpdata/plugins/ase.py b/dpdata/plugins/ase.py index 1e68bf71e..f668a0a77 100644 --- a/dpdata/plugins/ase.py +++ b/dpdata/plugins/ase.py @@ -140,7 +140,7 @@ def from_multi_systems( yield from frames def to_system(self, data, **kwargs): - """convert System to ASE Atom obj.""" + """Convert System to ASE Atom obj.""" from ase import Atoms structures = [] diff --git a/dpdata/plugins/list.py b/dpdata/plugins/list.py index eb510da29..68a140748 100644 --- a/dpdata/plugins/list.py +++ b/dpdata/plugins/list.py @@ -4,7 +4,7 @@ @Format.register("list") class ListFormat(Format): def to_system(self, data, **kwargs): - """convert system to list, usefull for data collection.""" + """Convert system to list, usefull for data collection.""" from dpdata import LabeledSystem, System if "forces" in data: diff --git a/dpdata/plugins/pymatgen.py b/dpdata/plugins/pymatgen.py index 531473603..82b64e715 100644 --- a/dpdata/plugins/pymatgen.py +++ b/dpdata/plugins/pymatgen.py @@ -7,7 +7,7 @@ @Format.register("pymatgen/structure") class PyMatgenStructureFormat(Format): def to_system(self, data, **kwargs): - """convert System to Pymatgen Structure obj.""" + """Convert System to Pymatgen Structure obj.""" structures = [] try: from pymatgen.core import Structure @@ -40,7 +40,7 @@ def from_system(self, file_name, **kwargs): return dpdata.pymatgen.molecule.to_system_data(file_name) def to_system(self, data, **kwargs): - """convert System to Pymatgen Molecule obj.""" + """Convert System to Pymatgen Molecule obj.""" molecules = [] try: from pymatgen.core import Molecule @@ -61,7 +61,7 @@ def to_system(self, data, **kwargs): @Format.register_to("to_pymatgen_ComputedStructureEntry") class PyMatgenCSEFormat(Format): def to_labeled_system(self, data, *args, **kwargs): - """convert System to Pymagen ComputedStructureEntry obj.""" + """Convert System to Pymagen ComputedStructureEntry obj.""" try: from pymatgen.entries.computed_entries import ComputedStructureEntry except ModuleNotFoundError as e: diff --git a/dpdata/system.py b/dpdata/system.py index 9408e4cca..5e0c96e7d 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -116,8 +116,7 @@ def check(self, system: "System"): pass elif not isinstance(data, self.dtype): raise DataError( - "Type of %s is %s, but expected %s" - % (self.name, type(data).__name__, self.dtype.__name__) + f"Type of {self.name} is {type(data).__name__}, but expected {self.dtype.__name__}" ) # check shape if self.shape is not None: @@ -126,8 +125,7 @@ def check(self, system: "System"): if isinstance(data, np.ndarray): if data.size and shape != data.shape: raise DataError( - "Shape of %s is %s, but expected %s" - % (self.name, data.shape, shape) + f"Shape of {self.name} is {data.shape}, but expected {shape}" ) elif isinstance(data, list): if len(shape) and shape[0] != len(data): @@ -381,7 +379,7 @@ def __len__(self): return self.get_nframes() def __add__(self, others): - """magic method "+" operation.""" + """Magic method "+" operation.""" self_copy = self.copy() if isinstance(others, System): other_copy = others.copy() @@ -396,7 +394,7 @@ def __add__(self, others): return self.__class__.from_dict({"data": self_copy.data}) def dump(self, filename, indent=4): - """dump .json or .yaml file.""" + """Dump .json or .yaml file.""" dumpfn(self.as_dict(), filename, indent=indent) def map_atom_types(self, type_map=None) -> np.ndarray: @@ -439,7 +437,7 @@ def map_atom_types(self, type_map=None) -> np.ndarray: @staticmethod def load(filename): - """rebuild System obj. from .json or .yaml file.""" + """Rebuild System obj. from .json or .yaml file.""" return loadfn(filename) def as_dict(self): @@ -527,8 +525,7 @@ def append(self, system): return False if system.uniq_formula != self.uniq_formula: raise RuntimeError( - "systems with inconsistent formula could not be append: %s v.s. %s" - % (self.uniq_formula, system.uniq_formula) + f"systems with inconsistent formula could not be append: {self.uniq_formula} v.s. {system.uniq_formula}" ) if system.data["atom_names"] != self.data["atom_names"]: # allow to append a system with different atom_names order @@ -1193,7 +1190,7 @@ def __str__(self): return ret def __add__(self, others): - """magic method "+" operation.""" + """Magic method "+" operation.""" self_copy = self.copy() if isinstance(others, LabeledSystem): other_copy = others.copy() @@ -1389,7 +1386,7 @@ def __str__(self): ) def __add__(self, others): - """magic method "+" operation.""" + """Magic method "+" operation.""" self_copy = deepcopy(self) if isinstance(others, System) or isinstance(others, MultiSystems): return self.__class__(self, others)