Current File : //proc/self/root/proc/self/root/lib64/python2.7/site-packages/numpy/core/arrayprint.pyo
�
E�`Qc	@s:dZdddgZdZddlZddlZddlmZmZm	Z	m
Z
mZmZddl
mZmZmZdd	lmZd
�Zdadad
aeadadadadaejddkr�ddlm Z nddddddddd�Z!d�Z"d�Z#d�Z$d�Z%dddd�Z&d�Z'ddddde(dd�Z)d�Z*d�Z+de,fd ��YZ-d!�Z.ej/Z0ej/d"Z1d#e,fd$��YZ2d%e,fd&��YZ3d'e,fd(��YZ4d)e,fd*��YZ5d+e,fd,��YZ6d-e,fd.��YZ7dS(/sWArray printing function

$Id: arrayprint.py,v 1.9 2005/09/13 13:58:44 teoliphant Exp $
tarray2stringtset_printoptionstget_printoptionstrestructuredtexti����N(tmaximumtminimumtabsolutet	not_equaltisnantisinf(tformat_longfloattdatetime_as_stringt
datetime_data(travelcCs||S(N((txty((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pytproductsii�iiKtnantinfi(treducecCs�|dk	r|an|dk	r*|an|dk	r?|an|dk	rT|an|dk	rk|an|dk	r�|an|dk	r�|an|adS(st

    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
            - 'numpy_str' : 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'

    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(	tNonet_line_widtht_summaryThresholdt_summaryEdgeItemst_float_output_precisiont_float_output_suppress_smallt_nan_strt_inf_strt
_formatter(t	precisiont	thresholdt	edgeitemst	linewidthtsuppresstnanstrtinfstrt	formatter((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR%sl						cCs=tdtdtdtdtdtdtdtdt�}|S(	s	
    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

    RRRR R!R"R#R$(	tdictRRRRRRRR(td((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR�s	cCs=ddl}|jdkr[t|�dtkrR|j|t |tf�}q9|}n�t|�dtkr�gttt|�t��D]}t||�^q�}|jgttt|�t�dd�D]}t||�^q��n2gtdt|��D]}t||�^q}|jt	|��}|S(Ni����iii(
tnumerictndimtlenRtconcatenatetrangetmint_leading_trailingtextendttuple(tat_nctbtitl((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR-�s
	2=2cCs|r
dSdSdS(Ns TruetFalse((R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt_boolFormatter�scCs
t|�S(N(trepr(R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pytrepr_format�st tc	CsD|dkrt}n|dkr*t}n|dkr?t}n|dkrTt}n|jtkrxd}t|�}nd}t|�}i
t	d6t
|�d6t|||�d6t|�d6t
|||�d6t|�d6t|�d	6t|�d
6td6td6}	|dk	rg|j�D]}
||
dk	r%|
^q%}d
|kr{x%|	j�D]}|d
|	|<q`Wnd|kr�x"dgD]}|d|	|<q�Wnd|kr�x%ddgD]}|d|	|<q�Wnd|krx%ddgD]}|d|	|<q�Wnd|krHx%ddgD]}|d|	|<q-Wnx4|	j�D]#}||krU|||	|<qUqUWny/|j}
d}ddl}|j|t�WnGtk
r�|jj}t|tj�r�|	d}
q�t|tj�r't|tj�r|	d
}
q�|	d}
q�t|tj �ret|tj!�rX|	d}
q�|	d}
q�t|tj"�r�t|tj#�r�|	d}
q�|	d}
q�t|tj$tj%f�r�|	d}
q�t|tj&�r�|	d	}
q�|	d}
nXd}|dt'|�7}t(||
t'|j)�|||t*|�d }|S(Ns..., R:tbooltinttfloatt	longfloattcomplexfloattlongcomplexfloattdatetimet	timedeltatnumpystrtstrtalltint_kindt
float_kindtcomplex_kindtstr_kindsnThe `_format` attribute is deprecated in Numpy 2.0 and will be removed in 2.1. Use the `formatter` kw instead.i����R9(+RRRRRtsizeRR-R
R6t
IntegerFormattFloatFormattLongFloatFormatt
ComplexFormattLongComplexFormattDatetimeFormattTimedeltaFormatR8RDtkeyst_formattwarningstwarntDeprecationWarningtAttributeErrortdtypettypet
issubclasst_nttbool_tintegerttimedelta64tfloatingR>tcomplexfloatingt
clongfloattunicode_tstring_t
datetime64R)t_formatArraytshapeR(R0tmax_line_widthRtsuppress_smallt	separatortprefixR$tsummary_inserttdatat
formatdicttktfkeystkeytformat_functiontmsgRTtdtypeobjtnext_line_prefixtlst((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt
_array2string�s�				


	




/	









cCsyddl}g}xZ|D]R}t||j�r@|j�}nt|t�r^t|�}n|j|�qWt|�S(Ni����(R't
isinstancetndarrayttolistR/t_convert_arraystappend(tobjR1tnewtupRn((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRzCs
c	Cs�|jdkr�|j�}y5|j|�}	d}
ddl}|j|
t�Wq�tk
r�t|t�r~t	|�}n||�}	q�XnBt
t|j�dkr�d}	n!t||||||d|�}	|	S(s�
    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
            - 'numpy_str' : 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.

    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]'

    snThe `_format` attribute is deprecated in Numpy 2.0 and will be removed in 2.1. Use the `formatter` kw instead.i����Nis[]R$((
RftitemRSRTRURVRWRwR/RzRRRv(R0RgRRhRiRjtstyleR$RRuRrRT((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyROs \
	cCsYt|j��t|j��|krE||j�d7}|}n||7}||fS(Ns
(R)trstrip(tstlinetwordtmax_line_lenRt((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt_extendLine�s
(	
c
Csh|dkr@|j�}t|t�r6t|�}nt|�S|rsd|t|�krs|||}	}
}ndt|�d}	}
}|dkr�d}|}
xFt|	�D]8}|||�|}t||
|||�\}}
q�W|rt||
|||�\}}
nxMt|
dd�D]9}|||�|}t||
|||�\}}
q(W||d�}t||
|||�\}}
||
d7}d|t|�}n�d}|j�}x�t|	�D]{}|dkr�||7}n|t	||||d|d||||�7}|j�|j�d	t
|dd�}q�W|rq|||d	7}nx�t|
dd�D]�}|	s�||
kr�||7}n|t	||||d|d||||�7}|j�|j�d	t
|dd�}q�W|	s|
dkr)||7}n|t	|d||d|d||||�j�d7}|S(
sgformatArray is designed for two modes of operation:

    1. Full output

    2. Summarized output

    iiR:ii����s]
t[R9s
(R~RwR/RzRDR)txrangeR�R�Retmax(R0RqtrankR�RtRit
edge_itemsRkR|t
leading_itemsttrailing_itemstsummary_insert1R�R�R3R�tsep((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRe�s^	
"!"


/


/

RLcBs)eZed�Zd�Zed�ZRS(cCse||_||_||_t|_t|_d|_y|j|�Wntt	fk
r`nXdS(Ni(
RRhtsignR5t
exp_formattlarge_exponenttmax_str_lent
fillFormatt	TypeErrortNotImplementedError(tselfRlRRhR�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt__init__s						cCs�ddl}|jdd�}z�t|�t|�B}t|d�|@}t|j|��}t|�dkr�d}d}nhtj	|�}t
j	|�}|dkr�t|_n|j
r�|dks�||dkr�t|_nWd|j|�X|jr�d|kod	knp)|d
k|_d|j|_|jrZ|jd7_n|jrld
}	nd}	|	d|j|jf}	n�d|jf}	t|�r�tg|D]}
t|
|j|	�^q��}nd}t|j|�}ttt|���|d|_|j|�rQt|jtt�tt�d�|_n|jrcd}	nd}	|	d|j|f}	d|jf|_|	|_dS(Ni����REtignoreigg�חAg-C��6?g@�@g>��N}a+g}Ô%�I�Tiis%+t%s%d.%des%%.%dfis%#+s%#s%d.%dfs%%%ds(R'tseterrRR	RRtcompressR)RRRtTrueR�RhR�RR�R�R�t_digitsR,RDR<tanyRRtspecial_fmttformat(R�RlR1terrstatetspecialtvalidtnon_zerotmax_valtmin_valR�RR((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR�sV		+			+#				cCs�ddl}|jdd�}z�t|�rY|jrH|jdtfS|jtfSnYt|�r�|dkr�|jr�|jdtfS|jtfSq�|jdtfSnWd|j|�X|j|}|j	r|d}|dks�|dkr�|dd	!d
|d	}q�nk|j
rP|dd
kr�d|d |d	}q�n6|r�|jd
�}|dt|�t|�}n|S(Ni����tinvalidR�t+it-i����ii����t0R9(
R'R�RR�R�RR	RR�R�R�R�R)(R�Rtstrip_zerosR1terrR�texpsigntz((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt__call__Os4		
	
	!(t__name__t
__module__R5R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRLs	5cCs1||}|jd�}|t|�t|�S(NR�(R�R)(RRR�R�R�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR�ss
iRKcBseZd�Zd�ZRS(cCs�yTttttj|���tttj|����}dt|�d|_Wn'ttfk
rmnt	k
r}nXdS(NR�R&(
R�R)RDRRRR�R�R�t
ValueError(R�RlR�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR�|s
cCs3t|kotknr'|j|Sd|SdS(Ns%s(t_MININTt_MAXINTR�(R�R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s(R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRK{s	
RMcBseZed�Zd�ZRS(cCs||_||_dS(N(RR�(R�RR�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s	cCs�t|�r(|jrdtSdtSn�t|�rg|dkr\|jrQdtSdtSq�dtSnP|dkr�|jr�dt||j�Sdt||j�Snt||j�SdS(NR�R9iR�(RR�RR	RR
R(R�R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s			(R�R�R5R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRM�sROcBseZd�Zd�ZRS(cCs(t|�|_t|dt�|_dS(NR�(RMtreal_formatR�timag_format(R�R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��scCs0|j|j�}|j|j�}||dS(Ntj(R�trealR�timag(R�RtrR3((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s(R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRO�s	RNcBseZd�Zd�ZRS(cCs:t|j||�|_t|j||dt�|_dS(NR�(RLR�R�R�R�R�(R�RRRh((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��scCs�|j|jdt�}|j|jdt�}|jjsp|jd�}|ddt|�t|�}n
|d}||S(NR�R�R�R9(R�R�R5R�R�R�R�R)(R�RR�R3R�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s%
(R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRN�s	RPcBs#eZdddd�Zd�ZRS(t	same_kindcCs�|dkr=|jjdkr4t|j�d}q=d}n|dkrm|d	krad|_qvd|_n	||_||_||_dS(
NtMiR�tYtWtDtUTCtlocal(R�R�R�R�(RRXtkindRttimezonetunittcasting(R�RR�R�R�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s			c	Cs)dt|d|jd|jd|j�S(Ns'%s'R�R�R�(RR�R�R�(R�R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s		N(R�R�RR�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRP�sRQcBseZd�Zd�ZRS(cCsx|jjdkrt|jd�}ttttj|���tttj|����}dt|�d|_	ndS(Ntmti8R�R&(
RXR�tviewR�R)RDRRRR�(R�RltvR�((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s
cCs|j|jd�S(NR�(R�tastype(R�R((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR��s(R�R�R�R�(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRQ�s	(8t__doc__t__all__t
__docformat__tsystnumerictypesR[tumathRRRRRR	t
multiarrayR
RRtfromnumericR
RRRRR5RRRRRRtversion_infot	functoolsRRRR-R6R8RvRzR7RR�RetobjectRLR�tmaxintR�R�RKRMRORNRPRQ(((s;/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt<module>sX	.		y	#			a		o		Ch