def constraint_wrapper(fun, constraint):
    """
    Wrap a function such that it's first argument is constrained 
    """
    def inner(x, *args, **kwargs):
        """the wrapped function"""
        return fun(constraint(x), *args, **kwargs)

    return inner