def test_deterministic_settings(self) -> None: # test basic business_hour / non_business_hour calculation # test we get an array of the right length with frequency=CountStat.DAY data = generate_time_series_data(days=7, business_hours_base=20, non_business_hours_base=15, spikiness=0) self.assertEqual(data, [400, 400, 400, 400, 400, 360, 360]) data = generate_time_series_data( days=1, business_hours_base=2000, non_business_hours_base=1500, growth=2, spikiness=0, frequency=CountStat.HOUR, ) # test we get an array of the right length with frequency=CountStat.HOUR self.assert_length(data, 24) # test that growth doesn't affect the first data point self.assertEqual(data[0], 2000) # test that the last data point is growth times what it otherwise would be self.assertEqual(data[-1], 1500 * 2) # test autocorrelation == 1, since that's the easiest value to test data = generate_time_series_data( days=1, business_hours_base=2000, non_business_hours_base=2000, autocorrelation=1, frequency=CountStat.HOUR, ) self.assertEqual(data[0], data[1]) self.assertEqual(data[0], data[-1])
def generate_fixture_data(self, stat: CountStat, business_hours_base: float, non_business_hours_base: float, growth: float, autocorrelation: float, spikiness: float, holiday_rate: float=0, partial_sum: bool=False) -> List[int]: self.random_seed += 1 return generate_time_series_data( days=self.DAYS_OF_DATA, business_hours_base=business_hours_base, non_business_hours_base=non_business_hours_base, growth=growth, autocorrelation=autocorrelation, spikiness=spikiness, holiday_rate=holiday_rate, frequency=stat.frequency, partial_sum=partial_sum, random_seed=self.random_seed)
def generate_fixture_data(self, stat, business_hours_base, non_business_hours_base, growth, autocorrelation, spikiness, holiday_rate=0): # type: (CountStat, float, float, float, float, float, float) -> List[int] self.random_seed += 1 return generate_time_series_data( days=self.DAYS_OF_DATA, business_hours_base=business_hours_base, non_business_hours_base=non_business_hours_base, growth=growth, autocorrelation=autocorrelation, spikiness=spikiness, holiday_rate=holiday_rate, frequency=stat.frequency, is_gauge=(stat.interval == CountStat.GAUGE), random_seed=self.random_seed)
def test_deterministic_settings(self) -> None: # test basic business_hour / non_business_hour calculation # test we get an array of the right length with frequency=CountStat.DAY data = generate_time_series_data( days=7, business_hours_base=20, non_business_hours_base=15, spikiness=0) self.assertEqual(data, [400, 400, 400, 400, 400, 360, 360]) data = generate_time_series_data( days=1, business_hours_base=2000, non_business_hours_base=1500, growth=2, spikiness=0, frequency=CountStat.HOUR) # test we get an array of the right length with frequency=CountStat.HOUR self.assertEqual(len(data), 24) # test that growth doesn't affect the first data point self.assertEqual(data[0], 2000) # test that the last data point is growth times what it otherwise would be self.assertEqual(data[-1], 1500*2) # test autocorrelation == 1, since that's the easiest value to test data = generate_time_series_data( days=1, business_hours_base=2000, non_business_hours_base=2000, autocorrelation=1, frequency=CountStat.HOUR) self.assertEqual(data[0], data[1]) self.assertEqual(data[0], data[-1])