def test_keyadd(self):
        data = TestGazelibMethods.data

        # adding keys
        data2 = gazelib.add_key(data, 'z', len(data)*[-1])
        self.assertEqual(gazelib.get_value(data2, 4, 'z'), -1)

        # adding insuffisiently long vector of values produces error
        with self.assertRaises(IndexError):
            gazelib.add_key(data, 'z', [1,2,3])


        # metrics calculations
        self.assertEqual(gazelib.duration(data, 'time'), 5)
        self.assertEqual(gazelib.longest_non_valid_streak(data, 'yval', 'time', [0,1]), 2)
    def test_filter_and_interpolation(self):
        data = TestGazelibMethods.data

        # median filter (for vector)
        filtered = gazelib.median_filter(gazelib.get_key(data, 'x'), 3)
        correct_filtered = [0.1, 0.4, 0.4, 0.4, 0.1, 0.1]
        self.assertListEqual(filtered, correct_filtered)
        #print(gazelib.get_key(data, 'x'))
        gazelib.add_key(data, 'x', correct_filtered)
        #print(gazelib.get_key(data, 'x'))
        self.assertListEqual(gazelib.median_filter_data(data, 3, 'x'),
                             gazelib.add_key(data, 'x', correct_filtered))

        # interpolation
        self.assertListEqual(gazelib.get_key(
            gazelib.interpolate_using_last_good_value(data, 'x', 'xval', [1,0]), 'x'),
            [0.1, 0.4, 0.4, 0.8, 0.8, 0.1])