Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #4420

Merged
merged 8 commits into from
Nov 29, 2024
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
exclude: ^source/3rdparty
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.4
rev: v0.8.0
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -60,7 +60,7 @@ repos:
- id: blacken-docs
# C++
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.3
rev: v19.1.4
hooks:
- id: clang-format
exclude: ^(source/3rdparty|source/lib/src/gpu/cudart/.+\.inc|.+\.ipynb$)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ def DeepPotential(*args, **kwargs):


__all__ = [
"__version__",
"DeepPotential",
"__version__",
]
12 changes: 6 additions & 6 deletions deepmd/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
)

__all__ = [
"select_idx_map",
"make_default_mesh",
"j_loader",
"VALID_ACTIVATION",
"VALID_PRECISION",
"expand_sys_str",
"get_np_precision",
"VALID_PRECISION",
"VALID_ACTIVATION",
"j_loader",
"make_default_mesh",
"select_idx_map",
]

_PRECISION = Literal["default", "float16", "float32", "float64"]
Expand All @@ -63,9 +63,9 @@
if TYPE_CHECKING:
_DICT_VAL = TypeVar("_DICT_VAL")
__all__ += [
"_ACTIVATION",
"_DICT_VAL",
"_PRECISION",
"_ACTIVATION",
]


Expand Down
12 changes: 6 additions & 6 deletions deepmd/dpmodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
)

__all__ = [
"DPModelCommon",
"PRECISION_DICT",
"DEFAULT_PRECISION",
"NativeOP",
"ModelOutputDef",
"PRECISION_DICT",
"DPModelCommon",
"FittingOutputDef",
"ModelOutputDef",
"NativeOP",
"OutputVariableDef",
"model_check_output",
"fitting_check_output",
"get_reduce_name",
"get_deriv_name",
"get_hessian_name",
"get_reduce_name",
"model_check_output",
]


Expand Down
12 changes: 6 additions & 6 deletions deepmd/dpmodel/atomic_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
)

__all__ = [
"make_base_atomic_model",
"BaseAtomicModel",
"DPAtomicModel",
"DPEnergyAtomicModel",
"PairTabAtomicModel",
"LinearEnergyAtomicModel",
"DPZBLLinearEnergyAtomicModel",
"DPDOSAtomicModel",
"DPPolarAtomicModel",
"DPDipoleAtomicModel",
"DPEnergyAtomicModel",
"DPPolarAtomicModel",
"DPZBLLinearEnergyAtomicModel",
"LinearEnergyAtomicModel",
"PairTabAtomicModel",
"make_base_atomic_model",
]
4 changes: 2 additions & 2 deletions deepmd/dpmodel/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ def safe_cast_array(


__all__ = [
"GLOBAL_NP_FLOAT_PRECISION",
"DEFAULT_PRECISION",
"GLOBAL_ENER_FLOAT_PRECISION",
"GLOBAL_NP_FLOAT_PRECISION",
"PRECISION_DICT",
"RESERVED_PRECISON_DICT",
"DEFAULT_PRECISION",
"NativeOP",
]
8 changes: 4 additions & 4 deletions deepmd/dpmodel/descriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
)

__all__ = [
"DescrptDPA1",
"DescrptDPA2",
"DescrptHybrid",
"DescrptSeA",
"DescrptSeAttenV2",
"DescrptSeR",
"DescrptSeT",
"DescrptSeTTebd",
"DescrptDPA1",
"DescrptSeAttenV2",
"DescrptDPA2",
"DescrptHybrid",
"make_base_descriptor",
]
6 changes: 3 additions & 3 deletions deepmd/dpmodel/fitting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
)

__all__ = [
"InvarFitting",
"make_base_fitting",
"DOSFittingNet",
"DipoleFitting",
"EnergyFittingNet",
"InvarFitting",
"PolarFitting",
"DOSFittingNet",
"PropertyFittingNet",
"make_base_fitting",
]
2 changes: 1 addition & 1 deletion deepmd/dpmodel/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
)

__all__ = [
"DPModelCommon",
"EnergyModel",
"PropertyModel",
"DPModelCommon",
"SpinModel",
"make_model",
]
26 changes: 13 additions & 13 deletions deepmd/dpmodel/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@
)

__all__ = [
"EnvMat",
"make_multilayer_network",
"make_embedding_network",
"make_fitting_network",
"AtomExcludeMask",
"EmbeddingNet",
"EnvMat",
"FittingNet",
"NativeLayer",
"NativeNet",
"NetworkCollection",
"load_dp_model",
"save_dp_model",
"traverse_model_dict",
"build_neighbor_list",
"nlist_distinguish_types",
"get_multiple_nlist_key",
"PairExcludeMask",
"build_multiple_neighbor_list",
"build_neighbor_list",
"extend_coord_with_ghosts",
"normalize_coord",
"get_multiple_nlist_key",
"inter2phys",
"load_dp_model",
"make_embedding_network",
"make_fitting_network",
"make_multilayer_network",
"nlist_distinguish_types",
"normalize_coord",
"phys2inter",
"save_dp_model",
"to_face_distance",
"AtomExcludeMask",
"PairExcludeMask",
"traverse_model_dict",
]
16 changes: 8 additions & 8 deletions deepmd/entrypoints/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,9 @@ def test_dos(
frame_output = np.hstack((test_out, pred_out))

save_txt_file(
detail_path.with_suffix(".dos.out.%.d" % ii),
detail_path.with_suffix(f".dos.out.{ii}"),
frame_output,
header="%s - %.d: data_dos pred_dos" % (system, ii),
header=f"{system} - {ii}: data_dos pred_dos",
append=append_detail,
)

Expand All @@ -718,9 +718,9 @@ def test_dos(
frame_output = np.hstack((test_out, pred_out))

save_txt_file(
detail_path.with_suffix(".ados.out.%.d" % ii),
detail_path.with_suffix(f".ados.out.{ii}"),
frame_output,
header="%s - %.d: data_ados pred_ados" % (system, ii),
header=f"{system} - {ii}: data_ados pred_ados",
append=append_detail,
)

Expand Down Expand Up @@ -860,9 +860,9 @@ def test_property(
frame_output = np.hstack((test_out, pred_out))

save_txt_file(
detail_path.with_suffix(".property.out.%.d" % ii),
detail_path.with_suffix(f".property.out.{ii}"),
frame_output,
header="%s - %.d: data_property pred_property" % (system, ii),
header=f"{system} - {ii}: data_property pred_property",
append=append_detail,
)

Expand All @@ -874,9 +874,9 @@ def test_property(
frame_output = np.hstack((test_out, pred_out))

save_txt_file(
detail_path.with_suffix(".aproperty.out.%.d" % ii),
detail_path.with_suffix(f".aproperty.out.{ii}"),
frame_output,
header="%s - %.d: data_aproperty pred_aproperty" % (system, ii),
header=f"{system} - {ii}: data_aproperty pred_aproperty",
append=append_detail,
)

Expand Down
8 changes: 4 additions & 4 deletions deepmd/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import deepmd.lib

__all__ = [
"GLOBAL_NP_FLOAT_PRECISION",
"GLOBAL_ENER_FLOAT_PRECISION",
"global_float_prec",
"GLOBAL_CONFIG",
"SHARED_LIB_MODULE",
"GLOBAL_ENER_FLOAT_PRECISION",
"GLOBAL_NP_FLOAT_PRECISION",
"SHARED_LIB_DIR",
"SHARED_LIB_MODULE",
"global_float_prec",
]

log = logging.getLogger(__name__)
Expand Down
4 changes: 2 additions & 2 deletions deepmd/infer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
)

__all__ = [
"DeepPot",
"calc_model_devi",
"DeepEval",
"DeepPot",
"DeepPotential",
"calc_model_devi",
]


Expand Down
6 changes: 2 additions & 4 deletions deepmd/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,7 @@ def _standard_input(self, coords, cells, atom_types, fparam, aparam, mixed_type)
fparam = np.tile(fparam.reshape([-1]), [nframes, 1])
else:
raise RuntimeError(
"got wrong size of frame param, should be either %d x %d or %d"
% (nframes, fdim, fdim)
f"got wrong size of frame param, should be either {nframes} x {fdim} or {fdim}"
)
if aparam is not None:
fdim = self.get_dim_aparam()
Expand All @@ -516,8 +515,7 @@ def _standard_input(self, coords, cells, atom_types, fparam, aparam, mixed_type)
aparam = np.tile(aparam.reshape([-1]), [nframes, natoms])
else:
raise RuntimeError(
"got wrong size of frame param, should be either %d x %d x %d or %d x %d or %d"
% (nframes, natoms, fdim, natoms, fdim, fdim)
f"got wrong size of frame param, should be either {nframes} x {natoms} x {fdim} or {natoms} x {fdim} or {fdim}"
)
return coords, cells, atom_types, fparam, aparam, nframes, natoms

Expand Down
8 changes: 4 additions & 4 deletions deepmd/infer/model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ def write_model_devi_out(
assert devi.shape[1] == 8
else:
assert devi.shape[1] > 8
header = "%s\n%10s" % (header, "step")
header = f"{header}\n{'step':10s}"
for item in "vf":
header += "%19s%19s%19s" % (
header += "{:19s}{:19s}{:19s}".format(
f"max_devi_{item}",
f"min_devi_{item}",
f"avg_devi_{item}",
)
header += "%19s" % "devi_e"
header += f'{"devi_e":19s}'
if atomic:
header += "%19s" % "atm_devi_f(N)"
header += f"{'atm_devi_f(N)':19s}"
with open(fname, "ab") as fp:
np.savetxt(
fp,
Expand Down
8 changes: 4 additions & 4 deletions deepmd/jax/descriptor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
)

__all__ = [
"DescrptDPA1",
"DescrptDPA2",
"DescrptHybrid",
"DescrptSeA",
"DescrptSeAttenV2",
"DescrptSeR",
"DescrptSeT",
"DescrptSeTTebd",
"DescrptDPA1",
"DescrptSeAttenV2",
"DescrptDPA2",
"DescrptHybrid",
]
2 changes: 1 addition & 1 deletion deepmd/jax/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

__all__ = [
"jax",
"jax_export",
"jnp",
"nnx",
"jax_export",
]
2 changes: 1 addition & 1 deletion deepmd/jax/fitting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
)

__all__ = [
"EnergyFittingNet",
"DOSFittingNet",
"DipoleFittingNet",
"EnergyFittingNet",
"PolarFittingNet",
]
4 changes: 2 additions & 2 deletions deepmd/jax/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
)

__all__ = [
"EnergyModel",
"DPZBLLinearEnergyAtomicModel",
"DOSModel",
"DPZBLLinearEnergyAtomicModel",
"DipoleModel",
"EnergyModel",
"PolarModel",
"PropertyModel",
]
2 changes: 1 addition & 1 deletion deepmd/pd/model/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ def get_model(model_params):

__all__ = [
"BaseModel",
"get_model",
"DPModelCommon",
"EnergyModel",
"FrozenModel",
"get_model",
"make_model",
]
6 changes: 2 additions & 4 deletions deepmd/pd/model/network/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@
elif nonlinearity == "leaky_relu":
if param is None:
negative_slope = 0.01
elif (
not isinstance(param, bool)
and isinstance(param, int)
or isinstance(param, float)
elif (not isinstance(param, bool) and isinstance(param, int)) or isinstance(

Check warning on line 141 in deepmd/pd/model/network/init.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pd/model/network/init.py#L141

Added line #L141 was not covered by tests
param, float
):
# True/False are instances of int, hence check above
negative_slope = param
Expand Down
Loading