Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 15, 2024
1 parent 8e9bbc5 commit 1b8d92f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion deepmd/entrypoints/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,9 @@ def test_property(
assert isinstance(property_name, list)
assert isinstance(property_dim, list)
assert sum(property_dim) == dp.task_dim
assert len(property_name) == len(property_dim), f"The shape of the `property_name` you provide must be consistent with the `property_dim`, but your `property_name` is {property_name} and your `property_dim` is {property_dim}!"
assert (
len(property_name) == len(property_dim)
), f"The shape of the `property_name` you provide must be consistent with the `property_dim`, but your `property_name` is {property_name} and your `property_dim` is {property_dim}!"
for name, dim in zip(property_name, property_dim):
data.add(name, dim, atomic=False, must=True, high_prec=True)
if has_atom_property:
Expand Down
1 change: 1 addition & 0 deletions deepmd/utils/out_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def compute_stats_from_atomic(
)
return output_bias, output_std


def compute_stats_property(
output_redu: np.ndarray,
natoms: np.ndarray,
Expand Down
12 changes: 10 additions & 2 deletions source/tests/common/dpmodel/test_output_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ def test_model_output_def(self) -> None:
c_differentiable=False,
atomic=True,
intensive=True,
sub_var_name=["foo","bar"],
sub_var_name=["foo", "bar"],
),
]
# fitting definition
fd = FittingOutputDef(defs)
expected_keys = ["energy", "energy2", "energy3", "dos", "foo", "gap", "property"]
expected_keys = [
"energy",
"energy2",
"energy3",
"dos",
"foo",
"gap",
"property",
]
self.assertEqual(
set(expected_keys),
set(fd.keys()),
Expand Down
6 changes: 4 additions & 2 deletions source/tests/common/test_out_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ def test_compute_stats_from_redu_with_assigned_bias(self) -> None:
def test_compute_stats_property(self) -> None:
bias, std = compute_stats_property(self.output_redu, self.natoms)
for fake_atom_bias in bias:
np.testing.assert_allclose(fake_atom_bias, np.mean(self.output_redu,axis=0), rtol=1e-7)
np.testing.assert_allclose(std, np.std(self.output_redu,axis=0), rtol=1e-7)
np.testing.assert_allclose(
fake_atom_bias, np.mean(self.output_redu, axis=0), rtol=1e-7
)
np.testing.assert_allclose(std, np.std(self.output_redu, axis=0), rtol=1e-7)

def test_compute_stats_from_atomic(self) -> None:
bias, std = compute_stats_from_atomic(self.output, self.atype)
Expand Down

0 comments on commit 1b8d92f

Please sign in to comment.