ó
šxŠ\c           @   sÀ  d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 m
 Z
 d d l m Z m Z d e f d „  ƒ  YZ e d	 dB ƒ Z e e d
 d d d d d ƒZ e e d
 d d d d d ƒZ d „  Z d „  Z d „  Z e ƒ  Z d e d <d e d <dB e d <e e d
 d d d d d ƒZ e ƒ  Z d e d <dB e d <e e d
 d d d d d ƒZ d „  Z e d	 dB ƒ Z e e d
 d d d d d ƒZ d „  Z e ƒ  Z  dB e  d <dB e  d	 <e e  d
 d d d d d ƒZ! e ƒ  Z" dB e" d <dB e" d	 <e e" d d d d ƒZ# e e" d
 d  d d d d ƒZ$ d! „  Z% e ƒ  Z& dB e& d <dB e& d	 <e' e& d" <e e& d
 d# d d d d ƒZ( e e& d
 d$ d d d d ƒZ) e d	 dB d" e' ƒ Z* e e* d d% ƒZ+ e d	 dB d" e' ƒ Z, e e, d
 d& d d d d ƒZ- e e, d
 d' d d d d ƒZ. e d d( ƒ Z/ e e/ d
 d) d d d d ƒZ0 e d dB ƒ Z1 e e1 d
 d* d d d d ƒZ2 e d	 dB ƒ Z3 e e3 d
 d+ d d d d ƒZ4 e ƒ  Z5 d e5 d <d e5 d <dB e5 d <e e5 d
 d, d d% ƒZ6 e ƒ  Z7 dB e7 d <dB e7 d	 <e7 j8 ƒ  Z9 Z: e' e: d" <dB e: d- <e7 j8 ƒ  Z; e' e; d. <e' e; d" <e' e7 d" <e e7 d d% ƒZ< e e: d
 d/ d d d d ƒZ= e e9 d
 d0 d d d d ƒZ> e e7 d
 d1 d d d d ƒZ? e e; d
 d2 d d d d ƒZ@ e ƒ  ZA dB eA d <dB eA d	 <e' eA d" <e eA d d% ƒZB e ƒ  ZC dB eC d	 <d3 eC d4 <e eC d
 d5 d d% ƒZD d6 „  ZE e d7 dB ƒ ZF e eF d
 d8 d d d d ƒZG d9 „  ZH d: „  ZI d; „  ZJ d< „  ZK dB d= „ ZL dC ZM d@ „  ZN dA „  ZO dB S(D   s´  
For compatibility with numpy libraries, pandas functions or
methods have to accept '*args' and '**kwargs' parameters to
accommodate numpy arguments that are not actually used or
respected in the pandas implementation.

To ensure that users do not abuse these parameters, validation
is performed in 'validators.py' to make sure that any extra
parameters passed correspond ONLY to those in the numpy signature.
Part of that validation includes whether or not the user attempted
to pass in non-default values for these extraneous parameters. As we
want to discourage users from relying on these parameters when calling
the pandas implementation, we want them only to pass in the default values
for these parameters.

This module provides a set of commonly used default arguments for functions
and methods that are spread throughout the codebase. This module will make it
easier to adjust to future upstream changes in the analogous numpy signatures.
iÿÿÿÿ(   t   ndarray(   t   OrderedDict(   t   UnsupportedFunctionCall(   t   validate_argst   validate_args_and_kwargst   validate_kwargs(   t   is_boolt
   is_integert   CompatValidatorc           B   s,   e  Z d d d d  „ Z d d d d „ Z RS(   c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   fnamet   methodt   defaultst   max_fname_arg_count(   t   selfR   R	   R
   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   __init__!   s    			c         C   së   | s | rç | d  k r! |  j n | } | d  k r< |  j n | } | d  k rW |  j n | } | d k r‚ t | | | |  j ƒ qç | d k r¤ t | | |  j ƒ qç | d k rÌ t | | | | |  j ƒ qç t d j	 d | ƒ ƒ ‚ n  d  S(   Nt   argst   kwargst   boths$   invalid validation method '{method}'R
   (
   t   NoneR	   R   R
   R   R   R   R   t
   ValueErrort   format(   R   R   R   R	   R   R
   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   __call__(   s    N(   t   __name__t
   __module__R   R   R   (    (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyR      s   t   outR	   t   argminR
   R   R   i   t   argmaxc         C   s;   t  |  t ƒ s |  d  k r1 |  f | } t }  n  |  | f S(   N(   t
   isinstanceR    R   t   True(   t   skipnaR   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   process_skipnaE   s    	c         C   s&   t  |  | ƒ \ }  } t | | ƒ |  S(   s!  
    If 'Series.argmin' is called via the 'numpy' library,
    the third parameter in its signature is 'out', which
    takes either an ndarray or 'None', so check if the
    'skipna' parameter is either an instance of ndarray or
    is None, since 'skipna' itself should be a boolean
    (   R   t   validate_argmin(   R   R   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_argmin_with_skipnaM   s    	c         C   s&   t  |  | ƒ \ }  } t | | ƒ |  S(   s!  
    If 'Series.argmax' is called via the 'numpy' library,
    the third parameter in its signature is 'out', which
    takes either an ndarray or 'None', so check if the
    'skipna' parameter is either an instance of ndarray or
    is None, since 'skipna' itself should be a boolean
    (   R   t   validate_argmax(   R   R   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_argmax_with_skipna[   s    	t   axist	   quicksortt   kindt   ordert   argsorti    c         C   sE   t  |  ƒ s |  d k r. |  f | } t }  n  t | | d d ƒ|  S(   s%  
    If 'Categorical.argsort' is called via the 'numpy' library, the
    first parameter in its signature is 'axis', which takes either
    an integer or 'None', so check if the 'ascending' parameter has
    either integer type or is None, since 'ascending' itself should
    be a boolean
    R   i   N(   R   R   R   t   validate_argsort_kind(   t	   ascendingR   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_argsort_with_ascendingy   s
    		t   clipi   c         C   s6   t  |  t ƒ r% |  f | } d }  n  t | | ƒ |  S(   s  
    If 'NDFrame.clip' is called via the numpy library, the third
    parameter in its signature is 'out', which can takes an ndarray,
    so check if the 'axis' parameter is an instance of ndarray, since
    'axis' itself should either be an integer or None
    N(   R   R    R   t   validate_clip(   R#   R   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_clip_with_axis   s
    	t   compresst   dtypet   cumsumc         C   s9   t  |  ƒ s" |  f | } t }  n  t | | d | ƒ|  S(   sß   
    If this function is called via the 'numpy' library, the third
    parameter in its signature is 'dtype', which takes either a
    'numpy' dtype or 'None', so check if the 'skipna' parameter is
    a boolean or not
    R	   (   R   R   t   validate_cum_func(   R   R   R   t   name(    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_cum_func_with_skipna®   s
    	t   keepdimst   allt   anyR   t   mint   maxt   Ct   reshapet   repeatt   roundt   sortt   initialt   overwrite_inputt   sumt   prodt   meant   mediant   raiset   modet   takec         C   sN   t  |  t ƒ s |  d k r1 |  f | } t }  n  t | | d d d d ƒ|  S(   sò   
    If this function is called via the 'numpy' library, the third
    parameter in its signature is 'axis', which takes either an
    ndarray or 'None', so check if the 'convert' parameter is either
    an instance of ndarray or is None
    R   i   R
   R   N(   R   R    R   R   t   validate_take(   t   convertR   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_take_with_convert	  s
    	t   axest	   transposec         C   sz   y t  t ƒ  | ƒ Wn_ t k
 ru } t |  ƒ j } t | ƒ } d | k rf | d j d | ƒ 7} n  t | ƒ ‚ n Xd  S(   Ns%   the 'axes' parameter is not supporteds    for {klass} instancest   klass(   t   validate_transposet   tupleR   t   typeR   t   strR   (   t   instR   t   eRL   t   msg(    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_transpose_for_generic  s    c         C   si   d } d j  d |  ƒ } t | ƒ d k r9 t | ƒ ‚ n  x) | D]! } | | k r@ t | ƒ ‚ q@ q@ Wd  S(   NR#   R/   R   sS   numpy operations are not valid with window objects. Use .{func}() directly instead t   funci    (   R#   R/   R   (   R   t   lenR   (   R2   R   R   t
   numpy_argsRS   t   arg(    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_window_func/  s    		c         C   si   d } d j  d |  ƒ } t | ƒ d k r9 t | ƒ ‚ n  x) | D]! } | | k r@ t | ƒ ‚ q@ q@ Wd  S(   NR#   R/   R   sW   numpy operations are not valid with window objects. Use .rolling(...).{func}() instead RU   i    (   R#   R/   R   (   R   RV   R   (   R2   R   R   RW   RS   RX   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_rolling_func=  s    		c         C   si   d } d j  d |  ƒ } t | ƒ d k r9 t | ƒ ‚ n  x) | D]! } | | k r@ t | ƒ ‚ q@ q@ Wd  S(   NR#   R/   R   sY   numpy operations are not valid with window objects. Use .expanding(...).{func}() instead RU   i    (   R#   R/   R   (   R   RV   R   (   R2   R   R   RW   RS   RX   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_expanding_funcK  s    		c         C   sf   | d k r g  } n  t | ƒ t | ƒ } t | ƒ t | ƒ d k rb t d j d |  ƒ ƒ ‚ n  d S(   s®   
    'args' and 'kwargs' should be empty, except for allowed
    kwargs because all of
    their necessary parameters are explicitly listed in
    the function signature
    i    sO   numpy operations are not valid with groupby. Use .groupby(...).{func}() insteadRU   N(   R   t   setRV   R   R   (   R2   R   R   t   allowed(    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_groupby_funcY  s    		t   stdt   varc         C   sV   t  | ƒ t  | ƒ d k rR |  t k rC t d j d |  ƒ ƒ ‚ qR t d ƒ ‚ n  d S(   s   
    'args' and 'kwargs' should be empty because all of
    their necessary parameters are explicitly listed in
    the function signature
    i    sQ   numpy operations are not valid with resample. Use .resample(...).{func}() insteadRU   s   too many arguments passed inN(   RV   t   RESAMPLER_NUMPY_OPSR   R   t	   TypeError(   R
   R   R   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_resampler_funcp  s    	c         C   s]   d } |  d k r d S|  | k s> |  d k  rY | |  d k  rY t d j d | ƒ ƒ ‚ n  d S(   së   
    Ensure that the axis argument passed to min, max, argmin, or argmax is
    zero or None, as otherwise it will be incorrectly ignored.

    Parameters
    ----------
    axis : int or None

    Raises
    ------
    ValueError
    i   Ni    s;   `axis` must be fewer than the number of dimensions ({ndim})t   ndim(   R   R   R   (   R#   Rd   (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   validate_minmax_axis€  s    (N(   R7   R8   R@   RA   RB   R_   R`   (P   t   __doc__t   numpyR    t   pandas.compatR   t   pandas.errorsR   t   pandas.util._validatorsR   R   R   t   pandas.core.dtypes.commonR   R   t   objectR   t   dictR   t   ARGMINMAX_DEFAULTSR   R!   R   R    R"   t   ARGSORT_DEFAULTSt   validate_argsortt   ARGSORT_DEFAULTS_KINDR(   R*   t   CLIP_DEFAULTSR,   R-   t   COMPRESS_DEFAULTSt   validate_compresst   CUM_FUNC_DEFAULTSR1   t   validate_cumsumR3   t   ALLANY_DEFAULTSt   Falset   validate_allt   validate_anyt   LOGICAL_FUNC_DEFAULTSt   validate_logical_funct   MINMAX_DEFAULTSt   validate_mint   validate_maxt   RESHAPE_DEFAULTSt   validate_reshapet   REPEAT_DEFAULTSt   validate_repeatt   ROUND_DEFAULTSt   validate_roundt   SORT_DEFAULTSt   validate_sortt   STAT_FUNC_DEFAULTSt   copyt   PROD_DEFAULTSt   SUM_DEFAULTSt   MEDIAN_DEFAULTSt   validate_stat_funct   validate_sumt   validate_prodt   validate_meant   validate_mediant   STAT_DDOF_FUNC_DEFAULTSt   validate_stat_ddof_funct   TAKE_DEFAULTSRG   RI   t   TRANSPOSE_DEFAULTSRM   RT   RY   RZ   R[   R^   Ra   Rc   Re   (    (    (    s;   lib/python2.7/site-packages/pandas/compat/numpy/function.pyt   <module>   sê   				


	

			

	

			


	


		






			


			

						 	