Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.282
rev: v0.0.284
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion dpdata/abacus/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def get_energy(outlines, ndump, dump_freq):


def get_frame(fname):
if type(fname) == str:
if isinstance(fname, str):
# if the input parameter is only one string, it is assumed that it is the
# base directory containing INPUT file;
path_in = os.path.join(fname, "INPUT")
Expand Down
2 changes: 1 addition & 1 deletion dpdata/abacus/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def get_coords_from_log(loglines, natoms):


def get_frame(fname):
if type(fname) == str:
if isinstance(fname, str):
# if the input parameter is only one string, it is assumed that it is the
# base directory containing INPUT file;
path_in = os.path.join(fname, "INPUT")
Expand Down
6 changes: 3 additions & 3 deletions dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def get_frame(fname):
"forces": [],
}

if type(fname) == str:
if isinstance(fname, str):
# if the input parameter is only one string, it is assumed that it is the
# base directory containing INPUT file;
path_in = os.path.join(fname, "INPUT")
Expand Down Expand Up @@ -255,7 +255,7 @@ def get_nele_from_stru(geometry_inlines):


def get_frame_from_stru(fname):
assert type(fname) == str
assert isinstance(fname, str)
with open(fname) as fp:
geometry_inlines = fp.read().split("\n")
nele = get_nele_from_stru(geometry_inlines)
Expand Down Expand Up @@ -304,7 +304,7 @@ def make_unlabeled_stru(
out += "\n"

if numerical_descriptor is not None:
assert type(numerical_descriptor) == str
assert isinstance(numerical_descriptor, str)
out += "NUMERICAL_DESCRIPTOR\n%s\n" % numerical_descriptor
out += "\n"

Expand Down
4 changes: 2 additions & 2 deletions dpdata/qe/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ def get_stress(lines):


def get_frame(fname):
if type(fname) == str:
if isinstance(fname, str):
path_out = fname
outname = os.path.basename(path_out)
# the name of the input file is assumed to be different from the output by 'in' and 'out'
inname = outname.replace("out", "in")
path_in = os.path.join(os.path.dirname(path_out), inname)
elif type(fname) == list and len(fname) == 2:
elif isinstance(fname, list) and len(fname) == 2:
path_in = fname[0]
path_out = fname[1]
else:
Expand Down
4 changes: 2 additions & 2 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def replicate(self, ncopy):
if len(ncopy) != 3:
raise RuntimeError("ncopy must be a list or tuple with 3 int")
for ii in ncopy:
if type(ii) is not int:
if not isinstance(ii, int):
raise RuntimeError("ncopy must be a list or tuple must with 3 int")

tmp = System()
Expand Down Expand Up @@ -690,7 +690,7 @@ def replace(self, initial_atom_type, end_atom_type, replace_num):
raise RuntimeError(
"Must use method replace() of the instance of class dpdata.System"
)
if type(replace_num) is not int:
if not isinstance(replace_num, int):
raise ValueError(f"replace_num must be a integer. Now is {replace_num}")
if replace_num <= 0:
raise ValueError(f"replace_num must be larger than 0.Now is {replace_num}")
Expand Down