ó
ÐEe]c        	   @` s;  d  Z  d d l m Z m Z m Z d d g Z d d l Z d d l m Z d d l	 m
 Z
 d d	 l m Z d d
 l m Z d d l m Z m Z d d l m Z m Z d d l m Z d „  Z d „  Z d e f d „  ƒ  YZ i e j e j 6e j e j 6e j e j 6Z d Z i e  d e j! d d d e j" d ƒ ƒ e j# 6e  d e j$ d d d e j" d ƒ ƒ e j 6e  d e j% d d d e j" d ƒ ƒ e j& 6e  d e j' d d d e j" d ƒ ƒ e j( 6Z) i  Z* d „  Z+ i  Z, d „  Z- d  „  Z. d! „  Z/ e
 d" ƒ d e f d# „  ƒ  Yƒ Z0 e
 d" ƒ d e f d$ „  ƒ  Yƒ Z1 d S(%   sJ   Machine limits for Float32 and Float64 and (long double) if available...

i    (   t   divisiont   absolute_importt   print_functiont   finfot   iinfoNi   (   t   MachAr(   t
   set_module(   t   numeric(   t   numerictypes(   t   arrayt   inf(   t   log10t   exp2(   t   umathc         C` s+   |  j  d k r' |  j ƒ  }  d |  _ n  |  S(   s   fix rank-0 --> rank-1i    i   (   i   (   t   ndimt   copyt   shape(   t   a(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   _fr0   s    c         C` s+   |  j  d k r' |  j ƒ  }  d |  _ n  |  S(   s   fix rank > 0 --> rank-0i   (    (   t   sizeR   R   (   R   (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   _fr1   s    t
   MachArLikec           B` s   e  Z d  Z d „  Z RS(   s$    Object to simulate MachAr instance c         ` s|  t  ˆ ‰ ‡ f d †  ‰  ‡  f d †  } ‡ ‡ f d †  } ˆ d |  _ | | j d ƒ ƒ |  _ |  _ | | j d ƒ ƒ |  _ | | j d ƒ ƒ |  _ |  _ | | j d ƒ ƒ |  _ |  _	 ˆ d	 | j d
 ƒ ƒ |  _
 |  j j | ƒ t t |  j ƒ ƒ |  _ | ˆ  d ƒ |  j ƒ |  _ | |  j ƒ |  _ | |  j ƒ |  _ | |  j ƒ |  _ | |  j ƒ |  _ | |  j ƒ |  _ d  S(   Nc         ` s   t  |  g ˆ  ƒ S(   N(   R	   (   t   v(   t   ftype(    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   <lambda>)   t    c         ` s   t  ˆ  |  ƒ ƒ S(   N(   R   (   R   (   t
   float_conv(    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   *   R   c         ` s   ˆ d t  t |  ƒ d ˆ  ƒ S(   Nt   fmti    (   R	   R   (   R   (   R   t   params(    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   +   R   t   titlet   epst   epsnegt   huget   tinyt   itypet   ibetai
   (   t   _MACHAR_PARAMSR   t   popt   epsilonR   R   t   xmaxR    t   xminR!   R#   t   __dict__t   updatet   intR   t	   precisiont
   resolutiont   _str_epst   _str_epsnegt	   _str_xmint	   _str_xmaxt   _str_resolution(   t   selfR   t   kwargst   float_to_floatt   float_to_str(    (   R   R   R   s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   __init__%   s$    
(   t   __name__t
   __module__t   __doc__R7   (    (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   "   s   s(   numpy {} precision floating point numberR"   R   s   %24.16eR   t   doubles   %15.7et   singles   %ss   long doubles   %12.5et   halfc         C` s   |  t  | <d  S(   N(   t   _KNOWN_TYPES(   t   machart   bytepat(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   _register_type\   s    c           C` s„  t  j }  t |  d d d d d d d d d	 d
 d d d d d d d d d t |  d ƒ ƒ d t |  d ƒ ƒ d |  d ƒ d |  dD ƒ ƒ} t | d ƒ | t d <t  j } t | d d d d d d d d d	 d d d d d d d d d d t | d ƒ ƒ d t | d ƒ ƒ d | d dE dF ƒ d t | d ƒ ƒ ƒ} t | d ƒ | t d  <t  j } dG } dH } t | d d$ d d% d d& d d' d	 d( d d) d d d d d d d dI d | d d+ | | | d, ƒ d | ƒ} t | d- ƒ | t d. <t  j } t | d/ ƒ ƒ }	 t | d0 ƒ ƒ }
 t	 j
 d1 d2 ƒ # | d ƒ |	 |
 | d, ƒ } Wd  QXt | d d3 d d/ d d0 d d4 d	 d5 d d6 d d d d d d d t | d3 ƒ ƒ d |	 d | d |
 ƒ} t | d7 ƒ t | d7 ƒ | t d <t | d8 ƒ ƒ } t | d0 ƒ ƒ } t	 j
 d1 d2 ƒ # | d ƒ | | | d, ƒ } Wd  QXt | d d9 d d8 d d0 d d4 d	 d: d d6 d d d d d d d t | d9 ƒ ƒ d | d | d | ƒ} t | d; ƒ | t d< <t t d= ƒ rÕt j | t ƒ | d ƒ ƒ n | j } t | d d> d d? d d& d d' d	 d@ d d) d d d d d d d t | d> ƒ ƒ d t | d? ƒ ƒ d | d t | d& ƒ ƒ ƒ} t | dA ƒ t | dB ƒ | t dC <d  S(J   Nt   machepiöÿÿÿt   negepiõÿÿÿt   minexpiòÿÿÿt   maxexpi   t   iti
   t   iexpi   R#   i   t   irndt   ngrdi    R   R   R    iàÿ  R!   s   f®iéÿÿÿièÿÿÿi‚ÿÿÿi€   i   i   i   s   ÍÌÌ½i    g       @g     €JÀg     ðÀiÌÿÿÿiËÿÿÿiüÿÿi   i4   i   g      JÀg      ð?i   s   š™™™™™¹¿i@   iÿÿÿiÀÿÿt   allt   ignoreiÿÿÿi @  ip   i   s   š™™™™™™™™™™™™™û¿iÀÿÿÿiÁÿÿÿi?   s
   ÍÌÌÌÌÌÌÌû¿iP   t	   nextafteri—ÿÿÿi–ÿÿÿii   s   š™™™™™Y<š™™™™™¹¿s   š™™™™™¹¿š™™™™™Y<t   ddg      ?g      p>l	                    g       <g       g      °<(   t   ntypest   float16R   R   RA   t	   _float_mat   float32t   float64t
   longdoubleR   t   errstatet   hasattrR   RL   R
   R    (   t   f16t
   float16_mat   f32t
   float32_mat   f64t
   epsneg_f64t   tiny_f64t
   float64_mat   ldt   epsneg_f128t	   tiny_f128t	   huge_f128t   float128_mat
   epsneg_f80t   tiny_f80t   huge_f80t
   float80_mat   huge_ddt   float_dd_ma(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   _register_known_types`   sì    		
		
			
	$		
$		
-		c         C` sÇ   t  j |  ƒ } | d k r0 t t |  ƒ ƒ ‚ n  |  d ƒ j d ƒ j ƒ  } t j | ƒ } | d k r‹ |  t j	 k r‹ t j | d  ƒ } n  | d k	 r› | St
 j d j | |  ƒ t d d ƒt |  ƒ S(   s€   Get MachAr instance or MachAr-like instance

    Get parameters for floating point type, by first trying signatures of
    various known floating point types, then, if none match, attempting to
    identify parameters by analysis.

    Parameters
    ----------
    ftype : class
        Numpy floating point type class (e.g. ``np.float64``)

    Returns
    -------
    ma_like : instance of :class:`MachAr` or :class:`MachArLike`
        Object giving floating point parameters for `ftype`.

    Warns
    -----
    UserWarning
        If the binary signature of the float type is not in the dictionary of
        known float types.
    s   -0.1t   <i
   sV   Signature {} for {} does not match any known type: falling back to type probe functiont
   stackleveli   N(   R$   t   gett   Nonet
   ValueErrort   reprt   newbyteordert   tobytesR>   RN   RS   t   warningst   warnt   formatt   UserWarningt   _discovered_machar(   R   R   t   keyt   ma_like(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   _get_macharï   s    	c         ` sK   t  ˆ  ‰ t ‡  f d †  ‡ f d †  ‡  f d †  ‡  ‡ f d †  ˆ d ƒ S(   sB    Create MachAr instance with found information on float types
    c         ` s   t  |  g ˆ  ƒ S(   N(   R	   (   R   (   R   (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR     R   c         ` s   t  |  j ˆ  d ƒ ƒ d S(   NR"   i    (   R   t   astype(   R   (   R   (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR     R   c         ` s   t  t |  ƒ d ˆ  ƒ S(   Ni    (   R	   R   (   R   (   R   (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR      R   c         ` s   ˆ d t  t |  ƒ d ˆ  ƒ S(   NR   i    (   R	   R   (   R   (   R   R   (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   !  R   R   (   R$   R   (   R   (    (   R   R   s3   lib/python2.7/site-packages/numpy/core/getlimits.pyRv     s    
t   numpyc           B` s8   e  Z d  Z i  Z d „  Z d „  Z d „  Z d „  Z RS(   sn	  
    finfo(dtype)

    Machine limits for floating point types.

    Attributes
    ----------
    bits : int
        The number of bits occupied by the type.
    eps : float
        The smallest representable positive number such that
        ``1.0 + eps != 1.0``.  Type of `eps` is an appropriate floating
        point type.
    epsneg : floating point number of the appropriate type
        The smallest representable positive number such that
        ``1.0 - epsneg != 1.0``.
    iexp : int
        The number of bits in the exponent portion of the floating point
        representation.
    machar : MachAr
        The object which calculated these parameters and holds more
        detailed information.
    machep : int
        The exponent that yields `eps`.
    max : floating point number of the appropriate type
        The largest representable number.
    maxexp : int
        The smallest positive power of the base (2) that causes overflow.
    min : floating point number of the appropriate type
        The smallest representable number, typically ``-max``.
    minexp : int
        The most negative power of the base (2) consistent with there
        being no leading 0's in the mantissa.
    negep : int
        The exponent that yields `epsneg`.
    nexp : int
        The number of bits in the exponent including its sign and bias.
    nmant : int
        The number of bits in the mantissa.
    precision : int
        The approximate number of decimal digits to which this kind of
        float is precise.
    resolution : floating point number of the appropriate type
        The approximate decimal resolution of this type, i.e.,
        ``10**-precision``.
    tiny : float
        The smallest positive usable number.  Type of `tiny` is an
        appropriate floating point type.

    Parameters
    ----------
    dtype : float, dtype, or instance
        Kind of floating point data-type about which to get information.

    See Also
    --------
    MachAr : The implementation of the tests that produce this information.
    iinfo : The equivalent for integer data types.

    Notes
    -----
    For developers of NumPy: do not instantiate this at the module level.
    The initial calculation of these parameters is expensive and negatively
    impacts import times.  These objects are cached, so calling ``finfo()``
    repeatedly inside your functions is not a problem.

    c         C` s…  y t  j | ƒ } Wn& t k
 r; t  j t | ƒ ƒ } n X|  j j | d  ƒ } | d  k	 ra | S| g } t  j | ƒ } | | k	 r› | j | ƒ | } n  t	 | t  j
 ƒ sÀ t d | ƒ ‚ n  |  j j | d  ƒ } | d  k	 rå | St	 | t  j ƒ s&t | } | | k	 r&| j | ƒ | } q&n  |  j j | d  ƒ } | d  k	 rK| St j |  ƒ j | ƒ } x | D] } | |  j | <qjW| S(   Ns   data type %r not inexact(   R   t   dtypet	   TypeErrort   typet   _finfo_cacheRl   Rm   t
   obj2sctypet   appendt
   issubclasst   inexactRn   t   floatingt   _convert_to_floatt   objectt   __new__t   _init(   t   clsR|   t   objt   dtypest   newdtypet   dt(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR‡   m  s:    		
c         C` sY  t  j | ƒ |  _ t | ƒ } x9 d d d d d d g D] } t |  | t | | ƒ ƒ q7 Wx7 d d d	 g D]& } t |  | t | | ƒ j d
 ƒ qj W|  j j d |  _ | j j d
 |  _	 |  j	 |  _
 | j j d
 |  _ | j |  _ | j |  _ | |  _ | j j ƒ  |  _ | j j ƒ  |  _ | j j ƒ  |  _ | j j ƒ  |  _ | j j ƒ  |  _ |  S(   NR,   RG   RE   RD   RC   RB   R!   R-   R   i    i   (   R   R|   Ry   t   setattrt   getattrt   flatt   itemsizet   bitsR    t   maxt   minR   RG   t   nexpRF   t   nmantR?   R0   t   stript	   _str_tinyR1   t   _str_maxR/   R.   R2   (   R3   R|   R?   t   word(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyRˆ   Ž  s*    		$	c         C` s   d } | |  j  S(   NsÍ  Machine parameters for %(dtype)s
---------------------------------------------------------------
precision = %(precision)3s   resolution = %(_str_resolution)s
machep = %(machep)6s   eps =        %(_str_eps)s
negep =  %(negep)6s   epsneg =     %(_str_epsneg)s
minexp = %(minexp)6s   tiny =       %(_str_tiny)s
maxexp = %(maxexp)6s   max =        %(_str_max)s
nexp =   %(nexp)6s   min =        -max
---------------------------------------------------------------
(   R)   (   R3   R   (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   __str__¦  s    
c         C` s-   |  j  j } |  j j ƒ  } | | d <d | S(   Nt   klasssZ   %(klass)s(resolution=%(resolution)s, min=-%(_str_max)s, max=%(_str_max)s, dtype=%(dtype)s)(   t	   __class__R8   R)   R   (   R3   t   ct   d(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   __repr__´  s
    
(   R8   R9   R:   R   R‡   Rˆ   R›   R    (    (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   %  s   D	!		c           B` s_   e  Z d  Z i  Z i  Z d „  Z d „  Z e e ƒ Z d „  Z e e ƒ Z d „  Z	 d „  Z
 RS(   sl  
    iinfo(type)

    Machine limits for integer types.

    Attributes
    ----------
    bits : int
        The number of bits occupied by the type.
    min : int
        The smallest integer expressible by the type.
    max : int
        The largest integer expressible by the type.

    Parameters
    ----------
    int_type : integer type, dtype, or instance
        The kind of integer data type to get information about.

    See Also
    --------
    finfo : The equivalent for floating point data types.

    Examples
    --------
    With types:

    >>> ii16 = np.iinfo(np.int16)
    >>> ii16.min
    -32768
    >>> ii16.max
    32767
    >>> ii32 = np.iinfo(np.int32)
    >>> ii32.min
    -2147483648
    >>> ii32.max
    2147483647

    With instances:

    >>> ii32 = np.iinfo(np.int32(10))
    >>> ii32.min
    -2147483648
    >>> ii32.max
    2147483647

    c         C` s©   y t  j | ƒ |  _ Wn) t k
 rA t  j t | ƒ ƒ |  _ n X|  j j |  _ |  j j d |  _ d |  j |  j f |  _ |  j d k r¥ t d |  j f ƒ ‚ n  d  S(   Ni   s   %s%dt   ius   Invalid integer data type %r.(	   R   R|   R}   R~   t   kindR‘   R’   Rw   Rn   (   R3   t   int_type(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR7   ñ  s    c         C` sk   |  j  d k r d Sy t j |  j } Wn9 t k
 rb t d |  j d >ƒ } | t j |  j <n X| Sd S(   s   Minimum value of given dtype.t   ui    i   N(   R¢   R   t	   _min_valsRw   t   KeyErrorR+   R’   (   R3   t   val(    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR”   ü  s    c         C` s€   y t  j |  j } Wne t k
 r{ |  j d k rM t d |  j >d ƒ } n t d |  j d >d ƒ } | t  j |  j <n X| S(   s   Maximum value of given dtype.R¤   i   (   R   t	   _max_valsRw   R¦   R¢   R+   R’   (   R3   R§   (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR“   
  s    c         C` s,   d } | i |  j  d 6|  j d 6|  j d 6S(   s   String representation.s½   Machine parameters for %(dtype)s
---------------------------------------------------------------
min = %(min)s
max = %(max)s
---------------------------------------------------------------
R|   R”   R“   (   R|   R”   R“   (   R3   R   (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR›     s    c         C` s#   d |  j  j |  j |  j |  j f S(   Ns   %s(min=%s, max=%s, dtype=%s)(   R   R8   R”   R“   R|   (   R3   (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR    #  s    (   R8   R9   R:   R¥   R¨   R7   R”   t   propertyR“   R›   R    (    (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyR   ¼  s   0				(2   R:   t
   __future__R    R   R   t   __all__Rr   R?   R   t	   overridesR   R   R   R   RN   R	   R
   R   R   R   R   R   R†   R   R<   t   csinglet   float_t   complex_t	   longfloatt
   clongfloatR…   t
   _title_fmtt   dictt   int64Rt   R;   t   int32t   longlongRS   t   int16R=   R$   R>   RA   RP   Ri   Ry   Rv   R   R   (    (    (    s3   lib/python2.7/site-packages/numpy/core/getlimits.pyt   <module>   sZ   									+	–