예제 #1
0
    def test_cut_y_single(self):
        """
        Compute the nominal cut-Y of 1 timeseries.
        """

        # Matching condition
        condition = "1<Y<=8.009"

        # Expected TS
        expected_ts_list_matching = [[
            [1e12, 5.0],
            [1e12 + 1000, 6.2],
            [1e12 + 3000, 8.0],
            [1e12 + 5000, 2.0],
            [1e12 + 6000, 6.0],
            [1e12 + 7000, 3.0],
            [1e12 + 8000, 2.0],
            [1e12 + 10000, 8.0],
            [1e12 + 11000, 8.0],
            [1e12 + 12000, 8.0],
            [1e12 + 13000, 8.0]
        ]]

        expected_ts_list_not_matching = [[
            [1e12 + 2000, 1.0],
            [1e12 + 4000, -15.0],
            [1e12 + 9000, 42.0]
        ]]

        fid_pattern = "TEST_{fid}_cutY{compl}"

        input_ts_list = None
        obtained_ts_list_matching = None
        obtained_ts_list_not_matching = None

        try:
            # Prepare list of TS
            input_ts_list = [gen_ts(1)]

            # Cleanup former results
            self._cleanup_former_results(fid_pattern=fid_pattern, input_ts_list=input_ts_list)

            # Call the algorithm
            obtained_ts_list_matching, obtained_ts_list_not_matching = cut_y(original_ts_list=input_ts_list,
                                                                             criterion=condition,
                                                                             fid_pattern=fid_pattern)

            # Check content
            self._check_cut_y_results(expect_matching=expected_ts_list_matching,
                                      expect_not_matching=expected_ts_list_not_matching,
                                      obtained_matching=obtained_ts_list_matching,
                                      obtained_not_matching=obtained_ts_list_not_matching)

        finally:

            # Cleanup results
            self._cleanup_results(input_ts_list=input_ts_list,
                                  obtained_match=obtained_ts_list_matching,
                                  obtained_no_match=obtained_ts_list_not_matching)
예제 #2
0
    def test_cut_y_no_ts(self):
        """
        Robustness when no TS are provided (empty TS list).
        """

        # Matching condition
        condition = "True"

        fid_pattern = "TEST_{fid}_cutY{compl}"

        # Prepare list of TS
        input_ts_list = []

        # ValueError indicates the number of items in ts_list shall be >0
        with self.assertRaises(ValueError):
            # Call the algorithm
            cut_y(original_ts_list=input_ts_list,
                  criterion=condition,
                  fid_pattern=fid_pattern)
예제 #3
0
    def test_cut_y_inherit(self):
        """
        Check the created TS inherit from the original one.
        """

        # Matching condition
        condition = "1<Y<=8.009"

        fid_pattern = "TEST_{fid}_cutY{compl}"

        input_ts_list = None
        obtained_ts_list_matching = None
        obtained_ts_list_not_matching = None

        try:
            # Prepare list of TS
            input_ts_list = [gen_ts(1), gen_ts(2)]

            for item in input_ts_list:
                IkatsApi.md.create(item['tsuid'], "MyMetaToKeep", "hello")

            # Cleanup former results
            self._cleanup_former_results(fid_pattern=fid_pattern, input_ts_list=input_ts_list)

            # Call the algorithm
            obtained_ts_list_matching, obtained_ts_list_not_matching = cut_y(original_ts_list=input_ts_list,
                                                                             criterion=condition,
                                                                             fid_pattern=fid_pattern)

            # Check metadata inheritance
            md_to_check = IkatsApi.md.read([x['tsuid'] for x in obtained_ts_list_matching])
            for _, item in enumerate(obtained_ts_list_matching):
                self.assertFalse("MyMetaToKeep" not in md_to_check[item['tsuid']])
            md_to_check = IkatsApi.md.read([x['tsuid'] for x in obtained_ts_list_not_matching])
            for _, item in enumerate(obtained_ts_list_not_matching):
                self.assertFalse("MyMetaToKeep" not in md_to_check[item['tsuid']])

        finally:

            # Cleanup results
            self._cleanup_results(input_ts_list=input_ts_list,
                                  obtained_match=obtained_ts_list_matching,
                                  obtained_no_match=obtained_ts_list_not_matching)