示例#1
0
    def test_reference_filter_for_an_unselected_metric(self):
        reference_filter = ReferenceFilter(self.dataset.fields.unused_metric, ComparisonOperator.gt, 5)
        reference = DayOverDay(self.dataset.fields.timestamp, filters=[reference_filter])

        result_df = apply_reference_filters(self.df, reference)

        pd.testing.assert_frame_equal(result_df, self.df)
示例#2
0
    def test_reference_filter_with_not_equal_to(self):
        reference_filter = ReferenceFilter(self.dataset.fields.metric0, ComparisonOperator.ne, 5)
        reference = DayOverDay(self.dataset.fields.timestamp, filters=[reference_filter])

        result_df = apply_reference_filters(self.df, reference)

        pd.testing.assert_frame_equal(
            result_df.reset_index(drop=True),
            pd.DataFrame.from_dict({"$metric0": [1, 3, 4], "$metric0_dod": [1, 9, 12]}),
        )
示例#3
0
    def test_reference_filter_with_2_filters_combined(self):
        reference_filter_gt = ReferenceFilter(self.dataset.fields.metric0, ComparisonOperator.gt, 3)
        reference_filter_lt = ReferenceFilter(self.dataset.fields.metric0, ComparisonOperator.lt, 10)
        reference = DayOverDay(
            self.dataset.fields.timestamp,
            filters=[reference_filter_gt, reference_filter_lt],
        )

        result_df = apply_reference_filters(self.df, reference)

        pd.testing.assert_frame_equal(
            result_df.reset_index(drop=True),
            pd.DataFrame.from_dict({"$metric0": [2, 3], "$metric0_dod": [5, 9]}),
        )