Beispiel #1
0
 def test_butterFilter_exceptions(self, data, cutoff, Fs):
     """
     We test exceptions raised when the length of the input data is too short, 
     when the cutoff frequency value is negative, zero, or too large, 
     and when the sampling frequency value is negative, zero, or too small.
     """
     with pytest.raises(Exception):
         Pipelines.butterFilter(data, cutoff, Fs)
Beispiel #2
0
    def test_butterFilter_accuracy(self, data, cutoff, Fs, expected_result):
        """
        This function tests Pipelines.butterFilter(data, cutoff, Fs),
        where data is an array of numbers to filter, cutoff is the cutoff
        frequency to filter, and Fs is the sampling frequency of the data.

        Pipelines.butterFilter applies a fourth-order low-pass Butterworth filter
        that is constructed using the scipy functions butter() and filtfilt().

        For each case, we test that the Butterworth filter is applied correctly
        by testing its output is accurate in cases where inputs are positive and negative 
        floats and integers. We test cases where inputs are lists and numpy arrays.
        """
        #Call butterFilter() with parametrized values
        result = Pipelines.butterFilter(data, cutoff, Fs)
        np.testing.assert_almost_equal(result, expected_result, self.rounding_precision)