예제 #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([]), [])