Package mdp :: Class NodeMetaclass
[hide private]
[frames] | no frames]

Type NodeMetaclass


A metaclass which copies docstrings from private to public methods.

This metaclass is meant to overwrite doc-strings of methods like Node.execute, Node.stop_training, Node.inverse with the ones defined in the corresponding private methods Node._execute, Node._stop_training, Node._inverse, etc.

This makes it possible for subclasses of Node to document the usage of public methods, without the need to overwrite the ancestor's methods.

Instance Methods [hide private]

Inherited from type: __call__, __delattr__, __eq__, __ge__, __getattribute__, __gt__, __hash__, __init__, __instancecheck__, __le__, __lt__, __ne__, __repr__, __setattr__, __subclasscheck__, __subclasses__, mro

Inherited from object: __format__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
a new object with type S, a subtype of T

__new__(cls, classname, bases, members)
 
_function_infodict(func)
Returns an info dictionary containing:
 
_get_infos(pubmethod)
 
_select_private_methods_to_wrap(cls, members)
Select private methods that can overwrite the public docstring.
 
_wrap_function(original_func, wrapper_infodict)
Return a wrapped version of func.
 
_wrap_method(wrapper_infodict, cls)
Return a wrapped version of func.
Class Variables [hide private]
  DOC_METHODS = ['_train', '_stop_training', '_execute', '_inver...
Properties [hide private]

Inherited from type: __abstractmethods__, __base__, __bases__, __basicsize__, __dictoffset__, __flags__, __itemsize__, __mro__, __name__, __weakrefoffset__

Inherited from object: __class__

Method Details [hide private]

__new__(cls, classname, bases, members)
Static Method

 


Returns:
a new object with type S, a subtype of T

Overrides: object.__new__
(inherited documentation)

_function_infodict(func)
Static Method

 

Returns an info dictionary containing:

  • name (the name of the function : str)
  • argnames (the names of the arguments : list)
  • defaults (the values of the default arguments : tuple)
  • signature (the signature without the defaults : str)
  • doc (the docstring : str)
  • module (the module name : str)
  • dict (the function __dict__ : str)
  • kwargs_name (the name of the kwargs argument, if present, else None)
>>> def f(self, x=1, y=2, *args, **kw): pass
>>> info = getinfo(f)
>>> info["name"]
'f'
>>> info["argnames"]
['self', 'x', 'y', 'args', 'kw']
>>> info["defaults"]
(1, 2)
>>> info["signature"]
'self, x, y, *args, **kw'
>>> info["kwargs_name"]
kw

_get_infos(pubmethod)
Static Method

 

_select_private_methods_to_wrap(cls, members)
Static Method

 

Select private methods that can overwrite the public docstring.

Return a dictionary priv_infos[pubname], where the keys are the public name of the private method to be wrapped, and the values are dictionaries with the signature, doc, ... informations of the private methods (see _function_infodict).

_wrap_function(original_func, wrapper_infodict)
Static Method

 
Return a wrapped version of func.
Parameters:
  • original_func - The function to be wrapped.
  • wrapper_infodict - The infodict to use for constructing the wrapper.

_wrap_method(wrapper_infodict, cls)
Static Method

 
Return a wrapped version of func.
Parameters:
  • wrapper_infodict - The infodict to be used for constructing the wrapper.
  • cls - Class to which the wrapper method will be added, this is used for the super call.

Class Variable Details [hide private]

DOC_METHODS

Value:
['_train',
 '_stop_training',
 '_execute',
 '_inverse',
 '_label',
 '_prob']