Exemple #1
0
    def test_apply_to_timeseries(self):
        rolling_mean = RollingMean(mock_dataset.fields.wins, 3)
        result = rolling_mean.apply(dimx1_date_df, None)

        expected = pd.Series([nan, nan, 2.0, 2.0, 2.0, 2.0],
                             name='$wins',
                             index=dimx1_date_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #2
0
    def test_apply_to_timeseries_with_uni_dim_and_ref(self):
        rolling_mean = RollingMean(mock_dataset.fields.wins, 3)
        result = rolling_mean.apply(dimx2_date_str_ref_df, ElectionOverElection(mock_dataset.fields.timestamp))

        expected = pd.Series([nan, nan, nan, nan, 4 / 3, 0., 4 / 3, 2 / 3, 4 / 3, 4 / 3, 2 / 3],
                             name='$wins_eoe',
                             index=dimx2_date_str_ref_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #3
0
    def test_apply_to_timeseries_with_uni_dim_and_ref(self):
        rolling_mean = RollingMean(slicer.metrics.wins, 3)
        result = rolling_mean.apply(cont_uni_dim_ref_df, ElectionOverElection(slicer.dimensions.timestamp))

        expected = pd.Series([np.nan, np.nan, np.nan, np.nan, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
                             name='$m$wins_eoe',
                             index=cont_uni_dim_ref_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #4
0
    def test_apply_to_timeseries_with_uni_dim(self):
        rolling_mean = RollingMean(slicer.metrics.wins, 3)
        result = rolling_mean.apply(cont_uni_dim_df, None)

        expected = pd.Series([np.nan, np.nan, np.nan, np.nan, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
                             name='$m$wins',
                             index=cont_uni_dim_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #5
0
    def test_apply_to_timeseries(self):
        rolling_mean = RollingMean(slicer.metrics.wins, 3)
        result = rolling_mean.apply(cont_dim_df, None)

        expected = pd.Series([np.nan, np.nan, 2.0, 2.0, 2.0, 2.0],
                             name='$m$wins',
                             index=cont_dim_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #6
0
    def test_apply_to_timeseries_with_uni_dim_and_ref(self):
        rolling_mean = RollingMean(slicer.metrics.wins, 3)
        result = rolling_mean.apply(
            cont_uni_dim_ref_df,
            ElectionOverElection(slicer.dimensions.timestamp))

        expected = pd.Series(
            [np.nan, np.nan, np.nan, np.nan, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            name='$m$wins_eoe',
            index=cont_uni_dim_ref_df.index)
        pandas.testing.assert_series_equal(expected, result)
Exemple #7
0
    def test_apply_to_timeseries_with_uni_dim(self):
        rolling_mean = RollingMean(mock_dataset.fields.wins, 3)
        result = rolling_mean.apply(dimx2_date_str_df, None)

        expected = pd.Series(
            [
                nan, nan, nan, nan, nan, 2 / 3, 4 / 3, 2 / 3, 4 / 3, 4 / 3,
                2 / 3, 4 / 3, 2 / 3
            ],
            name='$wins',
            index=dimx2_date_str_df.index,
        )
        pandas.testing.assert_series_equal(expected, result)