Exemple #1
0
 def test_get_on_slice_out_of_bounds_left_side(self, smallts):
     start = CURRENT - 2 * ONEHOUR
     end = CURRENT
     data = {CURRENT: 0}
     sliced_ts = smallts[start:end + 1 * ONEHOUR]
     expected_ts = TimeSeries(data, default=smallts.default)
     testing.assert_ts_equal(sliced_ts, expected_ts)
Exemple #2
0
 def test_sample_out_of_left_bound_with_no_default_permissive_shorten_interval(
         self, smallts):
     ts = smallts.sample(freq=HALFHOUR,
                         start=CURRENT - ONEHOUR,
                         end=CURRENT + ONEHOUR)
     expected_ts = TimeSeries({CURRENT: 0, CURRENT + HALFHOUR: 0})
     testing.assert_ts_equal(expected_ts, ts)
Exemple #3
0
 def test_simple_sample_on_default(self, smallts):
     ts = smallts.sample(HALFHOUR)
     expected_dict = {
         **smallts.data,
         **{key + HALFHOUR: smallts[key]
            for key in smallts.index[:-1]}
     }
     expected_ts = TimeSeries(expected_dict, default=smallts.default)
     testing.assert_ts_equal(expected_ts, ts)
Exemple #4
0
    def test_get_on_slice_add_back_previous_value_if_start_not_in_keys(
            self, smallts):
        start = CURRENT + HALFHOUR
        end = CURRENT + ONEHOUR
        sliced_ts = smallts[start:end + ONEHOUR]

        data = {start: 0, end: 1}
        expected_ts = TimeSeries(data, default=smallts.default)
        testing.assert_ts_equal(sliced_ts, expected_ts)
Exemple #5
0
    def test_same_consecutive_set_interval(self, smallts_withdefault, start,
                                           end):
        smallts_withdefault.set_interval(start, end, 1000)
        first_time = deepcopy(smallts_withdefault)

        for _ in range(10):
            smallts_withdefault.set_interval(start, end, 1000)

        testing.assert_ts_equal(first_time, smallts_withdefault)
Exemple #6
0
    def test_get_on_slice_exclude_upper_bound_include_lower_bound(
            self, smallts):
        start = CURRENT
        end = CURRENT + 1 * ONEHOUR
        sliced_ts = smallts[start:end + ONEHOUR]

        data = {start: 0, end: 1}
        expected_ts = TimeSeries(data, default=smallts.default)
        testing.assert_ts_equal(sliced_ts, expected_ts)
Exemple #7
0
 def test_get_on_slice_entirely_out_of_bounds_on_right_side(self, smallts):
     start = CURRENT + 10 * ONEHOUR
     end = CURRENT + 12 * ONEHOUR
     sliced_ts = smallts[start:end]
     expected_ts = TimeSeries({start: smallts[start]})
     testing.assert_ts_equal(sliced_ts, expected_ts)
Exemple #8
0
def test_from_series_to_ticst(smallts):
    serie = smallts.to_dataframe()['value']
    returned = serie.to_ticts()
    testing.assert_ts_equal(smallts, returned)
Exemple #9
0
def test_from_df_to_ticst(smallts):
    df = smallts.to_dataframe()
    returned = df.to_ticts()
    testing.assert_ts_equal(smallts, returned)
Exemple #10
0
 def test_it_returns_timeseries_from_json(self, smallts, tmpdir):
     path = tmpdir.join('test.json')
     smallts.to_json(path)
     ts_read = TimeSeries.from_json(path)
     testing.assert_ts_equal(smallts, ts_read)
Exemple #11
0
 def test_consecutive_setitem(self, smallts):
     smallts[CURRENT] = 1000
     first_time = TimeSeries(smallts)
     smallts[CURRENT] = 1000
     testing.assert_ts_equal(first_time, smallts)
Exemple #12
0
 def test_with_data_as_ticts_timeserie_and_name_given(self, smallts):
     smallts.default = 1000
     smallts.name = 'SomeName'
     newts = TimeSeries(smallts, name='SomeOtherName')
     testing.assert_ts_equal(smallts, newts, check_name=False)
     assert newts.name == 'SomeOtherName'
Exemple #13
0
 def test_with_data_as_ticts_timeserie(self, smallts):
     smallts.default = 1000
     smallts.name = 'SomeName'
     testing.assert_ts_equal(smallts, TimeSeries(smallts))
Exemple #14
0
 def test_mask_update_on_emptyts(self, smallts, emptyts, maskts):
     emptyts.mask_update(smallts, maskts)
     expected_ts = TimeSeries({CURRENT + 3 * ONEHOUR: 3})
     testing.assert_ts_equal(emptyts, expected_ts)
Exemple #15
0
 def test_simple_sample_with_start_being_string(self, smallts):
     start = '2019-01-01T09:00:00'
     ts = smallts.sample(HALFHOUR, start=start)
     expected_ts = TimeSeries({start: 9})
     testing.assert_ts_equal(expected_ts, ts)
Exemple #16
0
 def test_copy(self, smallts):
     copied = copy(smallts)
     testing.assert_ts_equal(copied, smallts)
Exemple #17
0
 def test_deepcopy_with_default(self, smallts_withdefault):
     deepcopied = deepcopy(smallts_withdefault)
     testing.assert_ts_equal(deepcopied, smallts_withdefault)
Exemple #18
0
 def test_deepcopy(self, smallts):
     deepcopied = deepcopy(smallts)
     testing.assert_ts_equal(deepcopied, smallts)
Exemple #19
0
 def test_copy_with_default(self, smallts_withdefault):
     copied = copy(smallts_withdefault)
     testing.assert_ts_equal(copied, smallts_withdefault)
Exemple #20
0
 def test_get_on_slice_out_of_bounds_on_right_side(self, smallts):
     sliced_ts = smallts[CURRENT + 9 * ONEHOUR:CURRENT + 12 * ONEHOUR]
     expected_dct = {CURRENT + 9 * ONEHOUR: 9}
     expected_ts = TimeSeries(expected_dct, default=smallts.default)
     testing.assert_ts_equal(sliced_ts, expected_ts)
Exemple #21
0
 def test_simple_add(self, smallts, smalldict):
     ts = smallts + smallts
     newdct = {key: value + value for key, value in smalldict.items()}
     expected_ts = TimeSeries(newdct)
     testing.assert_ts_equal(ts, expected_ts)