Skip to content

Commit 2dbd423

Browse files
pre-commit-ci[bot]ChiahsinChu
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5d89b4b commit 2dbd423

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

deepmd/pt/infer/deep_eval.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,24 +543,33 @@ def _eval_model(
543543
atomic_weight = np.tile(atomic_weight, (nframes, 1))
544544
elif atomic_weight.ndim == 2:
545545
# (nframes, natoms) or (natoms, k)
546-
if atomic_weight.shape[0] == natoms and atomic_weight.shape[1] != nframes:
546+
if (
547+
atomic_weight.shape[0] == natoms
548+
and atomic_weight.shape[1] != nframes
549+
):
547550
# (natoms, k) - broadcast across frames
548551
atomic_weight = np.tile(atomic_weight, (nframes, 1, 1))
549-
elif atomic_weight.shape[0] != nframes or atomic_weight.shape[1] != natoms:
552+
elif (
553+
atomic_weight.shape[0] != nframes
554+
or atomic_weight.shape[1] != natoms
555+
):
550556
raise ValueError(
551557
f"atomic_weight shape {atomic_weight.shape} incompatible with nframes={nframes} and natoms={natoms}"
552558
)
553559
elif atomic_weight.ndim == 3:
554560
# (nframes, natoms, k)
555-
if atomic_weight.shape[0] != nframes or atomic_weight.shape[1] != natoms:
561+
if (
562+
atomic_weight.shape[0] != nframes
563+
or atomic_weight.shape[1] != natoms
564+
):
556565
raise ValueError(
557566
f"atomic_weight shape {atomic_weight.shape} incompatible with nframes={nframes} and natoms={natoms}"
558567
)
559568
else:
560569
raise ValueError(
561570
f"atomic_weight must have 1, 2, or 3 dimensions, got {atomic_weight.ndim}"
562571
)
563-
572+
564573
atomic_weight_input = to_torch_tensor(
565574
atomic_weight.reshape(nframes, natoms, -1)
566575
)
@@ -657,24 +666,33 @@ def _eval_model_spin(
657666
atomic_weight = np.tile(atomic_weight, (nframes, 1))
658667
elif atomic_weight.ndim == 2:
659668
# (nframes, natoms) or (natoms, k)
660-
if atomic_weight.shape[0] == natoms and atomic_weight.shape[1] != nframes:
669+
if (
670+
atomic_weight.shape[0] == natoms
671+
and atomic_weight.shape[1] != nframes
672+
):
661673
# (natoms, k) - broadcast across frames
662674
atomic_weight = np.tile(atomic_weight, (nframes, 1, 1))
663-
elif atomic_weight.shape[0] != nframes or atomic_weight.shape[1] != natoms:
675+
elif (
676+
atomic_weight.shape[0] != nframes
677+
or atomic_weight.shape[1] != natoms
678+
):
664679
raise ValueError(
665680
f"atomic_weight shape {atomic_weight.shape} incompatible with nframes={nframes} and natoms={natoms}"
666681
)
667682
elif atomic_weight.ndim == 3:
668683
# (nframes, natoms, k)
669-
if atomic_weight.shape[0] != nframes or atomic_weight.shape[1] != natoms:
684+
if (
685+
atomic_weight.shape[0] != nframes
686+
or atomic_weight.shape[1] != natoms
687+
):
670688
raise ValueError(
671689
f"atomic_weight shape {atomic_weight.shape} incompatible with nframes={nframes} and natoms={natoms}"
672690
)
673691
else:
674692
raise ValueError(
675693
f"atomic_weight must have 1, 2, or 3 dimensions, got {atomic_weight.ndim}"
676694
)
677-
695+
678696
atomic_weight_input = to_torch_tensor(
679697
atomic_weight.reshape(nframes, natoms, -1)
680698
)

0 commit comments

Comments
 (0)