Skip to content

Commit

Permalink
resolve conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
iProzd committed Jun 4, 2024
1 parent be1a18e commit a394d97
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion deepmd/dpmodel/descriptor/dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 392 in deepmd/dpmodel/descriptor/dpa1.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/descriptor/dpa1.py#L392

Added line #L392 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
obj = self.se_atten
obj.ntypes = len(type_map)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/dpmodel/descriptor/dpa2.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 548 in deepmd/dpmodel/descriptor/dpa2.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/descriptor/dpa2.py#L548

Added line #L548 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.type_map = type_map
self.exclude_types = map_pair_exclude_types(self.exclude_types, slim_index)
Expand Down
4 changes: 2 additions & 2 deletions deepmd/dpmodel/descriptor/se_e2_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_e2_a",
"@version": 1,
"@version": 2,
"rcut": self.rcut,
"rcut_smth": self.rcut_smth,
"sel": self.sel,
Expand Down Expand Up @@ -419,7 +419,7 @@ def serialize(self) -> dict:
def deserialize(cls, data: dict) -> "DescrptSeA":
"""Deserialize from dict."""
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 422 in deepmd/dpmodel/descriptor/se_e2_a.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/descriptor/se_e2_a.py#L422

Added line #L422 was not covered by tests
data.pop("@class", None)
data.pop("type", None)
variables = data.pop("@variables")
Expand Down
4 changes: 2 additions & 2 deletions deepmd/dpmodel/descriptor/se_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_r",
"@version": 1,
"@version": 2,
"rcut": self.rcut,
"rcut_smth": self.rcut_smth,
"sel": self.sel,
Expand Down Expand Up @@ -344,7 +344,7 @@ def serialize(self) -> dict:
def deserialize(cls, data: dict) -> "DescrptSeR":
"""Deserialize from dict."""
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 347 in deepmd/dpmodel/descriptor/se_r.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/descriptor/se_r.py#L347

Added line #L347 was not covered by tests
data.pop("@class", None)
data.pop("type", None)
variables = data.pop("@variables")
Expand Down
4 changes: 2 additions & 2 deletions deepmd/dpmodel/descriptor/se_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_e3",
"@version": 1,
"@version": 2,
"rcut": self.rcut,
"rcut_smth": self.rcut_smth,
"sel": self.sel,
Expand All @@ -345,7 +345,7 @@ def serialize(self) -> dict:
def deserialize(cls, data: dict) -> "DescrptSeT":
"""Deserialize from dict."""
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 348 in deepmd/dpmodel/descriptor/se_t.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/descriptor/se_t.py#L348

Added line #L348 was not covered by tests
data.pop("@class", None)
data.pop("type", None)
variables = data.pop("@variables")
Expand Down
2 changes: 1 addition & 1 deletion deepmd/dpmodel/fitting/dipole_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 164 in deepmd/dpmodel/fitting/dipole_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/dipole_fitting.py#L164

Added line #L164 was not covered by tests
var_name = data.pop("var_name", None)
assert var_name == "dipole"
return super().deserialize(data)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/dpmodel/fitting/dos_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 77 in deepmd/dpmodel/fitting/dos_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/dos_fitting.py#L77

Added line #L77 was not covered by tests
data["numb_dos"] = data.pop("dim_out")
data.pop("tot_ener_zero", None)
data.pop("var_name", None)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/dpmodel/fitting/ener_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 77 in deepmd/dpmodel/fitting/ener_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/ener_fitting.py#L77

Added line #L77 was not covered by tests
data.pop("var_name")
data.pop("dim_out")
return super().deserialize(data)
Expand Down
5 changes: 3 additions & 2 deletions deepmd/dpmodel/fitting/general_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 202 in deepmd/dpmodel/fitting/general_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/general_fitting.py#L202

Added line #L202 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
assert self.mixed_types, "Only models in mixed types can perform type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.type_map = type_map
self.ntypes = len(type_map)
Expand Down Expand Up @@ -251,7 +252,7 @@ def serialize(self) -> dict:
"""Serialize the fitting to dict."""
return {
"@class": "Fitting",
"@version": 1,
"@version": 2,
"var_name": self.var_name,
"ntypes": self.ntypes,
"dim_descrpt": self.dim_descrpt,
Expand Down
2 changes: 1 addition & 1 deletion deepmd/dpmodel/fitting/invar_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 187 in deepmd/dpmodel/fitting/invar_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/invar_fitting.py#L187

Added line #L187 was not covered by tests
return super().deserialize(data)

def _net_out_dim(self):
Expand Down
7 changes: 4 additions & 3 deletions deepmd/dpmodel/fitting/polarizability_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __getitem__(self, key):
def serialize(self) -> dict:
data = super().serialize()
data["type"] = "polar"
data["@version"] = 2
data["@version"] = 3

Check warning on line 195 in deepmd/dpmodel/fitting/polarizability_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/polarizability_fitting.py#L195

Added line #L195 was not covered by tests
data["embedding_width"] = self.embedding_width
data["old_impl"] = self.old_impl
data["fit_diag"] = self.fit_diag
Expand All @@ -204,7 +204,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 2, 1)
check_version_compatibility(data.pop("@version", 1), 3, 1)

Check warning on line 207 in deepmd/dpmodel/fitting/polarizability_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/polarizability_fitting.py#L207

Added line #L207 was not covered by tests
var_name = data.pop("var_name", None)
assert var_name == "polar"
return super().deserialize(data)
Expand All @@ -226,7 +226,8 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 227 in deepmd/dpmodel/fitting/polarizability_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/fitting/polarizability_fitting.py#L227

Added line #L227 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
assert self.mixed_types, "Only models in mixed types can perform type slimming!"
super().slim_type_map(type_map=type_map)
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.scale = self.scale[slim_index]
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/descriptor/dpa1.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 420 in deepmd/pt/model/descriptor/dpa1.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/dpa1.py#L420

Added line #L420 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
obj = self.se_atten
obj.ntypes = len(type_map)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/descriptor/dpa2.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 351 in deepmd/pt/model/descriptor/dpa2.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/dpa2.py#L351

Added line #L351 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.type_map = type_map
self.exclude_types = map_pair_exclude_types(self.exclude_types, slim_index)
Expand Down
4 changes: 2 additions & 2 deletions deepmd/pt/model/descriptor/se_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_e2_a",
"@version": 1,
"@version": 2,
"rcut": obj.rcut,
"rcut_smth": obj.rcut_smth,
"sel": obj.sel,
Expand Down Expand Up @@ -300,7 +300,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "DescrptSeA":
data = data.copy()
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 303 in deepmd/pt/model/descriptor/se_a.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_a.py#L303

Added line #L303 was not covered by tests
data.pop("@class", None)
data.pop("type", None)
variables = data.pop("@variables")
Expand Down
4 changes: 2 additions & 2 deletions deepmd/pt/model/descriptor/se_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_r",
"@version": 1,
"@version": 2,
"rcut": self.rcut,
"rcut_smth": self.rcut_smth,
"sel": self.sel,
Expand Down Expand Up @@ -414,7 +414,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "DescrptSeR":
data = data.copy()
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 417 in deepmd/pt/model/descriptor/se_r.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_r.py#L417

Added line #L417 was not covered by tests
variables = data.pop("@variables")
embeddings = data.pop("embeddings")
env_mat = data.pop("env_mat")
Expand Down
4 changes: 2 additions & 2 deletions deepmd/pt/model/descriptor/se_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def serialize(self) -> dict:
return {
"@class": "Descriptor",
"type": "se_e3",
"@version": 1,
"@version": 2,
"rcut": obj.rcut,
"rcut_smth": obj.rcut_smth,
"sel": obj.sel,
Expand All @@ -325,7 +325,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "DescrptSeT":
data = data.copy()
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 328 in deepmd/pt/model/descriptor/se_t.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/descriptor/se_t.py#L328

Added line #L328 was not covered by tests
data.pop("@class", None)
data.pop("type", None)
variables = data.pop("@variables")
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/task/dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 135 in deepmd/pt/model/task/dipole.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/dipole.py#L135

Added line #L135 was not covered by tests
data.pop("var_name", None)
return super().deserialize(data)

Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/task/dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def output_def(self) -> FittingOutputDef:
@classmethod
def deserialize(cls, data: dict) -> "DOSFittingNet":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 104 in deepmd/pt/model/task/dos.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/dos.py#L104

Added line #L104 was not covered by tests
data.pop("@class", None)
data.pop("var_name", None)
data.pop("tot_ener_zero", None)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/task/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 83 in deepmd/pt/model/task/ener.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/ener.py#L83

Added line #L83 was not covered by tests
data.pop("var_name")
data.pop("dim_out")
return super().deserialize(data)
Expand Down
5 changes: 3 additions & 2 deletions deepmd/pt/model/task/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 260 in deepmd/pt/model/task/fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/fitting.py#L260

Added line #L260 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
assert self.mixed_types, "Only models in mixed types can perform type slimming!"
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.type_map = type_map
self.ntypes = len(type_map)
Expand All @@ -270,7 +271,7 @@ def serialize(self) -> dict:
"""Serialize the fitting to dict."""
return {
"@class": "Fitting",
"@version": 1,
"@version": 2,
"var_name": self.var_name,
"ntypes": self.ntypes,
"dim_descrpt": self.dim_descrpt,
Expand Down
2 changes: 1 addition & 1 deletion deepmd/pt/model/task/invar_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 1, 1)
check_version_compatibility(data.pop("@version", 1), 2, 1)

Check warning on line 142 in deepmd/pt/model/task/invar_fitting.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/invar_fitting.py#L142

Added line #L142 was not covered by tests
return super().deserialize(data)

def output_def(self) -> FittingOutputDef:
Expand Down
7 changes: 4 additions & 3 deletions deepmd/pt/model/task/polarizability.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ def slim_type_map(self, type_map: List[str]) -> None:
"""Change the type related params to slimmed ones, according to slimmed `type_map` and the original one in the model."""
assert (

Check warning on line 166 in deepmd/pt/model/task/polarizability.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/polarizability.py#L166

Added line #L166 was not covered by tests
self.type_map is not None
), "'type_map' must be defined when serializing with slimmed type!"
), "'type_map' must be defined when performing type slimming!"
assert self.mixed_types, "Only models in mixed types can perform type slimming!"
super().slim_type_map(type_map=type_map)
slim_index = get_index_between_two_maps(self.type_map, type_map)
self.scale = self.scale[slim_index]
Expand All @@ -174,7 +175,7 @@ def slim_type_map(self, type_map: List[str]) -> None:
def serialize(self) -> dict:
data = super().serialize()
data["type"] = "polar"
data["@version"] = 2
data["@version"] = 3

Check warning on line 178 in deepmd/pt/model/task/polarizability.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/polarizability.py#L178

Added line #L178 was not covered by tests
data["embedding_width"] = self.embedding_width
data["old_impl"] = self.old_impl
data["fit_diag"] = self.fit_diag
Expand All @@ -186,7 +187,7 @@ def serialize(self) -> dict:
@classmethod
def deserialize(cls, data: dict) -> "GeneralFitting":
data = copy.deepcopy(data)
check_version_compatibility(data.pop("@version", 1), 2, 1)
check_version_compatibility(data.pop("@version", 1), 3, 1)

Check warning on line 190 in deepmd/pt/model/task/polarizability.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/model/task/polarizability.py#L190

Added line #L190 was not covered by tests
data.pop("var_name", None)
return super().deserialize(data)

Expand Down

0 comments on commit a394d97

Please sign in to comment.