def test_frame_particle(): particle = FrameParticle(create_frame(4)) frames = [create_frame(fid, d) for fid, d in [(5, 33.0), (7, 28.0), (6, 31.2), (7, 34.9), (8, 27.8), (11, 29.0)]] for ix, frame in enumerate(frames): particle.set_new_frame(frame) frames_so_far = frames[:ix+1] frames_to_average = frames_so_far[-4:] expected_average = sum(f.image_dist for f in frames_to_average)/len(frames_to_average) assert particle.average() == expected_average
def create_particle(frame, image_dist_history): particle = FrameParticle(frame) particle.image_dist_history = image_dist_history return particle