def test_append__two_elements__correct_size(self): self.data.append(Gaze()) self.data.append(Gaze()) self.assertEqual(2, len(self.data.gaze_x)) self.assertEqual(2, len(self.data.gaze_y)) self.assertEqual(2, len(self.data.on_surface))
def test_to_numpy_array__two_elements__size_correct(self): self.data.append(Gaze()) self.data.append(Gaze()) result = self.data.to_numpy_array() self.assertEqual((2, 3), result.shape)
def test_clear__empty_buffer_and_correct_gaze(self): self.gaze_buffer.push_array([Gaze(), self.test_gaze]) self.gaze_buffer.clear() self.assertFalse(self.gaze_buffer.data) self.assert_gaze_equal()
def create_gaze_pixel_data_from_message(self, message_name): gaze_array = GazeArray() for data_point in self.__message[message_name]: msg = Gaze() msg.surface_name = self.__surface_name msg.on_surface = data_point[b"on_surf"] msg.confidence = data_point[b"confidence"] # Create Point for message with normalized data point_gaze_norm = Point() point_gaze_norm.x = data_point[b"norm_pos"][0] point_gaze_norm.y = data_point[b"norm_pos"][1] msg.gaze_norm = point_gaze_norm # Create Point for message with data in pixels msg.gaze_pixel = geometry.norm_to_pixel(point_gaze_norm, self.__screen_resolution_x, self.__screen_resolution_y) gaze_array.gazes.append(msg) return gaze_array
def create_gaze(x_pos, y_pos): """Create gaze data with predefined positions""" return Gaze(gaze_pixel=Point(x=x_pos, y=y_pos))
def test_push_array__two_elements__len_is_2_and_correct_gaze(self): self.gaze_buffer.push_array([Gaze(), self.test_gaze]) self.assertEqual(2, len(self.gaze_buffer.data)) self.assert_gaze_equal()