Skip to content

Commit

Permalink
fix issue #381. (#383)
Browse files Browse the repository at this point in the history
The returned system should be of the same type as the perturbed system

Co-authored-by: Han Wang <[email protected]>
  • Loading branch information
amcadmus and Han Wang authored Dec 1, 2022
1 parent 7a1eea9 commit 9936003
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dpdata/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,11 @@ def perturb(self,
perturbed_system : System
The perturbed_system. It contains `pert_num` * frame_num of the input system frames.
"""
if type(self) is not dpdata.System:
raise RuntimeError(
f'Using method perturb() of an instance of {type(self)}. '
f'Must use method perturb() of the instance of class dpdata.System.'
)
perturbed_system = System()
nframes = self.get_nframes()
for ii in range(nframes):
Expand Down

0 comments on commit 9936003

Please sign in to comment.