def test_uv_prediction(self): data = {} ballMock = PyMock() data["BallInfo"] = ballMock data["BallFound"] = True data[DATA_KEY_IS_NEW_FRAME] = True us = [(i/20.0)**3 for i in range(50)] vs = [(i/20.0)**2 for i in range(50)] time = range(50) us = us[0:30] + us[30:50] vs = vs[0:30] + vs[30:50] time = time[0:30] + time[30:50] us[30] = 10 bidfm = BallInfoDataFilterModule() bidfm.start(data) predictions = [] grades = [] for i in range(len(us)): data["BallInfo"]._setSomething("u", us[i]) data["BallInfo"]._setSomething("v", vs[i]) data[DATA_KEY_CAMERA_CAPTURE_TIMESTAMP] = time[i] # Simplistic counter for increasing time # Call the module bidfm.update(data) self.assertTrue("uvprediction" in data[DATA_KEY_BALL_INFO_FILTERED]) predictions.append(data[DATA_KEY_BALL_INFO_FILTERED]["uvprediction"]) grades.append(data[DATA_KEY_BALL_INFO_FILTERED]["uvgrade"]) if False: import matplotlib.pyplot as plt self.draw_first(predictions, us, vs, 1, 0, 50) # Draw the measured u value for this point in time #plt.plot(range(len(grades)), [math.sqrt(e[0]**2+e[1]**2) for e in grades], 'r-') # COMMENT - The red dots are the real u values measured, # the blue values the estimated values in 5 time steps # The green dotted lines are for better reading the u value # the Vertical lines describe when the estimation of u in 5 time steps is below zero plt.show()