'Reload an IPython extension by calling reload.
If the module has not been loaded before,
:meth:`InteractiveShell.load_extension` is called. Otherwise
:func:`reload` is called and then the :func:`load_ipython_extension`
function of the module, if it exists is called.'

def reload_extension(self, module_str):

    from IPython.utils.syspathcontext import prepended_to_syspath
    if ((module_str in self.loaded) and (module_str in sys.modules)):
        self.unload_extension(module_str)
        mod = sys.modules[module_str]
        with prepended_to_syspath(self.ipython_extension_dir):
            reload(mod)
        if self._call_load_ipython_extension(mod):
            self.loaded.add(module_str)
    else:
        self.load_extension(module_str)
