def test_get_parent_fails(self, particle): """Test that get_parent fails if the parent isn't in the tree""" event = Event(particle) child1 = Particle(particle_id=Particle.Type.electron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) with pytest.raises(ValueError): event.get_parent(child1)
def test_get_parent(self, particle): """Test the ability to retrieve parent of a particle""" event = Event(particle) child1 = Particle(particle_id=Particle.Type.electron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) child2 = Particle(particle_id=Particle.Type.positron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) event.add_children(particle, [child1, child2]) assert event.get_parent(child1) == particle assert event.get_parent(child2) == particle assert event.get_parent(particle) is None