2[c @`sdZddlmZmZmZddddddd d d g Zd Zdd lZdd lZej ddkryddl m Z Wqe k rddl m Z qXn8yddlm Z Wn!e k rddlm Z nXdd lZddlmZddlmZmZmZmZmZmZddlmZddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+ddlm,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2dd l3Z3dd l4Z4i dd6dd6dd6dd6e5d6d d!6d"d#6d$d%6d&d'6d d(6e5d)6Z7d d d d d d d d d d d d* Z8d d d d d d d d d d d+ Z9d,Z:e4j;d-Z<dbd.Z=d/Z>d0Z?d1Z@d2ZAd3ZBd4d5ZCeCd6d7d8ZDd d d d6d7ejEd d d d d d7d9 ZFd:ZGd;ZHd<ZId=eJfd>YZKd?eKfd@YZLdAeKfdBYZMd eNdCe5d d dDZOd eNeNdCe5d d dEZPdFeJfdGYZQdHeJfdIYZRdJeJfdKYZSdLeSfdMYZTdNeSfdOYZUdPeJfdQYZVdReVfdSYZWdTeVfdUYZXdVeJfdWYZYdXeJfdYYZZdZeZfd[YZ[d\Z\e.e/e0e1gZ]e^e-e_re]j`e-ne^e,e_r&e]j`e,nd]Zad^Zbd d d d_ZceCedZed d d d`ZfeNdaZgegefdegecdd S(csXArray printing function $Id: arrayprint.py,v 1.9 2005/09/13 13:58:44 teoliphant Exp $ i(tdivisiontabsolute_importtprint_functiont array2stringt array_strt array_reprtset_string_functiontset_printoptionstget_printoptionst printoptionstformat_float_positionaltformat_float_scientifictrestructuredtextNi(t get_identi(t numerictypes(tabsolutet not_equaltisnantisinftisfinitetisnat(t multiarray(tarraytdragon4_positionaltdragon4_scientifictdatetime_as_stringt datetime_datatdtypetndarraytset_legacy_print_mode(traveltany(t concatenatetasarrayterrstate(tlonglongtintctint_tfloat_tcomplex_tbool_tflexiblet edgeitemsit thresholdtmaxprect floatmodeit precisiontsuppressiKt linewidthtnantnanstrtinftinfstrt-tsignt formattertlegacyc C`sdtjD} |dk r8t|| dHs R/tfixedtuniqueR,t maxprec_equals floatmode option must be one of s, cs`s|]}dj|VqdS(s"{}"N(tformat(R:tm((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys PsR5t+t s+sign option must be one of ' ', '+', or '-'s1.13s>legacy printing option can currently only be '1.13' or `False`t stackleveliN(NR5RBRC( tlocalstitemsR9tboolt ValueErrortjointFalsetwarningstwarn( R.R+R*R0R/R2R4R6R7R-R8toptionstmodes((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_make_options_dictCs     c  K`s| jdd } | r@d} t| j| jdnt|||||||||| | } || d 1e3. The default is 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). sign : string, either '-', '+', or ' ', optional Controls printing of the sign of floating-point types. If '+', always print the sign of positive values. If ' ', always prints a space (whitespace character) in the sign position of positive values. If '-', omit the sign character of positive values. (default '-') 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' floatmode : str, optional Controls the interpretation of the `precision` option for floating-point types. Can take the following values: * 'fixed': Always print exactly `precision` fractional digits, even if this would print more or fewer digits than necessary to specify the value uniquely. * 'unique': Print the minimum number of fractional digits necessary to represent each value uniquely. Different elements may have a different number of digits. The value of the `precision` option is ignored. * 'maxprec': Print at most `precision` fractional digits, but if an element can be uniquely represented with fewer digits only print it with that many. * 'maxprec_equal': Print at most `precision` fractional digits, but if every element in the array can be uniquely represented with an equal number of fewer digits, use that many digits for all elements. legacy : string or `False`, optional If set to the string `'1.13'` enables 1.13 legacy printing mode. This approximates numpy 1.13 print output by including a space in the sign position of floats and different behavior for 0d arrays. If set to `False`, disables legacy mode. Unrecognized strings will be ignored with a warning for forward compatibility. .. versionadded:: 1.14.0 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) R8s7set_printoptions() got unexpected keyword argument '{}'iR7s1.13iqR5R6N( tpopR9t TypeErrorR@tpopitemROt_format_optionstupdateRRJ(R.R+R*R0R/R2R4R7R6R-tkwargR8tmsgtopt((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR[s"     cC`s tjS(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 - sign : str For a full description of these options, see `set_printoptions`. See Also -------- set_printoptions, set_string_function (RStcopy(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRsco`s@tj}ztj||tjVWdtj|XdS(sTContext manager for setting print options. Set print options for the scope of the `with` block, and restore the old options at the end. See `set_printoptions` for the full description of available options. Examples -------- >>> with np.printoptions(precision=2): ... print(np.array([2.0])) / 3 [0.67] The `as`-clause of the `with`-statement gives the current print options: >>> with np.printoptions(precision=2) as opts: ... assert_equal(opts, np.get_printoptions()) See Also -------- set_printoptions, get_printoptions N(tnpRR(targstkwargstopts((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR s  cC`st|}||jkr#||S|j|d|krtt|||tj| t|||tj| fd|St|||tjSdS(s Keep only the N-D corners (leading and trailing edges) of an array. Should be passed a base-class ndarray, since it makes no guarantees about preserving subclasses. itaxisN(tlentndimtshapeR t_leading_trailingRYt index_exp(taR*tindexR]((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRa:s !cC`s.t|tkrd}nd}|j|S(s@ Object arrays containing lists should be printed unambiguously s list({!r})s{!r}(ttypetlistR@(totfmt((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_object_formatNs cC`s t|S(N(trepr(tx((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt repr_formatVscC`s t|S(N(tstr(Rk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt str_formatYsc `s|d|d|d|d|di fdd6fdd 6fd d 6fd d 6fdd6fdd6fdd6fdd6dd6dd6dd6dd6}d}|d}|dk rg|jD]}||dk rM|^qM}d |krx+|jD]}||d ||csRGc`s tS(N(t IntegerFormat((Rp(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqdstintc`stdS(NR8(tFloatingFormat((RptfmodeR8tprecR6tsupp(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqestfloatc`stdS(NR8(Rt((RpRuR8RvR6Rw(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqgst longfloatc`stdS(NR8(tComplexFloatingFormat((RpRuR8RvR6Rw(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqist complexfloatc`stdS(NR8(Rz((RpRuR8RvR6Rw(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqkstlongcomplexfloatc`stdS(NR8(tDatetimeFormat((RpR8(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqmstdatetimec`s tS(N(tTimedeltaFormat((Rp(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqnst timedeltacS`stS(N(Ri(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqostobjectcS`stS(N(Rn(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqpstvoidcS`stS(N(Rl(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqqstnumpystrcS`stS(N(Rm(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqrsRmc`s fdS(Nc`sS(N(((Rk(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRqws((Rk((Rks4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pytindirectvsR7talltint_kindt float_kindt complex_kindtstr_kind(R9tkeys(RpRWt formatdictRR7R;tfkeystkey((RpRuR8RvR6Rws4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_get_formatdict\sN        /      cK`s|j}|j}t||}t|tjr>|dSt|tjr{t|tjrm|dS|dSn$t|tjrt|tj r|dS|dSnt|tj rt|tj r|dS|dSnt|tj tj fr|dSt|tjr8|d St|tjrU|d St|tjr|jd k rtj||S|d Sn |dSd S( s; find the right formatting function for the dtype_ RGRRsRyRxR|R{RR~RRN(RReRt issubclasst_ntR(tintegert timedelta64tfloatingRytcomplexfloatingt clongfloattunicode_tstring_t datetime64tobject_RtnamesR9tStructuredVoidFormatt from_data(RpRMtdtype_tdtypeobjR((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_get_format_functions8         s...c`sfd}|S(s  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 c`s1ttjfd}|S(Nc`s[t|tf}|kr%Sj|z|||SWdj|XdS(N(tidR taddtdiscard(tselfRZR[R(tft fillvaluet repr_running(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pytwrappers  (tsett functoolstwraps(RR(R(RRs4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pytdecorating_functions $ ((RR((Rs4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_recursive_guards RCtc C`st|}|jdkr$|}n|j|dkrSd}t||d}nd}t||}d}|dt|7}t|||d|||d||d}|S( NR+s...R*RRCR0R8((R!R`tsizeRaRR^t _formatArray( RcRMt separatortprefixRptsummary_inserttformat_functiontnext_line_prefixtlst((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt _array2strings   c  K`sQ| jdd }| r@d}t|j| jdnt||| ||d d | || | }tj}|j||ddkr|t j krt }n|j d kr|j j r||jSn(|t j k rtjdtddn|ddkr+|dct| 8d St||||S( s Return a string representation of an array. Parameters ---------- a : array_like 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 or None, 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 suffix: str, optional The length of the prefix and suffix strings are used to respectively align and wrap the output. An array is typically printed as:: prefix + array2string(a) + suffix The output is left-padded by the length of the prefix string, and wrapping is forced at the column ``max_line_width - len(suffix)``. style : _NoValue, optional Has no effect, do not use. .. deprecated:: 1.14.0 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 - 'void' : type `numpy.void` - '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' threshold : int, optional Total number of array elements which trigger summarization rather than full repr. edgeitems : int, optional Number of array items in summary at beginning and end of each dimension. sign : string, either '-', '+', or ' ', optional Controls printing of the sign of floating-point types. If '+', always print the sign of positive values. If ' ', always prints a space (whitespace character) in the sign position of positive values. If '-', omit the sign character of positive values. floatmode : str, optional Controls the interpretation of the `precision` option for floating-point types. Can take the following values: - 'fixed': Always print exactly `precision` fractional digits, even if this would print more or fewer digits than necessary to specify the value uniquely. - 'unique': Print the minimum number of fractional digits necessary to represent each value uniquely. Different elements may have a different number of digits. The value of the `precision` option is ignored. - 'maxprec': Print at most `precision` fractional digits, but if an element can be uniquely represented with fewer digits only print it with that many. - 'maxprec_equal': Print at most `precision` fractional digits, but if every element in the array can be uniquely represented with an equal number of fewer digits, use that many digits for all elements. legacy : string or `False`, optional If set to the string `'1.13'` enables 1.13 legacy printing mode. This approximates numpy 1.13 print output by including a space in the sign position of floats and different behavior for 0d arrays. If set to `False`, disables legacy mode. Unrecognized strings will be ignored with a warning for forward compatibility. .. versionadded:: 1.14.0 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]' R8s3array2string() got unexpected keyword argument '{}'is1.13sT'style' argument is deprecated and no longer functional except in 1.13 'legacy' modeRDiR0s[]N((RPR9RQR@RRRORSRXRTRYt_NoValueRjR`RRtitemRKRLtDeprecationWarningR^RR(Rctmax_line_widthR.tsuppress_smallRRtstyleR7R+R*R6R-tsuffixRUR8RVt overridesRM((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs,"      cC`st|t||k}|dkrP|t|t|krPt}qPn|rs||jd7}|}n||7}||fS(Ns1.13s (R^RJtrstrip(tstlinetwordt line_widthRR8t needs_wrap((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt _extendLines    c`sLfdzddd|d|SWddXdS(sgformatArray is designed for two modes of operation: 1. Full output 2. Summarized output c`st|}j|}|dkr3|S|d}dkrR|}n|td}j|}od|k}|r} } n d} |} d} |dkrkdkr|tj} n%|ttjtd} |} xXt| D]J}||f||}t| | || |\} } | 7} qW|rt| | | |\} } dkr| d7} q| 7} nx_t| dd D]K}|| f||}t| | || |\} } | 7} qWdkr'|} n|d ||}t| | || |\} } | | 7} n d} jd |d}x?t| D]1}||f||}| |||7} qW|rdkr| |d 7} q| ||7} nxFt| dd D]2}|| f||}| |||7} qW|d||}| ||7} d | t|d} | S(s By using this local function, we don't need to recurse with all the arguments. Since this function is not created recursively, the cost is not significant iRCs1.13t]iRis, is s, t[(i(i(R^R_R`RtmaxtrangeR(Rdthanging_indentt curr_widthR]t axes_lefttnext_hanging_indentt next_widthta_lent show_summaryt leading_itemsttrailing_itemsRt elem_widthRtiRtline_septnested(Rct edge_itemsRR8trecurserRR(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRsx          %        RdRRN((R9(RcRRRRRRR8((RcRRR8RRRs4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs !b  cC`s8|dkrdS|dkr4tdj|n|S(Niis{} must be >= 0(R9RHR@(Rktname((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_none_or_positive_arg#s   RtcB`s,eZdZedZdZdZRS(s' Formatter for subtypes of np.floating cK`st|tr$|rdnd}n|jdt|_|jdkro|jdkro|dkrod}qon||_|dkrd|_n ||_t |jd|_||_ ||_ t|_ t|_ |j|dS( NRBR5R8s1.13RCR>R.((t isinstanceRGtgetRJt_legacyR`R-R9R.RRR6t exp_formattlarge_exponentt fillFormat(RRpR.R-RR6RU((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt__init__,s          c`s|t|}t||dk}t|dkrtj|}tj|}tddC|dksj r|dks||dkrt_ nWdQXnt|dkrd_ d_ d_ d_ t_nAj r dtjd ks#jd kr3d tnfd |D}td |D\}}} td|D\} } td| Dd_ d _ td| D_jd krd_ ntd| D_ j dj_ t_ndtjd krLd tnfd|D}td|D\} } jd krdtd| D_ ntd| D_ td| D_ d_ jdkrj _t_d _ nt_d_ jd kryjdkryttj| ryj d7_ qyn|j|jkr jdkpt|t|dk} ttd} ttd| }j d}tj | |||_ ndS( NitovertignoregחAg-C6?g@@t.iR=s1.13R;c 3`s?|]5}t|djdddjdkVqdS(R.R>ttrimR6RBN(RR.R6(R:Rk(RRR>(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys `scs`s|]}|jdVqdS(teN(t partition(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys cscs`s|]}|jdVqdS(RN(tsplit(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys dscs`s|]}t|VqdS(N(R^(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys esics`s|]}t|VqdS(N(R^(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys hsics`s|]}t|VqdS(N(R^(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys osic3`sE|];}t|djdtdddjdkVqdS(R.t fractionalR>RR6RBN(RR.tTrueR6(R:Rk(RRR>(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys yscs`s|]}|jdVqdS(RN(R(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys ~scs`s$|]}t|jdVqdS(s-+N(R^tlstrip(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys scs`s|]}t|VqdS(N(R^(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys scs`s|]}t|VqdS(N(R^(R:R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys sR?RCR5R2R4(R=R?(RRR^RYRtminR"RRRtpad_leftt pad_rightRtexp_sizeR>R-RRJtzipR.R6RtsignbitRRRS(RRpt finite_valst abs_non_zerotmax_valtmin_valtstrst frac_strst_texp_strstint_partt frac_parttneginftnanlentinflentoffset((RRR>s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRGsr                    %+ cC`satj|stddtj|rZ|jdkrCdnd}|td}n;|dkrldn|jdkrdnd}|td}d |j|jd t||SWdQXn|j rt |d |j d |j d |j d|jdkd|jd|jSt|d |j d |j dtd |j d|jdkd|jd|jSdS(NtinvalidRRBRR2iR5R4RCiR.R>RR6Rt exp_digitsRR(RYRR"RR6RSRRR^RRR.R>RRRR(RRkR6tret((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt__call__s0--            (t__name__t __module__t__doc__RJRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRt*s  Tt FloatFormatcB`seZdZRS(cO`s3tjdtddtt|j||dS(Ns/FloatFormat has been replaced by FloatingFormatRDi(RKRLRtsuperRR(RRZR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs  (RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRstLongFloatFormatcB`seZdZRS(cO`s3tjdtddtt|j||dS(Ns3LongFloatFormat has been replaced by FloatingFormatRDi(RKRLRRR R(RRZR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs  (RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR sR;cC`s[t|d}t|d}t|d}t|d|d|d|d|d|d|S(s Format a floating-point scalar as a decimal string in scientific notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm. Parameters ---------- x : python float or numpy floating scalar Value to format. precision : non-negative integer or None, optional Maximum number of digits to print. May be None if `unique` is `True`, but must be an integer if unique is `False`. unique : boolean, optional If `True`, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If `precision` was omitted, print all necessary digits, otherwise digit generation is cut off after `precision` digits and the remaining value is rounded. If `False`, digits are generated as if printing an infinite-precision value and stopping after `precision` digits, rounding the remaining value. trim : one of 'k', '.', '0', '-', optional Controls post-processing trimming of trailing digits, as follows: * 'k' : keep trailing zeros, keep decimal point (no trimming) * '.' : trim all trailing zeros, leave decimal point * '0' : trim all but the zero before the decimal point. Insert the zero if it is missing. * '-' : trim trailing zeros and any trailing decimal point sign : boolean, optional Whether to show the sign for positive values. pad_left : non-negative integer, optional Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point. exp_digits : non-negative integer, optional Pad the exponent with zeros until it contains at least this many digits. If omitted, the exponent will be at least 2 digits. Returns ------- rep : string The string representation of the floating point value See Also -------- format_float_positional Examples -------- >>> np.format_float_scientific(np.float32(np.pi)) '3.1415927e+00' >>> s = np.float32(1.23e24) >>> np.format_float_scientific(s, unique=False, precision=15) '1.230000071797338e+24' >>> np.format_float_scientific(s, exp_digits=4) '1.23e+0024' R.RRR>RR6(RR(RkR.R>RR6RR((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR s <cC`sat|d}t|d}t|d}t|d|d|d|d|d|d|d|S(s Format a floating-point scalar as a decimal string in positional notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm. Parameters ---------- x : python float or numpy floating scalar Value to format. precision : non-negative integer or None, optional Maximum number of digits to print. May be None if `unique` is `True`, but must be an integer if unique is `False`. unique : boolean, optional If `True`, use a digit-generation strategy which gives the shortest representation which uniquely identifies the floating-point number from other values of the same type, by judicious rounding. If `precision` was omitted, print out all necessary digits, otherwise digit generation is cut off after `precision` digits and the remaining value is rounded. If `False`, digits are generated as if printing an infinite-precision value and stopping after `precision` digits, rounding the remaining value. fractional : boolean, optional If `True`, the cutoff of `precision` digits refers to the total number of digits after the decimal point, including leading zeros. If `False`, `precision` refers to the total number of significant digits, before or after the decimal point, ignoring leading zeros. trim : one of 'k', '.', '0', '-', optional Controls post-processing trimming of trailing digits, as follows: * 'k' : keep trailing zeros, keep decimal point (no trimming) * '.' : trim all trailing zeros, leave decimal point * '0' : trim all but the zero before the decimal point. Insert the zero if it is missing. * '-' : trim trailing zeros and any trailing decimal point sign : boolean, optional Whether to show the sign for positive values. pad_left : non-negative integer, optional Pad the left side of the string with whitespace until at least that many characters are to the left of the decimal point. pad_right : non-negative integer, optional Pad the right side of the string with whitespace until at least that many characters are to the right of the decimal point. Returns ------- rep : string The string representation of the floating point value See Also -------- format_float_scientific Examples -------- >>> np.format_float_positional(np.float32(np.pi)) '3.1415927' >>> np.format_float_positional(np.float16(np.pi)) '3.14' >>> np.format_float_positional(np.float16(0.3)) '0.3' >>> np.format_float_positional(np.float16(0.3), unique=False, precision=10) '0.3000488281' R.RRR>RRR6(RR(RkR.R>RRR6RR((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR sC  RrcB`seZdZdZRS(cC`sg|jdkrKttttj|tttj|}nd}dj||_dS(Nis%{}d(RRR^RmRYRR@(RRpt max_str_len((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRVs !cC`s |j|S(N(R@(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR^s(RRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRrUs RocB`seZdZdZRS(cK`s"|jdkrdnd|_dS(Ns TrueR((R`ttruestr(RRpR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRcscC`s|r |jSdS(NRJ(R (RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRhs(RRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRobs RzcB`s#eZdZedZdZRS(s. Formatter for subtypes of np.complexfloating c K`st|tr$|rdnd}n|}}|jdtdkrUd}d}nt|j|||d|||_t|j|||dd||_dS(NRBR5R8s1.13R?R,R6( RRGRRJRttrealt real_formattimagt imag_format( RRkR.R-RR6RUtfloatmode_realtfloatmode_imag((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRns  cC`sT|j|j}|j|j}t|j}|| d||}||S(Ntj(R R RRR^R(RRktrRtsp((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR~s (RRRRJRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRzls t ComplexFormatcB`seZdZRS(cO`s3tjdtddtt|j||dS(Ns8ComplexFormat has been replaced by ComplexFloatingFormatRDi(RKRLRRRR(RRZR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs (RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRstLongComplexFormatcB`seZdZRS(cO`s3tjdtddtt|j||dS(Ns<LongComplexFormat has been replaced by ComplexFloatingFormatRDi(RKRLRRRR(RRZR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs (RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRst_TimelikeFormatcB`s#eZdZdZdZRS(cC`s|t|}t|dkrett|jtj|t|jtj|}nd}t||jkrt|d}ndj||_dj ||_ dS(Niis%{}ss'NaT'( RR^Rt_format_non_natRYRRR@t_formattrjustt_nat(RRptnon_natR ((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs$cC`s tdS(N(tNotImplementedError(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRscC`s+t|r|jS|j|j|SdS(N(RRRR(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs (RRRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs  R}cB`s/eZdddedZdZdZRS(t same_kindcC`s|dkr=|jjdkr4t|jd}q=d}n|dkrRd}n||_||_||_||_tt |j |dS(NtMiRtnaive( R9RtkindRttimezonetunittcastingR8RR}R(RRkR#R"R$R8((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs        cC`s2|jdkr|j|Stt|j|S(Ns1.13(R8RRR}R(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs c C`s)dt|d|jd|jd|jS(Ns'%s'R#R"R$(RR#R"R$(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs   N(RRR9RJRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR}s   RcB`seZdZRS(cC`st|jdS(Nti8(Rmtastype(RRk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs(RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRstSubArrayFormatcB`seZdZdZRS(cC`s ||_dS(N(R(RR((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRsc`sY|jdkr4ddjfd|DdSddjfd|DdS(NiRs, c3`s|]}j|VqdS(N(R(R:Rc(R(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys sRc3`s|]}j|VqdS(N(R(R:Rc(R(s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pys s(R_RI(Rtarr((Rs4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs%(RRRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR's RcB`s/eZdZdZedZdZRS(s Formatter for structured np.void objects. This does not work on structured alias types like np.dtype(('i4', 'i2,i2')), as alias scalars lose their field information, and the implementation relies upon np.void.__getitem__. cC`s ||_dS(N(tformat_functions(RR)((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRscK`slg}xY|jjD]K}t|||}|j|jdkrQt|}n|j|qW||S(s This is a second way to initialize StructuredVoidFormat, using the raw data as input. Added to avoid changing the signature of __init__. ((RRRR`R'tappend(tclsRpRMR)t field_nameR((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRscC`sngt||jD]\}}||^q}t|dkrTdj|dSdjdj|SdS(Nis({},)is({})s, (RR)R^R@RI(RRktfieldRt str_fields((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs .(RRRRt classmethodRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs tStructureFormatcB`seZdZRS(cO`s3tjdtddtt|j||dS(Ns9StructureFormat has been replaced by StructuredVoidFormatRDi(RKRLRRR0R(RRZR[((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs (RRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR0scC`stjt|t|S(s Implements the repr for structured-void scalars. It is called from the scalartypes.c.src code, and is placed here because it uses the elementwise formatters defined above. (RRRRS(Rk((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyt_void_scalar_reprscC`sRtj|}tddkr2|jtkr2tS|jdk rEtS|jtkS(s" Determine if the given dtype is implied by the representation of its values. Parameters ---------- dtype : dtype Data type Returns ------- implied : bool True if the dtype is implied by the representation of its values. Examples -------- >>> np.core.arrayprint.dtype_is_implied(int) True >>> np.array([1, 2, 3], int) array([1, 2, 3]) >>> np.core.arrayprint.dtype_is_implied(np.int8) False >>> np.array([1, 2, 3], np.int8) array([1, 2, 3], dtype=np.int8) R8s1.13N( RYRRSReR(RJRR9t _typelessdata(R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pytdtype_is_implieds cC`sx|jdk rt|St|jtr9dt|S|j}|rt|djoa|j rtt |}n|S(s Convert a dtype to a short form which evaluates to the same dtype. The intent is roughly that the following holds >>> from numpy import * >>> assert eval(dtype_short_repr(dt)) == dt s'%s'iN( RR9RmRReR)RtisalphatisalnumRj(Rttypename((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pytdtype_short_reprCs   #c C`s|dkrtd}nt|tk r=t|j}nd}t|jo^|jdk}|d}|rwdnd}tddkr|jdkr|jj rt |j }nX|jdks|jdkrt ||||d |d |}nd t |jf}|||} |r.| Sd j t|j} t| | jd d} d} tddkrt|jjtrd dt|d} qn5| t| d|krd dt|d} n| | | S(s Return the string representation of an array. Parameters ---------- arr : ndarray Input array. max_line_width : int, optional The maximum number of columns the string should span. Newline characters split 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, default is False. Very small is defined by `precision`, if the precision is 8 then numbers smaller than 5e-9 are represented as zero. Returns ------- string : str The string representation of an array. See Also -------- array_str, array2string, set_printoptions Examples -------- >>> np.array_repr(np.array([1,2])) 'array([1, 2])' >>> np.array_repr(np.ma.array([0.])) 'MaskedArray([ 0.])' >>> np.array_repr(np.array([], np.int32)) 'array([], dtype=int32)' >>> x = np.array([1e-6, 4e-7, 2, 3]) >>> np.array_repr(x, precision=6, suppress_small=True) 'array([ 0.000001, 0. , 2. , 3. ])' R0Rit(t)t,R8s1.13s, Rs [], shape=%ss dtype={})s iRCN((i(R9RSReRRR3RRR`RRjRRR@R7R^trfindRR)( R(RR.Rt class_namet skipdtypeRRRtarr_strt dtype_strt last_line_lentspacer((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyR[s6*   cC`s}tddkr<|jdkr<|jj r<t|jS|jdkrdttjj |dSt ||||ddS(s= Return a string representation of the data in an array. The data in the array is returned as a single string. This function is similar to `array_repr`, the difference being that `array_repr` also returns information on the kind of array and its data type. Parameters ---------- a : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. The default is, indirectly, 75. 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 numbers "very close" to zero as zero; default is False. Very close is defined by precision: if the precision is 8, e.g., numbers smaller (in absolute value) than 5e-9 are represented as zero. See Also -------- array2string, array_repr, set_printoptions Examples -------- >>> np.array_str(np.arange(3)) '[0 1 2]' R8s1.13RCR(((( RSR`RRRmRt _guarded_strRYRt __getitem__R(RcRR.R((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs "cC`sI|dkr5|r"tjtdStjtdSntj||SdS(s  Set a Python function to be used when pretty printing arrays. Parameters ---------- f : function or None Function to be used to pretty print arrays. The function should expect a single array argument and return a string of the representation of the array. If None, the function is reset to the default NumPy function to print arrays. repr : bool, optional If True (default), the function for pretty printing (``__repr__``) is set, if False the function that returns the default string representation (``__str__``) is set. See Also -------- set_printoptions, get_printoptions Examples -------- >>> def pprint(arr): ... return 'HA! - What are you going to do now?' ... >>> np.set_string_function(pprint) >>> a = np.arange(10) >>> a HA! - What are you going to do now? >>> print(a) [0 1 2 3 4 5 6 7 8 9] We can reset the function to the default: >>> np.set_string_function(None) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) `repr` affects either pretty printing or normal string representation. Note that ``__repr__`` is still affected by setting ``__str__`` because the width of each array element in the returned string becomes equal to the length of the result of ``__str__()``. >>> x = np.arange(4) >>> np.set_string_function(lambda x:'random', repr=False) >>> x.__str__() 'random' >>> x.__repr__() 'array([ 0, 1, 2, 3])' iiN(R9RRRR(RRj((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyRs 3 ((hRt __future__RRRt__all__t __docformat__tsysRt version_infot_threadR t ImportErrort _dummy_threadtthreadt dummy_threadtnumpyRYRRRtumathRRRRRRRRRRRRRRRt fromnumericRRtnumericR R!R"R#R$R%R&R'R(R)RKt contextlibRJR9RSRORRtcontextmanagerR RaRiRlRnRRRRRRRRRRRtRR RR R RrRoRzRRRR}RR'RR0R1R2RRsR*R3R7RRmRBRR(((s4/tmp/pip-build-fiC0ax/numpy/numpy/core/arrayprint.pyts        .:4        !     5 '     v  B J    %  $ T1 ;