ó
ØÆ÷Xc           @` sp  d  Z  d d l m Z m Z m Z d d g Z d d l m Z d d l m	 Z	 d d l m
 Z d d	 l	 m Z d
 „  Z i e j e j 6e j e j 6e j e j 6Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ e d k rle e j ƒ Z e d e j ƒ e d e j ƒ e e j ƒ Z e d e j ƒ e d e j ƒ e e j ƒ Z e d e j ƒ e d e j ƒ n  d S(   sJ   Machine limits for Float32 and Float64 and (long double) if available...

i    (   t   divisiont   absolute_importt   print_functiont   finfot   iinfoi   (   t   MachAr(   t   numeric(   t   numerictypes(   t   arrayc         C` s   |  j  d k r d |  _ n  |  S(   s   fix rank-0 --> rank-1i    i   (   i   (   t   ndimt   shape(   t   a(    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyt   _frz   s    c           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_cachet   gett   Nonet
   obj2sctypet   appendt
   issubclasst   inexactt
   ValueErrort   floatingt   _convert_to_floatt   objectt   __new__t   _init(   t   clsR   t   objt   dtypest   newdtypet   dt(    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR   `   s:    		
c         ` s>  t  j ˆ  ƒ |  _ ˆ  t j k r9 t j ‰ d ‰ d } n‡ ˆ  t j k r` t j ‰ d ‰ d } n` ˆ  t j k r‡ t j ‰ d ‰ d } n9 ˆ  t j	 k r® t j
 ‰ d ‰ d } n t t ˆ  ƒ ƒ ‚ t ‡  f d	 †  ‡ f d
 †  ‡  f d †  ‡  ‡ f d †  d | ƒ } x9 d d d d d d g D] } t |  | t | | ƒ ƒ qWx7 d d d g D]& } t |  | t | | ƒ j d ƒ qOW|  j j d |  _ | j j d |  _ |  j |  _ | j j d |  _ | j |  _ | j |  _ | |  _ | j j ƒ  |  _ | j j ƒ  |  _  | j! j ƒ  |  _! | j" j ƒ  |  _" | j# j ƒ  |  _# |  S(   Ns   %24.16et   doubles   %15.7et   singles   %ss   long doubles   %12.5et   halfc         ` s   t  |  g ˆ  ƒ S(   N(   R   (   t   v(   R   (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyt   <lambda>–   s    c         ` s   t  |  j ˆ  ƒ ƒ d S(   Ni    (   R   t   astype(   R%   (   t   itype(    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR&   —   s    c         ` s   t  t |  ƒ d ˆ  ƒ S(   Ni    (   R   R   (   R%   (   R   (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR&   ˜   s    c         ` s   ˆ t  t |  ƒ d ˆ  ƒ S(   Ni    (   R   R   (   R%   (   R   t   fmt(    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR&   ™   s    s(   numpy %s precision floating point numbert	   precisiont   iexpt   maxexpt   minexpt   negept   machept   tinyt
   resolutiont   epsnegi    i   ($   R   R   t   ntypesR"   t   int64R#   t   int32t
   longdoublet   longlongR$   t   int16R   t   reprR   t   setattrt   getattrt   flatt   itemsizet   bitst   huget   maxt   mint   epsR+   t   nexpt   itt   nmantt   machart	   _str_xmint   stript	   _str_tinyt	   _str_xmaxt   _str_maxt   _str_epsnegt   _str_epst   _str_resolution(   t   selfR   t   precnameRF   t   word(    (   R   R)   R(   s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR      sT    										$	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
---------------------------------------------------------------
(   t   __dict__(   RO   R)   (    (    s3   /tmp/pip-build-X4mzal/numpy/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__t   __name__RR   t   copy(   RO   t   ct   d(    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyt   __repr__¾   s
    
(   RV   t
   __module__t   __doc__R   R   R   RS   RZ   (    (    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR      s   C	!	/	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 ƒ ‚ n  d  S(   Ni   s   %s%dt   ius   Invalid integer data type.(	   R   R   R   R   t   kindR=   R>   t   keyR   (   RO   t   int_type(    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyt   __init__ú   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_valsR_   t   KeyErrort   intR>   (   RO   t   val(    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyRA     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.Rb   i   (   R   t	   _max_valsR_   Rd   R^   Re   R>   (   RO   Rf   (    (    s3   /tmp/pip-build-X4mzal/numpy/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   RA   R@   (   R   RA   R@   (   RO   R)   (    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyRS   !  s    c         C` s#   d |  j  j |  j |  j |  j f S(   Ns   %s(min=%s, max=%s, dtype=%s)(   RU   RV   RA   R@   R   (   RO   (    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyRZ   ,  s    (   RV   R[   R\   Rc   Rg   Ra   RA   t   propertyR@   RS   RZ   (    (    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyR   Æ   s   /				t   __main__s   single epsilon:s   single tiny:s   float epsilon:s   float tiny:s   longfloat epsilon:s   longfloat tiny:N(   R\   t
   __future__R    R   R   t   __all__RF   R   t    R   R   R3   R   R   R#   t   csinglet   float_t   complex_t	   longfloatt
   clongfloatR   R   R   R   RV   t   ft   printRB   R0   t   float(    (    (    s3   /tmp/pip-build-X4mzal/numpy/numpy/core/getlimits.pyt   <module>   s.   	­j