def test_merge_with_holes(self): values = [] for x in range(0, 10): if x % 2 == 0: values.append(x) else: values.append(None) new_series = TimeSeriesData(0, 50, 5, values) new_series.merge(self.time_series) self.assertEqual(list(self.time_series), list(new_series))
class TimeSeriesDataTest(TestCase): def setUp(self): self.time_series = TimeSeriesData(0, 50, 5, [float(x) for x in range(0, 10)]) def test_timestamps_property(self): self.assertEqual(10, len(self.time_series.timestamps)) self.assertEqual(0, self.time_series.timestamps[0]) self.assertEqual(45, self.time_series.timestamps[-1]) def test_iter_values(self): values = list(self.time_series) self.assertEqual(10, len(values)) self.assertEqual((0, 0.0), values[0]) self.assertEqual((45, 9.0), values[-1]) def test_merge_no_missing(self): # merge only has effect if time series has no gaps other_series = TimeSeriesData(0, 25, 5, [float(x * x) for x in range(1, 6)]) original_values = list(self.time_series) self.time_series.merge(other_series) self.assertEqual(original_values, list(self.time_series)) def test_merge_with_empty(self): new_series = TimeSeriesData(0, 50, 5, [None] * 10) new_series.merge(self.time_series) self.assertEqual(list(self.time_series), list(new_series)) def test_merge_with_holes(self): values = [] for x in range(0, 10): if x % 2 == 0: values.append(x) else: values.append(None) new_series = TimeSeriesData(0, 50, 5, values) new_series.merge(self.time_series) self.assertEqual(list(self.time_series), list(new_series))
def test_merge_with_empty(self): new_series = TimeSeriesData(0, 50, 5, [None] * 10) new_series.merge(self.time_series) self.assertEqual(list(self.time_series), list(new_series))