def applySampler(x_old, y_old, sampDict, df_old=None):
    param = np.asarray(sampDict['param']).ravel()
    if (sampDict['name'] == 'Replace'):
        if (len(param) == 0):
            raise Exception('Error: At least one value is required to resample the x values with')
        x_new = param
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Insert'):
        if (len(param) == 0):
            raise Exception('Error: provide a list of values to insert')
        x_new = np.sort(np.concatenate((x_old.ravel(), param)))
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Remove'):
        I = []
        if (len(param) == 0):
            raise Exception('Error: provide a list of values to remove')
        for d in param:
            Ifound = np.where((np.abs((x_old - d)) < 0.001))[0]
            if (len(Ifound) > 0):
                I += list(Ifound.ravel())
        x_new = np.delete(x_old, I)
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Delta x'):
        if (len(param) == 0):
            raise Exception('Error: provide value for dx')
        dx = param[0]
        x_new = np.arange(x_old[0], (x_old[(- 1)] + (dx / 2)), dx)
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Every n'):
        if (len(param) == 0):
            raise Exception('Error: provide value for n')
        n = int(param[0])
        if (n == 0):
            raise Exception('Error: |n| should be at least 1')
        x_new = x_old[::n]
        if (df_old is not None):
            return (x_new, df_old.copy().iloc[::n, :])
        if (y_old is not None):
            return (x_new, y_old[::n])
    else:
        raise NotImplementedError('{}'.format(sampDict))
    pass
def applySampler(x_old, y_old, sampDict, df_old=None):
    param = np.asarray(sampDict['param']).ravel()
    if (sampDict['name'] == 'Replace'):
        if (len(param) == 0):
            raise Exception('Error: At least one value is required to resample the x values with')
        x_new = param
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Insert'):
        if (len(param) == 0):
            raise Exception('Error: provide a list of values to insert')
        x_new = np.sort(np.concatenate((x_old.ravel(), param)))
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Remove'):
        I = []
        if (len(param) == 0):
            raise Exception('Error: provide a list of values to remove')
        for d in param:
            Ifound = np.where((np.abs((x_old - d)) < 0.001))[0]
            if (len(Ifound) > 0):
                I += list(Ifound.ravel())
        x_new = np.delete(x_old, I)
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Delta x'):
        if (len(param) == 0):
            raise Exception('Error: provide value for dx')
        dx = param[0]
        x_new = np.arange(x_old[0], (x_old[(- 1)] + (dx / 2)), dx)
        return resample_interp(x_old, x_new, y_old, df_old)
    elif (sampDict['name'] == 'Every n'):
        if (len(param) == 0):
            raise Exception('Error: provide value for n')
        n = int(param[0])
        if (n == 0):
            raise Exception('Error: |n| should be at least 1')
        x_new = x_old[::n]
        if (df_old is not None):
            return (x_new, df_old.copy().iloc[::n, :])
        if (y_old is not None):
            return (x_new, y_old[::n])
    else:
        raise NotImplementedError('{}'.format(sampDict))
    pass