def test_monitor_coord_to_image_ind_array_with_nan(self): x_cm, y_cm = np.zeros([10]), np.zeros([10]) x_cm[::2] = np.nan y_cm[::2] = np.nan x, y = monitor_coord_to_image_ind(x_cm, y_cm, 51.91, 32.4) self.assertTrue(np.sum(x[1::2]), 0.5 * 5) self.assertTrue(np.sum(y[1::2]), 0.5 * 5) self.assertTrue(np.sum(np.isnan(x)), 5) self.assertTrue(np.sum(np.isnan(y)), 5)
def get_eye_tracking_data(dataset, missing_data_fill_size): ''' Gets the eye tracking data from the AIBO dataset. ''' try: _, pupil_loc = dataset.get_pupil_location(as_spherical=False) _, pupil_size = dataset.get_pupil_size() except NoEyeTrackingException: pupil_loc = np.full([missing_data_fill_size, 2], np.nan) pupil_size = np.full([missing_data_fill_size], np.nan) finally: pupil_x = pupil_loc[:, 0] pupil_y = pupil_loc[:, 1] pupil_x, pupil_y = monitor_coord_to_image_ind(pupil_x, pupil_y) return {'pupil_x': pupil_x, 'pupil_y': pupil_y, 'pupil_size': pupil_size}
def test_monitor_coord_to_image_ind_array_shape(self): x_cm, y_cm = np.zeros([10]), np.zeros([10]) x, y = monitor_coord_to_image_ind(x_cm, y_cm, 51.91, 32.4) self.assertCountEqual(x.shape, [10]) self.assertCountEqual(y.shape, [10])
def test_monitor_coord_to_image_ind_values_bottom_right(self): x, y = monitor_coord_to_image_ind(25.9, -16.15, 51.9, 32.4) self.assertAlmostEqual(x, 0.999, places=2) self.assertAlmostEqual(y, 0.999, places=2)
def test_monitor_coord_to_image_ind_values_top_left(self): x, y = monitor_coord_to_image_ind(-25.9, 16.15, 51.9, 32.4) self.assertAlmostEqual(x, 0.0, places=2) self.assertAlmostEqual(y, 0.0, places=2)
def test_monitor_coord_to_image_ind_values_center(self): x, y = monitor_coord_to_image_ind(0, 0, 51.9, 32.4) self.assertEqual(x, 0.5) self.assertEqual(y, 0.5)
def test_monitor_coord_to_image_ind_ValueError_high_y(self): with self.assertRaises(ValueError): monitor_coord_to_image_ind(0, 16.5, 51.9, 32.4)
def test_monitor_coord_to_image_ind_ValueError_low_x(self): with self.assertRaises(ValueError): monitor_coord_to_image_ind(-26, 0, 51.9, 32.4)
def test_monitor_coord_to_image_ind_TypeError(self): with self.assertRaises(TypeError): monitor_coord_to_image_ind([0], [0], 51.9, 32.4)