示例#1
0
def setup(obj):
    """
    Describes a spotpy setup using its class name, docstring and parameters
    :param obj: A spotpy compatible model setup
    :return: A describing string
    """

    # Get class name
    s = unicode(type(obj).__name__)

    # Add doc string
    mdoc = _getdoc(obj)

    s += mdoc + '\n'

    # Get parameters from class

    params = '\n'.join(' - {p}'.format(p=p)
                       for p in get_parameters_from_setup(obj))

    # Add parameters to string
    s += '\n'
    s += 'Parameters:\n{params}'.format(params=params)

    return s
示例#2
0
def sampler(obj):
    """
    Returns a string representation of the sampler.
    By design, it is rather verbose and returns a
    large multiline description
    :return:
    """
    s = unicode(type(obj).__name__)
    s += _getdoc(obj) + '\n'
    s += u'\n    db format: ' + obj.dbformat
    s += u'\n    db name: ' + obj.dbname
    s += u'\n    save simulation: ' + str(obj.save_sim)
    s += u'\n    parallel: ' + type(obj.repeat).__module__.split('.')[-1]
    return s
def setup(obj):
    """
    Describes a spotpy setup using its class name, docstring and parameters
    :param obj: A spotpy compatible model setup
    :return: A describing string
    """
    # Get class name
    cname = unicode(type(obj).__name__)
    # Add doc string
    mdoc = _getdoc(obj).strip('\n').replace('\r', '\n')
    # Get parameters from class
    params = '\n'.join(' - {p}'.format(p=unicode(p)) for p in get_parameters_from_setup(obj))
    parts = [cname, '=' * len(cname), mdoc, 'Parameters:', '-' * 11, params]
    return '\n'.join(parts)
def sampler(obj):
    """
    Returns a string representation of the sampler.
    By design, it is rather verbose and returns a
    large multiline description
    :return:
    """
    cname = unicode(type(obj).__name__)
    s = [cname, '=' * len(cname), _getdoc(obj),
         '    db format: ' + obj.dbformat,
         '    db name: ' + obj.dbname,
         '    save simulation: ' + str(obj.save_sim),
         '    parallel: ' + type(obj.repeat).__module__.split('.')[-1]]
    return '\n'.join(s)
 def _setup_text(self):
     """
     Generates the rst for the setup
     :return:
     """
     # Get class name
     obj = self.setup
     cname = rst._as_rst_caption(type(obj).__name__, 0)
     # Add doc string
     mdoc = _getdoc(obj).strip('\n').replace('\r', '\n') + '\n\n'
     # Get parameters from class
     param_caption = rst._as_rst_caption('Parameters', 1)
     params = '\n'.join('#. **{p.name}:** {p}'.format(p=p) for p in get_parameters_from_setup(obj))
     return cname + mdoc + param_caption + params
 def _sampler_text(self):
     """
     Generates the rst for the sampler
     :return:
     """
     obj = self.sampler
     cname = rst._as_rst_caption(type(obj).__name__, 0)
     s = [
          '- **db format:** ' + obj.dbformat,
          '- **db name:** ' + obj.dbname,
          '- **save simulation:** ' + str(obj.save_sim),
          '- **parallel:** ' + type(obj.repeat).__module__.split('.')[-1],
          '', ''
          ]
     return cname + _getdoc(obj).strip('\n') + '\n\n' + '\n'.join(s)
def getdoc(x):
    from inspect import getdoc as _getdoc
    s = _getdoc(x)
    return s
示例#8
0
def getdoc(x):
    from inspect import getdoc as _getdoc
    s = _getdoc(x)
    return s