Skip to content

Commit d310532

Browse files
[pre-commit.ci] pre-commit autoupdate (#5212)
<!--pre-commit.ci start--> updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.14 → v0.15.0](astral-sh/ruff-pre-commit@v0.14.14...v0.15.0) <!--pre-commit.ci end--> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 97d8ded commit d310532

4 files changed

Lines changed: 23 additions & 17 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
exclude: ^source/3rdparty
3030
- repo: https://github.com/astral-sh/ruff-pre-commit
3131
# Ruff version.
32-
rev: v0.14.14
32+
rev: v0.15.0
3333
hooks:
3434
- id: ruff
3535
args: ["--fix"]

deepmd/dpmodel/utils/serialization.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ def save_dp_model(filename: str, model_dict: dict) -> None:
106106
with h5py.File(filename, "w") as f:
107107
model_dict = traverse_model_dict(
108108
model_dict,
109-
lambda x: f.create_dataset(
110-
f"variable_{variable_counter():04d}", data=x
111-
).name,
109+
lambda x: (
110+
f.create_dataset(f"variable_{variable_counter():04d}", data=x).name
111+
),
112112
)
113113
save_dict = {
114114
**extra_dict,
@@ -118,15 +118,17 @@ def save_dp_model(filename: str, model_dict: dict) -> None:
118118
elif filename_extension in {".yaml", ".yml"}:
119119
model_dict = traverse_model_dict(
120120
model_dict,
121-
lambda x: {
122-
"@class": "np.ndarray",
123-
"@is_variable": True,
124-
"@version": 1,
125-
"dtype": x.dtype.name,
126-
"value": x.tolist(),
127-
}
128-
if isinstance(x, np.ndarray)
129-
else x,
121+
lambda x: (
122+
{
123+
"@class": "np.ndarray",
124+
"@is_variable": True,
125+
"@version": 1,
126+
"dtype": x.dtype.name,
127+
"value": x.tolist(),
128+
}
129+
if isinstance(x, np.ndarray)
130+
else x
131+
),
130132
)
131133
with open(filename, "w") as f:
132134
yaml.safe_dump(

deepmd/pd/utils/multi_task.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ def replace_one_item(
150150
for shared_key in shared_links:
151151
shared_links[shared_key]["links"] = sorted(
152152
shared_links[shared_key]["links"],
153-
key=lambda x: x["shared_level"]
154-
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100,
153+
key=lambda x: (
154+
x["shared_level"]
155+
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100
156+
),
155157
)
156158
# little trick to make spin models in the front to be the base models,
157159
# because its type embeddings are more general.

deepmd/pt/utils/multi_task.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ def replace_one_item(
155155
for shared_key in shared_links:
156156
shared_links[shared_key]["links"] = sorted(
157157
shared_links[shared_key]["links"],
158-
key=lambda x: x["shared_level"]
159-
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100,
158+
key=lambda x: (
159+
x["shared_level"]
160+
- ("spin" in model_config["model_dict"][x["model_key"]]) * 100
161+
),
160162
)
161163
# little trick to make spin models in the front to be the base models,
162164
# because its type embeddings are more general.

0 commit comments

Comments
 (0)