Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: particle_data: Fixed removal of bonds to deleted particles. #3356

Merged
merged 1 commit into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/particle_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ void local_remove_particle(int part) {
cell = c;
position = i;
} else {
remove_all_bonds_to(p, i);
remove_all_bonds_to(p, part);
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions testsuite/python/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ def test_parallel_property_setters(self):
# Cause a different mpi callback to uncover deadlock immediately
_ = getattr(s.part[:], p)

def test_remove_particle(self):
"""Tests that if a particle is removed,
it no longer exists and bonds to the removed particle are
also removed."""

p1 = self.system.part[self.pid]
p2 = self.system.part.add(pos=p1.pos, bonds=[(self.f1, p1.id)])

p1.remove()
self.assertFalse(self.system.part.exists(self.pid))
self.assertEqual(len(p2.bonds), 0)

def test_zz_remove_all(self):
for id in self.system.part[:].id:
self.system.part[id].remove()
Expand Down