Skip to content

Commit 63feaad

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c972cab commit 63feaad

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

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)