Skip to content

Commit

Permalink
throw erros when rmin is no less than rmax
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Mar 5, 2024
1 parent c765cdb commit d8fefb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deepmd/dpmodel/utils/env_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def compute_smooth_weight(
rmax: float,
):
"""Compute smooth weight for descriptor elements."""
if rmin >= rmax:
raise ValueError("rmin should be less than rmax.")

Check warning on line 21 in deepmd/dpmodel/utils/env_mat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/dpmodel/utils/env_mat.py#L20-L21

Added lines #L20 - L21 were not covered by tests
min_mask = distance <= rmin
max_mask = distance >= rmax
mid_mask = np.logical_not(np.logical_or(min_mask, max_mask))
Expand Down
2 changes: 2 additions & 0 deletions deepmd/pt/utils/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ def build_neighbor_list(

def compute_smooth_weight(distance, rmin: float, rmax: float):
"""Compute smooth weight for descriptor elements."""
if rmin >= rmax:
raise ValueError("rmin should be less than rmax.")

Check warning on line 232 in deepmd/pt/utils/preprocess.py

View check run for this annotation

Codecov / codecov/patch

deepmd/pt/utils/preprocess.py#L231-L232

Added lines #L231 - L232 were not covered by tests
min_mask = distance <= rmin
max_mask = distance >= rmax
mid_mask = torch.logical_not(torch.logical_or(min_mask, max_mask))
Expand Down

0 comments on commit d8fefb4

Please sign in to comment.