示例#1
0
    def test_no_flatliner(self):
        df = df_no_flatliner
        threshold = 0.25
        expected = None
        result = find_nonzero_flatliner(df, threshold)

        self.assertEqual(result, expected)
    def test_no_flatliner(self):
        df = df_no_flatliner
        suspicious_moments = validation.find_nonzero_flatliner(df, 0.25)

        expected = df
        result = preprocessing.replace_invalid_data(df, suspicious_moments)

        self.assertDataframeEqual(expected, result)
示例#3
0
    def test_flatliner_start_end(self):
        """Data: zero value flatliner for complete station

        Expected: empty list, since the function detects only non-zero station flatliners
        """
        df = df_flatliner_start_end
        threshold = 0.25
        result = find_nonzero_flatliner(df, threshold)
        self.assertEqual(1, len(result))
示例#4
0
    def test_zero_flatliner(self):
        """Data: zero value flatliner for complete station

        Expected: empty list, since the function detects only non-zero station flatliners
        """
        df = df_zero_flatliner
        threshold = 0.25
        expected = None
        result = find_nonzero_flatliner(df, threshold)
        self.assertEqual(result, expected)
示例#5
0
    def test_no_data(self):
        """Data: empty database

        Expected: empty list, since there is no data to check
        """
        df = df_zero_file
        threshold = 0.25
        expected = None
        result = find_nonzero_flatliner(df, threshold)
        self.assertEqual(result, expected)
示例#6
0
    def test_trafo_flatliner(self):
        """Data: only one trafo shows a flatliner

        Expected: empty list, since the function only detects a complete station flatliner (all trafo's)
        """
        df = df_trafo_flatliner
        threshold = 0.25
        expected = None
        result = find_nonzero_flatliner(df, threshold)
        self.assertEqual(result, expected)
    def test_no_data(self):
        """Data: empty database

        Expected: empty list, since there is no data to check
        """
        df = df_zero_file
        suspicious_moments = validation.find_nonzero_flatliner(df, 0.25)
        expected = df
        result = preprocessing.replace_invalid_data(df, suspicious_moments)
        self.assertDataframeEqual(expected, result)
    def test_station_flatliner(self):
        """Data: all trafo's containing non zero-value flatliners

        Expected: list containing all trafo values and timestamps of the
        stationsflatliners + the generates diff_columns to detect the flatliners.
        """
        df = df_flatliner.copy()
        suspicious_moments = validation.find_nonzero_flatliner(df, 0.25)
        # create expected output with diff_columns
        df_flatliner_output = pd.DataFrame({
            "date":
            date_range2,
            "LC_trafo": [0, np.nan, np.nan, np.nan, 0],
            "col1": [8.0, np.nan, np.nan, np.nan, 8.0],
            "col2": [8.0, np.nan, np.nan, np.nan, 8.0],
        })
        df_flatliner_output = df_flatliner_output.set_index("date")
        expected = df_flatliner_output
        result = preprocessing.replace_invalid_data(df, suspicious_moments)
        self.assertDataframeEqual(expected, result)
示例#9
0
    def test_flatliner_zerovalues(self):
        """Data: one trafo showing a non zero-value flatliner, one trafo showing a zero-value flatliner

        Expected: list containing all trafo values and timestamps of the stationsflatliners + the generates diff_columns to detect the flatliners.
        """
        df = df_zerovalues_flatliner
        threshold = 0.25
        # create expected output with diff_columns
        df_zerovalues_flatliner_output = pd.DataFrame({
            "from_time": [now - timedelta(minutes=45)],
            "to_time": [now - timedelta(minutes=0)],
            "duration_h":
            [(now - timedelta(minutes=0)) - (now - timedelta(minutes=45))],
        })
        expected = list()
        expected.append(df_zerovalues_flatliner_output)
        result = find_nonzero_flatliner(df, threshold)
        expected_output = expected[0]
        self.assertDataframeEqual(expected_output,
                                  result,
                                  check_index_type=False,
                                  check_dtype=False)