code: def add_analyses(cls, source):
          
          if isinstance(source, types.FunctionType):
              _add_single_method(source.__name__, source)
          else:
              if isinstance(source, types.ModuleType):
                  mod = source
              elif isinstance(source, types.StringTypes):
                  import os
                  import imp
                  path = os.path.abspath(source)
                  if os.path.isfile(path) and path[-3:] == '.py':
                      dir, file = os.path.split(path)
                      name = file[:-3]
                      module_info = imp.find_module(name, [dir])
                      mod = imp.load_module('nsim.' + name, *module_info)
                  elif (os.path.isdir(path) and 
                          '__init__.py' in os.listdir(path)):
                      module_info = imp.find_module('__init__', [path])
                      name = os.path.basename(path)
                      mod = imp.load_module('nsim.' + name, *module_info)
                  else:
                      raise Error('"%s" is not a file or directory' % source)
              else:
                  raise ValueError('`source` argument not a function or module')
              for name, obj in mod.__dict__.items():
                  if name[0] != '_' and isinstance(obj, types.FunctionType):
                      cls._add_single_method(name, obj)
docs: Dynamically add new analysis methods to the Timeseries class.
          Args:
            source: Can be a function, module or the filename of a python file.
              If a filename or a module is given, then all functions defined 
              inside not starting with _ will be added as methods.
  
          The only restriction on the functions is that they can accept a 
          Timeseries as their first argument. So existing functions that 
          take a ndarray or array or even a list will usually also work.