ó
áp7]c           @@  sG  d  d l  m Z d  d l m Z d  d l Z d  d l Z e e j ƒ e d ƒ k Z e j	 j
 Z
 d „  Z e j d d „ Z d d d „ Z y d  d l m Z Wn' e k
 rÆ d  d	 l m Z e Z n Xy d  d
 l m Z m Z Wn' e k
 r
d  d
 l m Z m Z n Xy d  d l m Z Wn! e k
 rBd  d l m Z n Xd S(   i    (   t   absolute_import(   t   LooseVersionNs   0.19c         C@  s  |  d k r |  S|  |  d @s" |  St  d ƒ } d } xÁ | |  k  r÷ | } xy | |  k  rÄ |  | } d | d j ƒ  } | | } | |  k r’ | S| | k  r§ | } n  | d 9} | |  k rL | SqL W| | k  rÚ | } n  | d 9} | |  k r7 | Sq7 W| | k  r| } n  | S(   s!  
    Find the next regular number greater than or equal to target.
    Regular numbers are composites of the prime factors 2, 3, and 5.
    Also known as 5-smooth numbers or Hamming numbers, these are the optimal
    size for inputs to FFTPACK.

    Target must be a positive integer.
    i   i   t   infi   i   i   (   t   floatt
   bit_length(   t   targett   matcht   p5t   p35t   quotientt   p2t   N(    (    s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pyt   _next_regular   s6    	
	
	
	c         C@  s_   t  j |  d t ƒ| } | d k	 r7 | j | ƒ } n  t | t  j ƒ s[ t  j | ƒ } n  | S(   s"   Return an array of all value.
    t   dtypeN(   t   npt   onest   boolt   Nonet   astypet
   isinstancet   ndarrayt   asarray(   t   shapet   valuet   typecodet   out(    (    s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pyt	   _valarray8   s    c   	      @  s(  | d k r3 | d k r' t d ƒ ‚ qN t j } n | d k	 rN t d ƒ ‚ n  t j | Œ  } t ‡  f d †  | Dƒ ƒ } t j g  | D] } | j j ^ q† ƒ } t	 t j
 | d ƒ d | d | ƒ} t j | ˆ  | | Œ  ƒ | d k	 r$t ‡  f d †  | Dƒ ƒ } t j | ˆ  | | Œ  ƒ n  | S(	   sº  
    np.where(cond, x, fillvalue) always evaluates x even where cond is False.
    This one only evaluates f(arr1[cond], arr2[cond], ...).
    For example,
    >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
    >>> def f(a, b):
        return a*b
    >>> _lazywhere(a > 2, (a, b), f, np.nan)
    array([ nan,  nan,  21.,  32.])
    Notice it assumes that all `arrays` are of the same shape, or can be
    broadcasted together.
    s%   One of (fillvalue, f2) must be given.s)   Only one of (fillvalue, f2) can be given.c         3@  s!   |  ] } t  j ˆ  | ƒ Vq d  S(   N(   R   t   extract(   t   .0t   arr(   t   cond(    s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pys	   <genexpr>[   s    i    R   R   c         3@  s"   |  ] } t  j ˆ  | ƒ Vq d  S(   N(   R   R   (   R   R   (   R   (    s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pys	   <genexpr>`   s    N(   R   t
   ValueErrorR   t   nant   broadcast_arrayst   tuplet   mintypecodeR   t   charR   R   t   place(	   R   t   arrayst   ft	   fillvaluet   f2t   tempt   at   tcodeR   (    (   R   s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pyt
   _lazywhereD   s    (%(   t   loggamma(   t   gammaln(   t	   factorialt
   factorial2(   t	   logsumexp(   t
   __future__R    t   distutils.versionR   t   numpyR   t   scipyt   __version__t
   SP_GTE_019t   libt   NumpyVersionR   R    R   R   R-   t   scipy.specialR.   t   ImportErrorR/   R0   R1   t
   scipy.miscR2   (    (    (    s7   lib/python2.7/site-packages/statsmodels/compat/scipy.pyt   <module>   s*   	-$
