Question: I feel like I have a pretty good grasp on using decorators when dealing with regular functions, but between using methods of base classes for decorators in derived classes, and passing parameters to said decorators, I cannot figure out what to do next.
Here is a snippet of code.

```

class ValidatedObject:
    ...

    def apply_validation(self, field_name, code):
        def wrap(self, f):
            self._validations.append(Validation(field_name, code, f))
            return f
        return wrap

class test(ValidatedObject):
    ....
    @apply_validation("_name", "oh no!")
    def name_validation(self, name):
        return name == "jacob"

```

If I try this as is, I get an "apply\_validation" is not found.  

If I try it with `@self.apply_validation` I get a "self" isn't found.  

I've also been messing around with making `apply_validation` a class method without success. 

Would someone please explain what I'm doing wrong, and the best way to fix this? Thank you.

Answer: 
In case someone stumbled on this later.

To extract the data you can use regex, while for the custom median filter you can have a look [here](https://gist.github.com/bhawkins/3535131).
I will leave a copy down here in case it is removed:

```
def medfilt (x, k):
    """Apply a length-k median filter to a 1D array x.
    Boundaries are extended by repeating endpoints.
    """
    assert k % 2 == 1, "Median filter length must be odd."
    assert x.ndim == 1, "Input must be one-dimensional."
    k2 = (k - 1) // 2
    y = np.zeros ((len (x), k), dtype=x.dtype)
    y[:,k2] = x
    for i in range (k2):
        j = k2 - i
        y[j:,i] = x[:-j]
        y[:j,i] = x[0]
        y[:-j,-(i+1)] = x[j:]
        y[-j:,-(i+1)] = x[-1]
    return np.median (y, axis=1)

```
*scipy.signal.medfilt* accepts 1D kernels:

```
import pandas as pd
import scipy.signal

def median_filter(file_name, new_file_name, kernel_size):
    with open(file_name, 'r') as f:
        df = pd.read_csv(f, header=None)

    signal = df.iloc[:, 1].values
    median = scipy.signal.medfilt(signal, kernel_size)

    df = df.drop(df.columns[1], 1)
    df[1] = median
    df.to_csv(new_file_name, sep=',', index=None, header=None)

if __name__=='__main__':
    median_filter('old_signal.csv', 'new_signal.csv',  23)

```