document_class_CONFIG

(class from pyomo.common.config)

class pyomo.common.config.document_class_CONFIG(section='CONFIG', indent_spacing=4, width=78, visibility=None, doc=None, preamble=None, methods=None)[source]

Bases: document_kwargs_from_configdict

Class decorator for documenting CONFIG class attributes.

This wrapper around the document_kwargs_from_configdict decorator will add the documentation generated from the target’s CONFIG class attribute to the main class docstring.

In addition to the standard options accepted by document_kwargs_from_configdict, this decorator also accepts methods, an iterable of strings specifying methods on the target class to also document as accepting the CONFIG entries as keyword arguments.

Example

@document_class_CONFIG(methods=['solve'])
class MyClass:
    '''A class with a CONFIG class attribute.'''

    CONFIG = ConfigDict()
    CONFIG.declare('iterlim', ConfigValue(
        domain=int, doc='Solver iteration limit'
    ))
    CONFIG.declare('timeout', ConfigValue(
        domain=float, doc='Solver (wall clock) time limit'
    ))

    def solve(model, **kwargs):
        "Solve the specified model"
        config = self.CONFIG(kwargs)

Will result in

>>> help(MyClass)
Help on class MyClass ...

class MyClass(object)
 |  A class with a CONFIG class attribute.
 |
 |  **Class configuration**
 |
 |  This class leverages the Pyomo Configuration System for managing
 |  configuration options.  See the discussion on :ref:`configuring class
 |  hierarchies <class_config>` for more information on how configuration
 |  class attributes, instance attributes, and method keyword arguments
 |  interact.
 |
 |  .. _MyClass::CONFIG:
 |
 |  CONFIG
 |  ------
 |  iterlim: int, optional
 |
 |      Solver iteration limit
 |
 |  timeout: float, optional
 |
 |      Solver (wall clock) time limit
 |
 |  ...

 >>> help(MyClass.solve)
 Help on function solve:

 solve(model, **kwargs)
     Solve the specified model

     Keyword Arguments
     -----------------
     iterlim: int, optional

         Solver iteration limit

     timeout: float, optional

         Solver (wall clock) time limit
__init__(section='CONFIG', indent_spacing=4, width=78, visibility=None, doc=None, preamble=None, methods=None)[source]

Methods

__init__([section, indent_spacing, width, ...])

Member Documentation