• File: arrayprint.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyc
  • Date Modified: 12/19/2017 2:16 PM
  • File size: 23.4 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

9Zc	@`sdZddlmZmZmZdddgZdZddlZddlm	Z	d	d
l
mZd	dl
mZmZmZmZmZmZd	dlmZmZmZmZd	d
lmZd	dlmZejddkrejZejd	Z nej!Zej!d	Z dZ"da#da$da%e&a'da(da)da*da,dddddddddZ-dZ.dZ/dZ0dZ1ddddZ2dZ3ddddde4ddZ5d Z6d!Z7d"e8fd#YZ9d$Z:d%e8fd&YZ;d'e8fd(YZ<d)e8fd*YZ=d+e8fd,YZ>d-e8fd.YZ?d/e8fd0YZ@dS(1sXArray printing function

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

i(tdivisiontabsolute_importtprint_functiontarray2stringtset_printoptionstget_printoptionstrestructuredtextN(treducei(tnumerictypes(tmaximumtminimumtabsolutet	not_equaltisnantisinf(tarraytformat_longfloattdatetime_as_stringt
datetime_data(travel(tasarrayicC`s||S(N((txty((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pytproduct"siiiKtnantinfcC`s|dk	r|an|dk	r*|an|dk	r?|an|dk	rT|an|dk	rk|an|dk	r|an|dk	r|an|adS(sv

    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((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR0sm						cC`s=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

    R#R$R%R&R'R(R)R*(	tdictRRRRRR R!R"(td((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs	cC`sAddlm}|jdkr_t|dtkrV|j|t |tf}q=|}nt|dtkrgttt|tD]}t||^q}|j	gttt|tddD]}t||^qn2gtdt|D]}t||^q}|jt
|}|S(Ni(tnumericiii(tR-tndimtlenRtconcatenatetrangetmint_leading_trailingtextendttuple(tat_nctbtitl((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR4s
	2=2cC`s|r
dSdSdS(Ns TruetFalse((R((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt_boolFormatterscC`s
t|S(N(trepr(R((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pytrepr_formatst R.c	C`s|dkrt}n|dkr*t}n|dkr?t}n|dkrTt}n|jtkrxd}t|}nd}tt	|}i
t
d6t|d6t|||d6t
|d6t|||d6t|d6t|d	6t|d
6td6td6}	|dk	rg|jD]}
||
dk	r+|
^q+}d
|krx%|	jD]}|d
|	|<qfWnd|krx"dgD]}|d|	|<qWnd|krx%ddgD]}|d|	|<qWnd|krx%ddgD]}|d|	|<qWnd|krNx%ddgD]}|d|	|<q3Wnx4|	jD]#}||kr[|||	|<q[q[Wn|jj}
t|
tjr|	d}nt|
tjrt|
tjr|	d
}q|	d}nt|
tjr,t|
tjr|	d}q|	d}nt|
tjrjt|
tjr]|	d}q|	d}nQt|
tj tj!fr|	d}n)t|
tj"r|	d	}n
|	d}d}|dt#|7}t$||t#|j%|||t&|d }|S(Ns..., R.tbooltinttfloatt	longfloattcomplexfloattlongcomplexfloattdatetimet	timedeltatnumpystrtstrtalltint_kindt
float_kindtcomplex_kindtstr_kindR@i('RRRRR"tsizeRR4RRR=t
IntegerFormattFloatFormattLongFloatFormatt
ComplexFormattLongComplexFormattDatetimeFormattTimedeltaFormatR?RJtkeystdtypettypet
issubclasst_nttbool_tintegerttimedelta64tfloatingRDtcomplexfloatingt
clongfloattunicode_tstring_t
datetime64R0t_formatArraytshapeR(R7tmax_line_widthR#tsuppress_smallt	separatortprefixR*tsummary_inserttdatat
formatdicttktfkeystkeytdtypeobjtformat_functiontnext_line_prefixtlst((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt
_array2strings				


	




/









cC`s}ddlm}g}xZ|D]R}t||jrD|j}nt|trbt|}n|j|qWt|S(Ni(R-(R.R-t
isinstancetndarrayttolistR6t_convert_arraystappend(tobjR8tnewtupRo((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRzHs
c
	C`s|jdkrH|j}t|tr9t|}n||}	nBtt|jdkrid}	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.

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

    is[]R*((RgtitemRwR6RzRRRv(
R7RhR#RiRjRktstyleR*RRu((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRTsa	cC`sYt|jt|j|krE||jd7}|}n||7}||fS(Ns
(R0trstrip(tstlinetwordtmax_line_lenRt((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt_extendLines
(	
cC`sd|dkr@|j}t|tr6t|}nt|S|rqd|t|krq|}	|}
|}nd}	t|}
d}|dkrd}|}
xFt|	D]8}||||}t||
|||\}}
qW|rt||
|||\}}
nxMt|
ddD]9}||||}t||
|||\}}
q$W||d}t||
|||\}}
||
d7}d|t|}nd}|j}xt|	D]{}|dkr||7}n|t	||||d|d||||7}|j|jd	t
|dd}qW|rm|||d	7}nxt|
ddD]}|	s||
kr||7}n|t	||||d|d||||7}|j|jd	t
|dd}qW|	s|
dkr%||7}n|t	|d||d|d||||jd7}|S(
sgformatArray is designed for two modes of operation:

    1. Full output

    2. Summarized output

    iiR.iis]
t[R@s
(R~RwR6RzRJR0R2RRRftmax(R7RstrankRRtRjt
edge_itemsRlR|t
leading_itemsttrailing_itemstsummary_insert1RRR:Rtsep((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRfsf	
	"!"


/


/

RRcB`s)eZedZdZedZRS(cC`se||_||_||_t|_t|_d|_y|j|Wntt	fk
r`nXdS(Ni(
R#RitsignR<t
exp_formattlarge_exponenttmax_str_lent
fillFormatt	TypeErrortNotImplementedError(tselfRmR#RiR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt__init__s						cC`sddlm}|jddt|t|B}t|d|@}t|j|}t|dkrd}d}nht	j
|}tj
|}|dkrt|_
n|jr|dks||d	krt|_
nWdQX|j
rd|kod
knp|dk|_d|j|_|jrP|jd7_n|jrbd
}nd}|d|j|jf}nd|jf}t|rtg|D]}	t|	|j|^q}
nd}
t|j|
}
ttt||
d|_|j|rGt|jttttd|_n|jrYd}nd}|d|j|
f}d|jf|_||_dS(Ni(R-RKtignoreiggחAg-C6?g@@g>N}a+g}Ô%ITis%+t%s%d.%des%%.%dfis%#+s%#s%d.%dfs%%%ds(R.R-terrstateR
RRRtcompressR0R	RR
tTrueRRiRR#RRRt_digitsR3RJRBtanyR R!tspecial_fmttformat(RRmR8tspecialtvalidtnon_zerotmax_valtmin_valRRR#((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRsR		+			+#				cC`sddlm}|jddt|r[|jrJ|jdtfS|jtfSnYt|r|dkr|jr|jdtfS|jtfSq|jdtfSnWdQX|j	|}|j
r|d}|dks|dkr||dd	!d
|d	}q|nk|jrF|dd
kr|d|d |d	}q|n6|r||jd
}|dt
|t
|}n|S(Ni(R-tinvalidRt+it-iit0R@(R.R-RR
RRR RR!RRRRR0(RRtstrip_zerosR8Rtexpsigntz((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt__call__Rs0		
	
	!(t__name__t
__module__R<RRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRRs	3cC`s1||}|jd}|t|t|S(NR(RR0(RR#RRR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRts
RQcB`seZdZdZRS(cC`syTttttj|tttj|}dt|d|_Wn'ttfk
rmnt	k
r}nXdS(NRR,(
RR0RJR	RR
RRRt
ValueError(RRmR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyR{s
cC`s3t|kotknr'|j|Sd|SdS(Ns%s(t_MININTt_MAXINTR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs(RRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRQzs	
RScB`seZedZdZRS(cC`s||_||_dS(N(R#R(RR#R((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs	cC`st|r(|jrdtSdtSnt|rg|dkr\|jrQdtSdtSqdtSnP|dkr|jrdt||jSdt||jSnt||jSdS(NRR@iR(R
RR RR!RR#(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs			(RRR<RR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRSsRUcB`seZdZdZRS(cC`s(t||_t|dt|_dS(NR(RStreal_formatRtimag_format(RR#((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRscC`s0|j|j}|j|j}||dS(Ntj(RtrealRtimag(RRtrR:((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs(RRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRUs	RTcB`seZdZdZRS(cC`s:t|j|||_t|j||dt|_dS(NR(RRRRRRR(RRR#Ri((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRscC`s|j|jdt}|j|jdt}|jjsp|jd}|ddt|t|}n
|d}||S(NRRRR@(RRR<RRRRR0(RRRR:R((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs%
(RRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRTs	RVcB`s#eZddddZdZRS(t	same_kindcC`sq|dkr=|jjdkr4t|jd}q=d}n|dkrRd}n||_||_||_dS(NtMiRtnaive(RRYtkindRttimezonetunittcasting(RRRRR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs				c	C`s)dt|d|jd|jd|jS(Ns'%s'RRR(RRRR(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs		N(RRRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRVsRWcB`seZdZdZRS(cC`s|jjdkrtdgd|jd}|t||jd}t|dkrttttj	|ttt
j	|}nd}t|t|krt|d}ndt|d|_d	j||_
ndS(
NtmtNaTRYiti8iRR,s'NaT'(RYRRRtviewR0RRJR	RR
Rtrjustt_nat(RRmt	nat_valuetvR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs!cC`s/|d|kr|jS|j|jdSdS(NiR(RRtastype(RR((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRs(RRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyRWs	(At__doc__t
__future__RRRt__all__t
__docformat__tsyst	functoolsRR.RR\tumathR	R
RRR
Rt
multiarrayRRRRtfromnumericRR-Rtversion_infotmaxsizeRRtmaxintRRRRR<RRR R!RR"RRR4R=R?RvRzR>RRRftobjectRRRRQRSRURTRVRW(((sH/opt/alt/python27/lib64/python2.7/site-packages/numpy/core/arrayprint.pyt<module>s`	."				z	#			Z		l		Fd