def add_numpy_implementation(self, wrapped_func, dependencies=None, discard_units=None, compiler_kwds=None):
    '\n        Add a numpy implementation to a `Function`.\n\n        Parameters\n        ----------\n        function : `Function`\n            The function description for which an implementation should be added.\n        wrapped_func : callable\n            The original function (that will be used for the numpy implementation)\n        dependencies : list of `Function`, optional\n            A list of functions this function needs.\n        discard_units : bool, optional\n            See `implementation`.\n        '
    if (discard_units is None):
        discard_units = prefs['codegen.runtime.numpy.discard_units']
    if hasattr(wrapped_func, '_orig_func'):
        orig_func = wrapped_func._orig_func
    else:
        orig_func = wrapped_func
    if discard_units:
        new_globals = dict(orig_func.__globals__)
        for (key, value) in new_globals.items():
            if isinstance(value, Quantity):
                new_globals[key] = np.asarray(value)
        unitless_func = types.FunctionType(orig_func.__code__, new_globals, orig_func.__name__, orig_func.__defaults__, orig_func.__closure__)
        self._implementations['numpy'] = FunctionImplementation(name=None, code=unitless_func, dependencies=dependencies, compiler_kwds=None)
    else:

        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)
        self._implementations['numpy'] = FunctionImplementation(name=None, code=wrapper_function, dependencies=dependencies)
Add a numpy implementation to a `Function`.

Parameters
----------
function : `Function`
    The function description for which an implementation should be added.
wrapped_func : callable
    The original function (that will be used for the numpy implementation)
dependencies : list of `Function`, optional
    A list of functions this function needs.
discard_units : bool, optional
    See `implementation`.
def add_numpy_implementation(self, wrapped_func, dependencies=None, discard_units=None, compiler_kwds=None):
    '\n        Add a numpy implementation to a `Function`.\n\n        Parameters\n        ----------\n        function : `Function`\n            The function description for which an implementation should be added.\n        wrapped_func : callable\n            The original function (that will be used for the numpy implementation)\n        dependencies : list of `Function`, optional\n            A list of functions this function needs.\n        discard_units : bool, optional\n            See `implementation`.\n        '
    if (discard_units is None):
        discard_units = prefs['codegen.runtime.numpy.discard_units']
    if hasattr(wrapped_func, '_orig_func'):
        orig_func = wrapped_func._orig_func
    else:
        orig_func = wrapped_func
    if discard_units:
        new_globals = dict(orig_func.__globals__)
        for (key, value) in new_globals.items():
            if isinstance(value, Quantity):
                new_globals[key] = np.asarray(value)
        unitless_func = types.FunctionType(orig_func.__code__, new_globals, orig_func.__name__, orig_func.__defaults__, orig_func.__closure__)
        self._implementations['numpy'] = FunctionImplementation(name=None, code=unitless_func, dependencies=dependencies, compiler_kwds=None)
    else:

        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)
        self._implementations['numpy'] = FunctionImplementation(name=None, code=wrapper_function, dependencies=dependencies)