Exemple #1
0
 def commentrepr(self):
     """Returns a list with comments, e.g. for making string
     representations more informative.  When `pub.options.reprcomments`
     is set to |False|, an empty list is returned.
     """
     if pub.options.reprcomments:
         return ['# %s' % line for line in
                 textwrap.wrap(autodoctools.description(self), 78)]
     return []
Exemple #2
0
 def extract_units(self, parseqs=None):
     """Return a set of units of the given or the handled parameters
     and sequences."""
     if parseqs is None:
         parseqs = self.parseqs
     units = set()
     for parseq in parseqs:
         desc = autodoctools.description(parseq)
         if '[' in desc:
             unit = desc.split('[')[-1].split(']')[0]
             units.add(unit)
     return units
Exemple #3
0
 def commentrepr(self):
     """Returns a list with comments, e.g. for making string representations
     more informative.  When :attr:`pub.options.reprcomments` is set to
     `False`, an empty list is returned.
     """
     from hydpy import pub
     if pub.options.reprcomments:
         return [
             '# %s' % line
             for line in textwrap.wrap(autodoctools.description(self), 78)
         ]
     else:
         return []
Exemple #4
0
 def __new__(cls, name, parents, dict_):
     for tuplename in ('_RUNMETHODS', '_ADDMETHODS'):
         methods = dict_.get(tuplename, ())
         if methods:
             if tuplename == '_RUNMETHODS':
                 lst = [
                     '\n\n\n    The following "run methods" are called '
                     'each simulation step run in the given sequence:'
                 ]
             elif tuplename == '_ADDMETHODS':
                 lst = [
                     '\n\n\n    The following "additional methods" are '
                     'called by at least one "run method":'
                 ]
             for method in methods:
                 lst.append('      * :func:`~%s` `%s`' % ('.'.join(
                     (method.__module__,
                      method.__name__)), autodoctools.description(method)))
             dict_['__doc__'] += '\n'.join(l for l in lst)
     return type.__new__(cls, name, parents, dict_)
Exemple #5
0
    def __new__(cls, cls_name, cls_parents, dict_):
        _METHOD_GROUPS = ('_RUN_METHODS', '_ADD_METHODS', '_INLET_METHODS',
                          '_OUTLET_METHODS', '_RECEIVER_METHODS',
                          '_SENDER_METHODS', '_PART_ODE_METHODS',
                          '_FULL_ODE_METHODS')
        dict_['_METHOD_GROUPS'] = _METHOD_GROUPS
        for method_name in _METHOD_GROUPS:
            methods = dict_.get(method_name, ())
            if methods:
                if method_name == '_RUN_METHODS':
                    lst = [
                        '\n\n\n    The following "run methods" are called '
                        'each simulation step run in the given sequence:'
                    ]
                elif method_name == '_ADD_METHODS':
                    lst = [
                        '\n\n\n    The following "additional methods" are '
                        'called by at least one "run method":'
                    ]
                elif method_name == '_INLET_METHODS':
                    lst = [
                        '\n\n\n    The following "inlet update methods" '
                        'are called in the given sequence immediately  '
                        'before solving the differential equations '
                        'of the respective model:'
                    ]
                elif method_name == '_OUTLET_METHODS':
                    lst = [
                        '\n\n\n    The following "outlet update methods" '
                        'are called in the given sequence immediately  '
                        'after solving the differential equations '
                        'of the respective model:'
                    ]
                elif method_name == '_RECEIVER_METHODS':
                    lst = [
                        '\n\n\n    The following "receiver update methods" '
                        'are called in the given sequence before solving '
                        'the differential equations of any model:'
                    ]
                elif method_name == '_SENDER_METHODS':
                    lst = [
                        '\n\n\n    The following "sender update methods" '
                        'are called in the given sequence after solving '
                        'the differential equations of all models:'
                    ]
                elif method_name == '_PART_ODE_METHODS':
                    lst = [
                        '\n\n\n    The following methods define the '
                        'relevant components of a system of ODE '
                        'equations (e.g. direct runoff):'
                    ]
                elif method_name == '_FULL_ODE_METHODS':
                    lst = [
                        '\n\n\n    The following methods define the '
                        'complete equations of an ODE system '
                        '(e.g. change in storage of `fast water` due to '
                        ' effective precipitation and direct runoff):'
                    ]
                for method in methods:
                    lst.append('      * :func:`~%s` %s' % ('.'.join(
                        (method.__module__,
                         method.__name__)), autodoctools.description(method)))
                doc = dict_.get('__doc__', 'Undocumented model.')
                dict_['__doc__'] = doc + '\n'.join(l for l in lst)

        return type.__new__(cls, cls_name, cls_parents, dict_)