ó
‡ˆ\c           @   si   d  d l  Z  d  d l Z d  d l Z d d g Z d e f d „  ƒ  YZ d „  Z d e f d „  ƒ  YZ d S(   iÿÿÿÿNt
   deprecatedt   DeprecationDictc           B   s>   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   s—  Decorator to mark a function or class as deprecated.

    Issue a warning when the function is called/the class is instantiated and
    adds a warning to the docstring.

    The optional extra argument will be appended to the deprecation message
    and the docstring. Note: to use this with the default value for extra, put
    in an empty of parentheses:

    >>> from sklearn.utils import deprecated
    >>> deprecated() # doctest: +ELLIPSIS
    <sklearn.utils.deprecation.deprecated object at ...>

    >>> @deprecated()
    ... def some_function(): pass

    Parameters
    ----------
    extra : string
          to be added to the deprecation messages
    t    c         C   s   | |  _  d  S(   N(   t   extra(   t   selfR   (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   __init__"   s    c         C   s-   t  | t ƒ r |  j | ƒ S|  j | ƒ Sd S(   sP   Call method

        Parameters
        ----------
        obj : object
        N(   t
   isinstancet   typet   _decorate_classt   _decorate_fun(   R   t   obj(    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   __call__%   s    c            sy   d | j  ‰ |  j r* ˆ d |  j 7‰ n  | j ‰  ‡  ‡ f d †  } | | _ d | _  |  j ˆ  j ƒ | _ ˆ  | _ | S(   Ns   Class %s is deprecateds   ; %sc             s    t  j ˆ d t ƒˆ  |  | Ž  S(   Nt   category(   t   warningst   warnt   DeprecationWarning(   t   argst   kwargs(   t   initt   msg(    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   wrapped9   s    R   (   t   __name__R   R   t   _update_doct   __doc__t   deprecated_original(   R   t   clsR   (    (   R   R   s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR   1   s    					c            sm   d ˆ  j  ‰ |  j r* ˆ d |  j 7‰ n  t j ˆ  ƒ ‡  ‡ f d †  ƒ } |  j | j ƒ | _ ˆ  | _ | S(   s   Decorate function funs   Function %s is deprecateds   ; %sc             s    t  j ˆ d t ƒˆ  |  | Ž  S(   NR   (   R   R   R   (   R   R   (   t   funR   (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR   K   s    (   R   R   t	   functoolst   wrapsR   R   t   __wrapped__(   R   R   R   (    (   R   R   s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR	   D   s    	!	c         C   sB   d } |  j  r% d | |  j  f } n  | r> d | | f } n  | S(   Nt
   DEPRECATEDs   %s: %ss   %s

%s(   R   (   R   t   olddoct   newdoc(    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR   W   s    	(   R   t
   __module__R   R   R   R   R	   R   (    (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR       s   			c         C   s†   t  j d k  r t d ƒ ‚ n  t |  d g  ƒ } | d k rE g  } n  d d j g  | D]! } t | j t ƒ rU | j ^ qU ƒ k } | S(	   s=   Helper to check if func is wraped by our deprecated decoratori   i   s-   This is only available for python3.5 or abovet   __closure__R    R   (   i   i   N(	   t   syst   version_infot   NotImplementedErrort   getattrt   Nonet   joinR   t   cell_contentst   str(   t   funct   closurest   ct   is_deprecated(    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   _is_deprecated`   s    	
'c           B   s5   e  Z d  Z d „  Z d „  Z d d „ Z d „  Z RS(   sä   A dict which raises a warning when some keys are looked up

    Note, this does not raise a warning for __contains__ and iteration.

    It also will raise a warning even after the key has been manually set by
    the user.
    c         O   s&   i  |  _  t t |  ƒ j | | Ž  d  S(   N(   t   _deprecationst   superR   R   (   R   R   R   (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR   v   s    	c         C   sK   | |  j  k r5 |  j  | \ } } t j | | Ž  n  t t |  ƒ j | ƒ S(   N(   R0   R   R   R1   R   t   __getitem__(   R   t   keyt	   warn_argst   warn_kwargs(    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR2   z   s    c         C   s%   y |  | SWn t  k
 r  | SXd S(   sö   Return the value corresponding to key, else default.

        Parameters
        ----------
        key : any hashable object
            The key
        default : object, optional
            The default returned when key is not in dict
        N(   t   KeyError(   R   R3   t   default(    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   get€   s    c         O   s   | | f |  j  | <d S(   s¢   Add a warning to be triggered when the specified key is read

        Parameters
        ----------
        key : any hashable object
            The key
        N(   R0   (   R   R3   R   R   (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   add_warning   s    N(   R   R!   R   R   R2   R'   R8   R9   (    (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyR   n   s
   		(	   R#   R   R   t   __all__t   objectR    R/   t   dictR   (    (    (    s8   lib/python2.7/site-packages/sklearn/utils/deprecation.pyt   <module>   s   X	