diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fe362cb0e..ab4fca9c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: - id: black-jupyter - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.284 + rev: v0.0.285 hooks: - id: ruff args: ["--fix"] @@ -35,7 +35,7 @@ repos: args: ["--write"] # Python inside docs - repo: https://github.com/asottile/blacken-docs - rev: 1.15.0 + rev: 1.16.0 hooks: - id: blacken-docs ci: diff --git a/dpdata/abacus/md.py b/dpdata/abacus/md.py index 55538d0b1..4b8ec0387 100644 --- a/dpdata/abacus/md.py +++ b/dpdata/abacus/md.py @@ -206,7 +206,7 @@ def get_frame(fname): data["energies"] = energy data["forces"] = force data["virials"] = stress - if type(data["virials"]) != np.ndarray: + if not isinstance(data["virials"], np.ndarray): del data["virials"] data["orig"] = np.zeros(3) diff --git a/dpdata/md/rdf.py b/dpdata/md/rdf.py index d5409a0ce..de8f1c746 100644 --- a/dpdata/md/rdf.py +++ b/dpdata/md/rdf.py @@ -62,9 +62,9 @@ def _compute_rdf_1frame(box, posis, atype, sel_type=[None, None], max_r=5, nbins sel_type[0] = all_types if sel_type[1] is None: sel_type[1] = all_types - if type(sel_type[0]) is not list: + if not isinstance(sel_type[0], list): sel_type[0] = [sel_type[0]] - if type(sel_type[1]) is not list: + if not isinstance(sel_type[1], list): sel_type[1] = [sel_type[1]] natoms = len(posis) import ase.neighborlist diff --git a/dpdata/system.py b/dpdata/system.py index cf03aa617..daf0c8858 100644 --- a/dpdata/system.py +++ b/dpdata/system.py @@ -509,7 +509,7 @@ def check_type_map(self, type_map): self.sort_atom_names(type_map=type_map) def apply_type_map(self, type_map): - if type_map is not None and type(type_map) is list: + if type_map is not None and isinstance(type_map, list): self.check_type_map(type_map) else: raise RuntimeError("invalid type map, cannot be applied") diff --git a/plugin_example/README.md b/plugin_example/README.md index 322756f93..a506a4e88 100644 --- a/plugin_example/README.md +++ b/plugin_example/README.md @@ -6,6 +6,7 @@ pip install . ```py import dpdata + print(dpdata.System(12, fmt="random")) ```