Пример #1
0
    def test_interpolateEmptyTS(self):
        '''
		Checks that an Error is raised if try to interpolate based on an empty ArrayTimeSeries
		'''
        ts = ArrayTimeSeries([], [])
        with self.assertRaises(AssertionError):
            ts.interpolate([1])
Пример #2
0
    def test_interpolateNumeric(self):
        '''
		Checks that an Error is raised if the time sequence input for interpolation contains non numeric elements
		'''
        test_times = [1, 2, 3, 4, 5]
        test_values = [1, 2, 3, 4, 5]
        ts = ArrayTimeSeries(test_times, test_values)
        with self.assertRaises(AssertionError):
            ts.interpolate(list('abcd'))
Пример #3
0
    def test_interpolateBoundaryCondition(self):
        '''
		Verify if a new time point is smaller than the first time point in the existing time series, the interpolate function outputs the first value; likewise for larger time points.
		'''
        test_times = [1, 3]
        test_values = [3, 9]
        ts = ArrayTimeSeries(test_times, test_values)
        self.assertEqual(ts.interpolate([3, 5]), [9, 9])
Пример #4
0
    def test_interpolateInBound(self):
        '''
		Test the interpolate function for a new time input within the boundary of the existing time sequence
		'''
        test_times = [1, 2]
        test_values = [3, 6]
        ts = ArrayTimeSeries(test_times, test_values)
        self.assertEqual(ts.interpolate([1.5]), [4.5])
Пример #5
0
    def test_interpolateEmptyInput(self):
        '''
		Checks that an Error is raised if try to interpolate based on an empty ArrayTimeSeries
		'''
        ts = ArrayTimeSeries([1], [2])
        self.assertEqual(ts.interpolate([]), [])