def wrapper_function(*args):
    arg_units = list(self._function._arg_units)
    if self._function.auto_vectorise:
        arg_units += [DIMENSIONLESS]
    if (not (len(args) == len(arg_units))):
        raise ValueError(('Function %s got %d arguments, expected %d' % (self._function.pyfunc.__name__, len(args), len(arg_units))))
    new_args = []
    for (arg, arg_unit) in zip(args, arg_units):
        if ((arg_unit == bool) or (arg_unit is None) or isinstance(arg_unit, str)):
            new_args.append(arg)
        else:
            new_args.append(Quantity.with_dimensions(arg, get_dimensions(arg_unit)))
    result = orig_func(*new_args)
    if isinstance(self._function._return_unit, Callable):
        return_unit = self._function._return_unit(*[get_dimensions(a) for a in args])
    else:
        return_unit = self._function._return_unit
    if (return_unit == bool):
        if (not (isinstance(result, bool) or (np.asarray(result).dtype == bool))):
            raise TypeError(('The function %s returned %s, but it was expected to return a boolean value ' % (orig_func.__name__, result)))
    elif ((isinstance(return_unit, int) and (return_unit == 1)) or (return_unit.dim is DIMENSIONLESS)):
        fail_for_dimension_mismatch(result, return_unit, ('The function %s returned {value}, but it was expected to return a dimensionless quantity' % orig_func.__name__), value=result)
    else:
        fail_for_dimension_mismatch(result, return_unit, ('The function %s returned {value}, but it was expected to return a quantity with units %r' % (orig_func.__name__, return_unit)), value=result)
    return np.asarray(result)
def wrapper_function(*args):
    arg_units = list(self._function._arg_units)
    if self._function.auto_vectorise:
        arg_units += [DIMENSIONLESS]
    if (not (len(args) == len(arg_units))):
        raise ValueError(('Function %s got %d arguments, expected %d' % (self._function.pyfunc.__name__, len(args), len(arg_units))))
    new_args = []
    for (arg, arg_unit) in zip(args, arg_units):
        if ((arg_unit == bool) or (arg_unit is None) or isinstance(arg_unit, str)):
            new_args.append(arg)
        else:
            new_args.append(Quantity.with_dimensions(arg, get_dimensions(arg_unit)))
    result = orig_func(*new_args)
    if isinstance(self._function._return_unit, Callable):
        return_unit = self._function._return_unit(*[get_dimensions(a) for a in args])
    else:
        return_unit = self._function._return_unit
    if (return_unit == bool):
        if (not (isinstance(result, bool) or (np.asarray(result).dtype == bool))):
            raise TypeError(('The function %s returned %s, but it was expected to return a boolean value ' % (orig_func.__name__, result)))
    elif ((isinstance(return_unit, int) and (return_unit == 1)) or (return_unit.dim is DIMENSIONLESS)):
        fail_for_dimension_mismatch(result, return_unit, ('The function %s returned {value}, but it was expected to return a dimensionless quantity' % orig_func.__name__), value=result)
    else:
        fail_for_dimension_mismatch(result, return_unit, ('The function %s returned {value}, but it was expected to return a quantity with units %r' % (orig_func.__name__, return_unit)), value=result)
    return np.asarray(result)