Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/numpy/core/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/numpy/core/__pycache__/arrayprint.cpython-35.pyc



(��^r�@s�dZddlmZmZmZdddgZdZddlZddlZej	ddkr�ydd	l
mZWq�ek
r�dd	l
mZYq�Xn9ydd	lmZWn"ek
r�dd	lmZYnXd
dlmZd
dlmZmZmZmZmZmZd
d
lmZmZmZmZmZd
dl m!Z!d
dl"m#Z#ej	ddkr�ej$Z%ej$d
Z&nej'Z%ej'd
Z&dd�Z(da)da*da+da,da-da.da/da0dddddddddd�Z1dd�Z2dd�Z3dd�Z4dd�Z5d d!�Z6d"d#�Z7d$d%�Z8d&d'dd(d)�Z9d*d+d,�Z:e:�dddd&d'e;dd-d��Z<d.d/�Z=d0d1�Z>Gd2d3�d3e?�Z@d4d5�ZAGd6d7�d7e?�ZBGd8d9�d9e?�ZCGd:d;�d;e?�ZDGd<d=�d=e?�ZEGd>d?�d?e?�ZFGd@dA�dAe?�ZGGdBdC�dCe?�ZHGdDdE�dEe?�ZIdS)FzXArray printing function

$Id: arrayprint.py,v 1.9 2005/09/13 13:58:44 teoliphant Exp $

�)�division�absolute_import�print_function�array2string�set_printoptions�get_printoptions�restructuredtextN�)�	get_ident�)�numerictypes)�maximum�minimum�absolute�	not_equal�isnan�isinf)�array�format_longfloat�datetime_as_string�
datetime_data�dtype)�ravel)�asarraycCs||S)N�)�x�yrr�H/opt/alt/python35/lib64/python3.5/site-packages/numpy/core/arrayprint.py�product-sri��F�K�nan�infcCs�|dk	r|a|dk	r$|a|dk	r6|a|dk	rH|a|dk	r\|a|dk	rn|a|dk	r�|a|adS)a�

    Set printing options.

    These options determine the way floating point numbers, arrays and
    other NumPy objects are displayed.

    Parameters
    ----------
    precision : int, optional
        Number of digits of precision for floating point output (default 8).
    threshold : int, optional
        Total number of array elements which trigger summarization
        rather than full repr (default 1000).
    edgeitems : int, optional
        Number of array items in summary at beginning and end of
        each dimension (default 3).
    linewidth : int, optional
        The number of characters per line for the purpose of inserting
        line breaks (default 75).
    suppress : bool, optional
        Whether or not suppress printing of small floating point values
        using scientific notation (default False).
    nanstr : str, optional
        String representation of floating point not-a-number (default nan).
    infstr : str, optional
        String representation of floating point infinity (default inf).
    formatter : dict of callables, optional
        If not None, the keys should indicate the type(s) that the respective
        formatting function applies to.  Callables should return a string.
        Types that are not specified (by their corresponding keys) are handled
        by the default formatters.  Individual types for which a formatter
        can be set are::

            - 'bool'
            - 'int'
            - 'timedelta' : a `numpy.timedelta64`
            - 'datetime' : a `numpy.datetime64`
            - 'float'
            - 'longfloat' : 128-bit floats
            - 'complexfloat'
            - 'longcomplexfloat' : composed of two 128-bit floats
            - 'numpystr' : types `numpy.string_` and `numpy.unicode_`
            - 'object' : `np.object_` arrays
            - 'str' : all other strings

        Other keys that can be used to set a group of types at once are::

            - 'all' : sets all types
            - 'int_kind' : sets 'int'
            - 'float_kind' : sets 'float' and 'longfloat'
            - 'complex_kind' : sets 'complexfloat' and 'longcomplexfloat'
            - 'str_kind' : sets 'str' and 'numpystr'

    See Also
    --------
    get_printoptions, set_string_function, array2string

    Notes
    -----
    `formatter` is always reset with a call to `set_printoptions`.

    Examples
    --------
    Floating point precision can be set:

    >>> np.set_printoptions(precision=4)
    >>> print(np.array([1.123456789]))
    [ 1.1235]

    Long arrays can be summarised:

    >>> np.set_printoptions(threshold=5)
    >>> print(np.arange(10))
    [0 1 2 ..., 7 8 9]

    Small results can be suppressed:

    >>> eps = np.finfo(float).eps
    >>> x = np.arange(4.)
    >>> x**2 - (x + eps)**2
    array([ -4.9304e-32,  -4.4409e-16,   0.0000e+00,   0.0000e+00])
    >>> np.set_printoptions(suppress=True)
    >>> x**2 - (x + eps)**2
    array([-0., -0.,  0.,  0.])

    A custom formatter can be used to display array elements as desired:

    >>> np.set_printoptions(formatter={'all':lambda x: 'int: '+str(-x)})
    >>> x = np.arange(3)
    >>> x
    array([int: 0, int: -1, int: -2])
    >>> np.set_printoptions()  # formatter gets reset
    >>> x
    array([0, 1, 2])

    To put back the default options, you can use:

    >>> np.set_printoptions(edgeitems=3,infstr='inf',
    ... linewidth=75, nanstr='nan', precision=8,
    ... suppress=False, threshold=1000, formatter=None)
    N)�_line_width�_summaryThreshold�_summaryEdgeItems�_float_output_precision�_float_output_suppress_small�_nan_str�_inf_str�
_formatter)�	precision�	threshold�	edgeitems�	linewidth�suppress�nanstr�infstr�	formatterrrrr;sncCs=tdtdtdtdtdtdtdtdt�}|S)	a	
    Return the current print options.

    Returns
    -------
    print_opts : dict
        Dictionary of current print options with keys

          - precision : int
          - threshold : int
          - edgeitems : int
          - linewidth : int
          - suppress : bool
          - nanstr : str
          - infstr : str
          - formatter : dict of callables

        For a full description of these options, see `set_printoptions`.

    See Also
    --------
    set_printoptions, set_string_function

    r+r,r-r.r/r0r1r2)	�dictr&r$r%r#r'r(r)r*)�drrrr�s	cs.ddlm}�jdkrkt��dtkrb|j�dt��td�f�}q*�}n�t��dtkr��fdd�ttt��t��D�}|j�fdd�ttt��t�dd	�D��n(�fdd�tdt���D�}|jt	|��}|S)
Nr)�numeric�cs g|]}t�|��qSr)�_leading_trailing)�.0�i)�arr�
<listcomp>�s	z%_leading_trailing.<locals>.<listcomp>cs!g|]}t�|��qSr)r7)r8r9)r:rrr;�s	rcs g|]}t�|��qSr)r7)r8r9)r:rrr;�s	���)
�r5�ndim�lenr%Zconcatenate�range�min�extend�tuple)r:�_nc�b�lr)r:rr7�s	&(r7cCs|r
dSdSdS)Nz True�Falser)rrrr�_boolFormatter�srHcCs.t|�tkrd}nd}|j|�S)z@ Object arrays containing lists should be printed unambiguously z
list({!r})z{!r})�type�list�format)�o�fmtrrr�_object_format�s	rNcCs
t|�S)N)�repr)rrrr�repr_format�srPcsBddd�d�fdd�d���fdd�d�fd	d�d
���fdd�d�fd
d�d�fdd�d�fdd�ddd�ddd�ddd�i}dd�}�dk	r>�fdd��j�D�}d|kr.x(|j�D]}|�d�||<qWd|krbx%dgD]}|�d�||<qDWd|kr�x(ddgD]}|�d�||<q{Wd|kr�x(d
dgD]}|�d�||<q�Wd |krx(ddgD]}|�d �||<q�Wx4|j�D]&}||kr|�|�||<qW|S)!N�boolcSstS)N)rHrrrr�<lambda>sz!_get_formatdict.<locals>.<lambda>�intcs
t��S)N)�
IntegerFormatr)�datarrrRs�floatcst����S)N)�FloatFormatr)rUr+�suppress_smallrrrRs�	longfloatcs
t��S)N)�LongFloatFormatr)r+rrrRs�complexfloatcst����S)N)�
ComplexFormatr)rUr+rXrrrRs	�longcomplexfloatcs
t��S)N)�LongComplexFormatr)r+rrrRs�datetimecs
t��S)N)�DatetimeFormatr)rUrrrR	s�	timedeltacs
t��S)N)�TimedeltaFormatr)rUrrrR
s�objectcSstS)N)rNrrrrrRs�numpystrcSstS)N)rPrrrrrRs�strcSstS)N)rerrrrrR
scs�fdd�S)Ncs�S)Nrr)rrrrRsz3_get_formatdict.<locals>.indirect.<locals>.<lambda>r)rr)rr�indirectsz!_get_formatdict.<locals>.indirectcs&g|]}�|dk	r|�qS)Nr)r8�k)r2rrr;s	z#_get_formatdict.<locals>.<listcomp>�allZint_kindZ
float_kindZcomplex_kindZstr_kind)�keys)rUr+rXr2�
formatdictrfZfkeys�keyr)rUr2r+rXr�_get_formatdictsBrlcCs�|j}|jdk	r�g}xb|jD]W}||}tt|�|||�}||jfkrrt|�}|j|�q(Wt|�S|j	}	t
||||�}
t|	tj
�r�|
d�St|	tj�rt|	tj�r�|
d�S|
d�Sn�t|	tj�rBt|	tj�r4|
d�S|
d�Sn�t|	tj�rt|	tj�rq|
d�S|
d�Snkt|	tjtjf�r�|
d	�St|	tj�r�|
d
�St|	tj�r�|
d�S|
d	�SdS)z;
    find the right formatting function for the dtype_
    NrQrarSrYrVr]r[rdr_rc)r�fields�names�_get_format_functionr�shape�SubArrayFormat�append�StructureFormatrIrl�
issubclass�_ntZbool_�integerZtimedelta64ZfloatingrYZcomplexfloatingZ
clongfloatZunicode_Zstring_Z
datetime64Zobject_)rUr+rXr2Zdtype_�format_functions�
field_nameZfield_values�format_functionZdtypeobjrjrrrro+sD	

	ro� r=c	Cs�|jtkr$d}t|�}nd}tt|��}t||||�}	d}
|
dt|�7}
t||	|j||
|t	|�dd�}|S)Nz..., r=rzrr<)
�sizer$r7rrror?�_formatArrayr>r%)r:�max_line_widthr+rX�	separator�prefixr2�summary_insertrUry�next_line_prefix�lstrrr�
_array2stringWs	r�z...cs�fdd�}|S)a
    Like the python 3.2 reprlib.recursive_repr, but forwards *args and **kwargs

    Decorates a function such that if it calls itself with the same first
    argument, it returns `fillvalue` instead of recursing.

    Largely copied from reprlib.recursive_repr
    cs4t��tj�����fdd��}|S)Ncs[t|�t�f}|�kr%�S�j|�z�|||�SWd�j|�XdS)N)�idr
�add�discard)�self�args�kwargsrk)�f�	fillvalue�repr_runningrr�wrapper}s
z>_recursive_guard.<locals>.decorating_function.<locals>.wrapper)�set�	functools�wraps)r�r�)r�)r�r�r�decorating_functionzs	'z-_recursive_guard.<locals>.decorating_functionr)r�r�r)r�r�_recursive_guardps
r�c	Cs
|dkrt}|dkr$t}|dkr6t}|dkrHt}|jfkr�|j�}|jjdk	r�t|gd|j�}	t	|	|||�}
|
|	d�}q	||�}nEt
jt|j�dkr�d}n!t
||||||d|�}|S)a�
    Return a string representation of an array.

    Parameters
    ----------
    a : ndarray
        Input array.
    max_line_width : int, optional
        The maximum number of columns the string should span. Newline
        characters splits the string appropriately after array elements.
    precision : int, optional
        Floating point precision. Default is the current printing
        precision (usually 8), which can be altered using `set_printoptions`.
    suppress_small : bool, optional
        Represent very small numbers as zero. A number is "very small" if it
        is smaller than the current printing precision.
    separator : str, optional
        Inserted between elements.
    prefix : str, optional
        An array is typically printed as::

          'prefix(' + array2string(a) + ')'

        The length of the prefix string is used to align the
        output correctly.
    style : function, optional
        A function that accepts an ndarray and returns a string.  Used only
        when the shape of `a` is equal to ``()``, i.e. for 0-D arrays.
    formatter : dict of callables, optional
        If not None, the keys should indicate the type(s) that the respective
        formatting function applies to.  Callables should return a string.
        Types that are not specified (by their corresponding keys) are handled
        by the default formatters.  Individual types for which a formatter
        can be set are::

            - 'bool'
            - 'int'
            - 'timedelta' : a `numpy.timedelta64`
            - 'datetime' : a `numpy.datetime64`
            - 'float'
            - 'longfloat' : 128-bit floats
            - 'complexfloat'
            - 'longcomplexfloat' : composed of two 128-bit floats
            - 'numpystr' : types `numpy.string_` and `numpy.unicode_`
            - 'str' : all other strings

        Other keys that can be used to set a group of types at once are::

            - 'all' : sets all types
            - 'int_kind' : sets 'int'
            - 'float_kind' : sets 'float' and 'longfloat'
            - 'complex_kind' : sets 'complexfloat' and 'longcomplexfloat'
            - 'str_kind' : sets 'str' and 'numpystr'

    Returns
    -------
    array_str : str
        String representation of the array.

    Raises
    ------
    TypeError
        if a callable in `formatter` does not return a string.

    See Also
    --------
    array_str, array_repr, set_printoptions, get_printoptions

    Notes
    -----
    If a formatter is specified for a certain type, the `precision` keyword is
    ignored for that type.

    This is a very flexible function; `array_repr` and `array_str` are using
    `array2string` internally so keywords with the same name should work
    identically in all three functions.

    Examples
    --------
    >>> x = np.array([1e-16,1,2,3])
    >>> print(np.array2string(x, precision=2, separator=',',
    ...                       suppress_small=True))
    [ 0., 1., 2., 3.]

    >>> x  = np.arange(3.)
    >>> np.array2string(x, formatter={'float_kind':lambda x: "%.2f" % x})
    '[0.00 1.00 2.00]'

    >>> x  = np.arange(3)
    >>> np.array2string(x, formatter={'int':lambda x: hex(x)})
    '[0x0L 0x1L 0x2L]'

    Nrrz[]r2)r#r&r'r*rp�itemrrmrror��reducerr�)r:r}r+rXr~r�styler2r�arrryr�rrrr�s*b	cCsVt|j��t|j��|krB||j�d7}|}||7}||fS)N�
)r?�rstrip)�s�line�word�max_line_lenr�rrr�_extendLines
(
r�cCs3|dkrtd��|rId|t|�krI|}|}	|}
nd}t|�}	d}
|dkr�d}|}xFt|�D]8}
|||
�|}t|||||�\}}q�W|
r�t|||
||�\}}xMt|	dd�D]9}
|||
�|}t|||||�\}}q�W||d�}t|||||�\}}||d7}d|t|�d�}n�d}|j�}x�t|�D]x}
|
dkr�||7}|t||
||d|d	||||�7}|j�|j�d
t|dd�}q�W|
rB|||
d
7}x�t|	dd
�D]}
|sm|
|	krw||7}|t||
||d|d	||||�7}|j�|j�d
t|dd�}qUW|s�|	dkr�||7}|t|d||d|d	||||�j�d7}|S)zgformatArray is designed for two modes of operation:

    1. Full output

    2. Summarized output

    rzrank shouldn't be zero.r6r=rz]
�[Nrzr�r<r<r<r<)�
ValueErrorr?r@r�r�r|�max)r:ryZrankr�r�r~Z
edge_itemsr�Z
leading_itemsZtrailing_itemsZsummary_insert1r�r�r9r��seprrrr|s`		""


/


/

r|c@s:eZdZddd�Zdd�Zddd�Zd	S)
rWFcCsf||_||_||_d|_d|_d|_y|j|�Wnttfk
raYnXdS)NFr)	r+rX�sign�
exp_format�large_exponent�max_str_len�
fillFormat�	TypeError�NotImplementedError)r�rUr+rXr�rrr�__init__[s						zFloatFormat.__init__c	sddlm}|jdd���t|�t|�B}t|d�|@}t|j|��}t|�dkr�d}d}nbt	j
|�}tj
|�}|dkr�d�_�j
r�|d	ks�||d
kr�d�_WdQRX�jr}d|kodknp|dk�_d
�j�_�jrH�jd7_�jrZd�nd��d�j�jf�n�d�jf�t|�r�t��fdd�|D��}nd}t�j|�}ttt|���|d�_|j|�r0t�jtt�tt�d��_�jrBd�nd��d�j|f�d�jf�_��_dS)Nr)r5rh�ignorergg�חATg-C��6?g@�@g>��N}a+g}Ô%�I�Trz%+�%z%d.%dez%%.%dfcs%g|]}t|�j���qSr)�_digitsr+)r8r)rKr�rrr;�s	z*FloatFormat.fillFormat.<locals>.<listcomp>r6z%#+z%#z%d.%dfz%%%ds)r=r5�errstaterrrr�compressr?r
r�rr�rXr�r+r�r�r�rArerS�anyr(r)�special_fmtrK)	r�rUrDZspecialZvalidZnon_zeroZmax_valZmin_valr+r)rKr�rr�isR			+			#				zFloatFormat.fillFormatTcCs�ddlm}|jdd���t|�r[|jrJ|jdtfS|jtfSnVt|�r�|dkr�|jr�|jdtfS|jtfSn|jdtfSWdQRX|j	|}|j
r|d}|dks�|dkr�|dd
�d
|dd�}nq|jrS|dd
kr�d|dd�|dd�}n3|r�|jd
�}|dt
|�t
|�}|S)Nr)r5�invalidr��+r�-r	r6�0rz������r�r�r�r�)r=r5r�rr�r�r(rr)rKr�r�r�r?)r�r�strip_zerosrDr�Zexpsign�zrrr�__call__�s0		
	
%	%zFloatFormat.__call__N)�__name__�
__module__�__qualname__r�r�r�rrrrrWZs3rWcCsE|dkr=||}|jd�}|t|�t|�SdSdS)Nrr�)r�r?)rr+rKr�r�rrrr��s

r�c@s(eZdZdd�Zdd�ZdS)rTcCs�yTttttj|���tttj|����}dt|�d|_Wn)ttfk
rnYnt	k
rYnXdS)Nr�r4)
r�r?rer
r�rrKr�r�r�)r�rUr�rrrr��s
zIntegerFormat.__init__cCs3t|kotknr'|j|Sd|SdS)Nz%s)�_MININT�_MAXINTrK)r�rrrrr��szIntegerFormat.__call__N)r�r�r�r�r�rrrrrT�s
rTc@s+eZdZddd�Zdd�ZdS)rZFcCs||_||_dS)N)r+r�)r�r+r�rrrr��s	zLongFloatFormat.__init__cCs�t|�r(|jrdtSdtSn�t|�rg|dkr\|jrQdtSdtSq�dtSnP|dkr�|jr�dt||j�Sdt||j�Snt||j�SdS)Nr�rzrr�)rr�r(rr)rr+)r�rrrrr��s			zLongFloatFormat.__call__N)r�r�r�r�r�rrrrrZ�srZc@s(eZdZdd�Zdd�ZdS)r^cCs(t|�|_t|dd�|_dS)Nr�T)rZ�real_format�imag_format)r�r+rrrr��szLongComplexFormat.__init__cCs0|j|j�}|j|j�}||dS)N�j)r��realr��imag)r�r�rr9rrrr��szLongComplexFormat.__call__N)r�r�r�r�r�rrrrr^�sr^c@s(eZdZdd�Zdd�ZdS)r\cCs:t|j||�|_t|j||dd�|_dS)Nr�T)rWr�r�r�r�)r�rr+rXrrrr�szComplexFormat.__init__cCs�|j|jdd�}|j|jdd�}|jjsp|jd�}|ddt|�t|�}n
|d}||S)Nr�Fr�r�rz)r�r�r�r�r�r�r?)r�rr�r9r�rrrr�
s%
zComplexFormat.__call__N)r�r�r�r�r�rrrrr\sr\c@s1eZdZddddd�Zdd�ZdS)r`NZ	same_kindcCsk|dkr:|jjdkr4t|j�d}nd}|dkrLd}||_||_||_dS)N�Mrr�Znaive)r�kindr�timezone�unit�casting)r�rr�r�r�rrrr�s		zDatetimeFormat.__init__c	Cs)dt|d|jd|jd|j�S)Nz'%s'r�r�r�)rr�r�r�)r�rrrrr�$s		zDatetimeFormat.__call__)r�r�r�r�r�rrrrr`sr`c@s(eZdZdd�Zdd�ZdS)rbcCs|jjdkrtdgd|j�d}t|jjd�}|j|�}|t||j|��}t|�dkr�tttt	j
|���tttj
|����}nd}t|�t|�kr�t|d�}dt|�d|_d	j
|�|_dS)
N�mZNaTrr�i8�r�r4z'NaT')rr�r�	byteorder�viewrr?r�rer
r�rrK�rjust�_nat)r�rUZ	nat_valueZ	int_dtypeZint_view�vr�rrrr�+s!zTimedeltaFormat.__init__cCsA|djd�|jd�kr)|jS|j|jd�SdS)Nrr�)r�r�rK�astype)r�rrrrr�=s"zTimedeltaFormat.__call__N)r�r�r�r�r�rrrrrb*srbc@s(eZdZdd�Zdd�ZdS)rqcCs
||_dS)N)ry)r�ryrrrr�FszSubArrayFormat.__init__cs_|jdkr7ddj�fdd�|D��dSddj�fdd�|D��dS)Nrr�z, c3s|]}�j|�VqdS)N)ry)r8r:)r�rr�	<genexpr>Ksz*SubArrayFormat.__call__.<locals>.<genexpr>�]c3s|]}�j|�VqdS)N)r�)r8r:)r�rrr�Ls)r>�join)r�r�r)r�rr�Is(zSubArrayFormat.__call__N)r�r�r�r�r�rrrrrqEsrqc@s(eZdZdd�Zdd�ZdS)rscCs||_t|�|_dS)N)rwr?�
num_fields)r�rwrrrr�Ps	zStructureFormat.__init__cCsnd}x4t||j�D] \}}|||�d7}qWd|jkr\|dd�n
|dd�dS)N�(z, rr6�)r�r<)�ziprwr�)r�rr��fieldryrrrr�TszStructureFormat.__call__N)r�r�r�r�r�rrrrrsOsrs)J�__doc__�
__future__rrr�__all__�
__docformat__�sysr��version_info�_threadr
�ImportError�
_dummy_thread�thread�dummy_threadr=rru�umathr
rrrrr�
multiarrayrrrrrZfromnumericrr5r�maxsizer�r�Zmaxintrr%r$r&r'r#r(r)r*rrr7rHrNrPrlror�r�rOrr�r|rcrWr�rTrZr^r\r`rbrqrsrrrr�<module>s~	

.(			{#+,	}Cd