Beispiel #1
0
 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))
Beispiel #2
0
 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))
Beispiel #3
0
 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))
Beispiel #4
0
 def side_effect(*args, **kwargs):
     startTime, endTime = args
     result_start = max(startTime, start)
     result_end = min(endTime, end)
     points = (result_end - result_start) // step
     return TimeSeriesData(result_start, result_end, step,
                           [float(x) for x in range(points)])
Beispiel #5
0
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))
Beispiel #6
0
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))
Beispiel #7
0
 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))
Beispiel #8
0
 def setUp(self):
     self.time_series = TimeSeriesData(0, 50, 5,
                                       [float(x) for x in range(0, 10)])
Beispiel #9
0
 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))
Beispiel #10
0
 def setUp(self):
   self.time_series = TimeSeriesData(0, 50, 5, [float(x) for x in range(0, 10)])
Beispiel #11
0
 def side_effect(*args, **kwargs):
   startTime, endTime = args
   result_start = max(startTime, start)
   result_end = min(endTime, end)
   points = (result_end - result_start) / step
   return TimeSeriesData(result_start, result_end, step, [0] * points)