Exemplo n.º 1
0
 def test__create(self):
     # params
     length = 2
     start = "01-01-2020"
     end = "02-01-2020"
     # object creation
     tsd = TimeSeriesDataset.create(length, start, end)
     # test
     self.assertIsInstance(tsd, TimeSeriesDataset)
     # Test if length is the same as planned
     self.assertEqual(len(tsd), length)
Exemplo n.º 2
0
 def test__create_with_freq_as_time_series(self):
     # params
     length = 3
     start = "01-01-2020"
     end = "02-01-2020"
     freq = TimeSeries.create("01-01-2020", "01-02-2020", "H")
     # object creation
     tsd = TimeSeriesDataset.create(length, start, end, freq)
     # test
     for ts in tsd:
         # if equal, all ts in tsd have an hourly frequency
         self.assertEqual(ts.frequency(), freq.frequency())
Exemplo n.º 3
0
 def test__split_in_chunks(self):
     # params
     n_chunks = 12
     length = 3
     start = "01-01-2020"
     end = "02-01-2020"
     freq = "H"
     # object creation
     tsd = TimeSeriesDataset.create(length, start, end, freq)
     chunkified_tds = tsd.split_in_chunks(n_chunks)
     # test if the number of chunks is the right one
     self.assertEqual(len(chunkified_tds), n_chunks)
     for tsd in chunkified_tds:
         # test if each item is a TimeSeriesDataset
         self.assertIsInstance(tsd, TimeSeriesDataset)
         # test if each item in a TimeSeriesDataset is a TS
         for ts in tsd:
             self.assertIsInstance(ts, TimeSeries)
Exemplo n.º 4
0
 def test__fill(self):
     # params
     length = 3
     start = "01-01-2020"
     end = "02-01-2020"
     freq = "H"
     # object creation
     tsd = TimeSeriesDataset.create(length, start, end, freq)
     # test if every elements are nans
     for ts in tsd:
         for i in ts.series[TIME_SERIES_VALUES]:
             self.assertIs(i, np.nan)
     # fill with zeros
     tsd = tsd.fill(0)
     # test if every elements are zeros
     for ts in tsd:
         for i in ts.series[TIME_SERIES_VALUES]:
             self.assertIs(i, 0)
Exemplo n.º 5
0
    def test__split_at(self):
        # params
        length = 3
        start = "01-01-2020 00:00"
        end = "03-01-2020 00:00"
        freq = "H"
        # object creation
        tsd = TimeSeriesDataset.create(length, start, end, freq)
        # test
        splitting_point = "02-01-2020 00:00"
        tsd1, tsd2 = tsd.split_at(splitting_point)

        # check the first split
        for ts in tsd1:
            self.assertEqual(ts.start(), Timestamp(start))
            self.assertEqual(ts.end(), Timestamp(splitting_point))

        # check the second split
        for ts in tsd2:
            self.assertEqual(ts.start(), Timestamp(splitting_point))
            self.assertEqual(ts.end(), Timestamp(end))