bgx hdZgdZdZddlZddlZddlZ ddlmZn#e$r ddl mZYnwxYwddl Z ddl m ZddlmZmZmZmZdd l mZdd lmZmZmZmZmZmZmZdd lmZdd lmZm Z m!Z!dd l m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+ddl,Z,ddl-Z-ddl.Z.ddddddddddej/d Z0 dVdZ1e+d dWdddZ2e+ddZ3dZ4e+de.j5dZ6dXd!Z7d"Z8d#Z9d$Z:d%Z;d&Z d[ddd,Z?e*e?d-dddd)d*e j@dddddd*f ddd.ZAd/ZBd0ZCd1ZDd2ZEGd3d4ZFe+d d\d7ZGe+d d]d8ZHGd9d:ZIGd;d<ZJGd=d>ZKGd?d@ZLGdAdBeLZMGdCdDeLZNGdEdFZOGdGdHZPdIZQe$e%e&e'gZRdJZSdKZTdddeAfdLZU d^dMZVe*eVd-d^dNZWe=dOZXdddeAfdPZY d^dQZZe*eZd-d^dRZ[e\eAdSeAZ]ej^eYe]TZ_ej^eUe]TZ`d_dUZadS)`zXArray printing function $Id: arrayprint.py,v 1.9 2005/09/13 13:58:44 teoliphant Exp $ ) array2string array_str array_reprset_string_functionset_printoptionsget_printoptions printoptionsformat_float_positionalformat_float_scientificrestructuredtextN) get_ident) numerictypes)absoluteisinfisfiniteisnat) multiarray)arraydragon4_positionaldragon4_scientificdatetime_as_string datetime_datandarrayset_legacy_print_mode)any) concatenateasarrayerrstate)longlongintcint_float_complex_bool_flexible)array_function_dispatch set_moduleimaxprecFKnaninf-) edgeitems threshold floatmode precisionsuppress linewidthnanstrinfstrsign formatterlegacyc dtD} |t|| d<gd} | | dgzvr/tddd| Dz|dvrtd | d krt j| d <n1| d krd | d <n%| dkrd| d <n| ntjdd|Lt|tj stdtj|rtd|; tj|| d<n"#t$r} td| d} ~ wwxYw| S)zm Make a dictionary out of the non-None arguments, plus conversion of *legacy* and sanity checks. ci|] \}}||| SN).0kvs L/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/arrayprint.py z&_make_options_dict..HsBBB1AMq!MMMNr4)fixeduniquer* maxprec_equalz floatmode option must be one of , c3@K|]}d|VdS)z"{}"Nformat)r?ms rB z%_make_options_dict..Ps."C"C6==#3#3"C"C"C"C"C"CrD)Nr/+ z+sign option must be one of ' ', '+', or '-'Fr:1.13q1.21yzGlegacy printing option can currently only be '1.13', '1.21', or `False`r) stacklevelzthreshold must be numericzIthreshold must be non-NAN, try sys.maxsize for untruncated representationr3zprecision must be an integer)localsitemsbool ValueErrorjoinsysmaxsizewarningswarn isinstancenumbersNumber TypeErrornpisnanoperatorindex)r3r1r0r5r4r6r7r8r9r2r:optionsmodeses rB_make_options_dictrj@sCB 0 0BBBG"8nn  ; ; ;E&&;"C"CU"C"C"CCCDEE E (((FGGG K 6   6      "# % % % %)W^44 9788 8 8I   KJKK K C#+>)#<# 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.bytes_` and `numpy.str_` - 'object' : `np.object_` arrays 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 'numpystr' floatmode : str, optional Controls the interpretation of the `precision` option for floating-point types. Can take the following values (default maxprec_equal): * '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. This also enables 1.21 legacy printing mode (described below). If set to the string `'1.21'` enables 1.21 legacy printing mode. This approximates numpy 1.21 print output of complex structured dtypes by not inserting spaces after commas that separate fields and after colons. If set to `False`, disables legacy mode. Unrecognized strings will be ignored with a warning for forward compatibility. .. versionadded:: 1.14.0 .. versionchanged:: 1.22.0 See Also -------- get_printoptions, printoptions, set_string_function, array2string Notes ----- `formatter` is always reset with a call to `set_printoptions`. Use `printoptions` as a context manager to set the values temporarily. Examples -------- Floating point precision can be set: >>> np.set_printoptions(precision=4) >>> np.array([1.123456789]) [1.1235] Long arrays can be summarised: >>> np.set_printoptions(threshold=5) >>> np.arange(10) array([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) Also to temporarily override options, use `printoptions` as a context manager: >>> with np.printoptions(precision=2, suppress=True, threshold=5): ... np.linspace(0, 10, 10) array([ 0. , 1.11, 2.22, ..., 7.78, 8.89, 10. ]) r9r:rQr/r8rSr N)rj_format_optionsupdaterr[r\) r3r1r0r5r4r6r7r9r8r2r:opts rBrrtsB Y 9i%vvtY& 0 0C!C 3x C''c""""%  "c ) )c"""""  "ck 1 1a      2 1rDczt}ddddtjdi|d|d<|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 - sign : str For a full description of these options, see `set_printoptions`. See Also -------- set_printoptions, printoptions, set_string_function rQrPrSrRFr:)rncopyr[r\)optss rBrr'sB6    ! !D VS&#+u 8nDN KrDctdS)z'Return the legacy print mode as an int.r:)rnr>rDrB_get_legacy_print_moderuIs 8 $$rDc/Ktj} tj|i|tjVtjdi|dS#tjdi|wxYw)aContext 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 -------- >>> from numpy.testing import assert_equal >>> with np.printoptions(precision=2): ... np.array([2.0]) / 3 array([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 Nr>)rcrr)argskwargsrss rBrrNs6   D$ T,V,,,!##### ##d#######d####s &AA#r>c rt|}||jkr||S|j|d|zkr\tt |||t jd|zt |||t j| dzf|St |||t jddzS)z 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. N)axis)lenndimshaper_leading_trailingrc index_exp)ar0rfr{s rBrrqs u::D qv~~xwt}q{"" aEBL*9*4M,M N N aEBL)4M,M N N   !Iur|AAA/FGGGrDcbt|turd}nd}||S)z@ Object arrays containing lists should be printed unambiguously z list({!r})z{!r})typelistrK)ofmts rB_object_formatrs- Aww$ ::a==rDc t|Sr=)reprxs rB repr_formatrs 77NrDc t|Sr=)strrs rB str_formatrs q66MrDc tfdfdfdfdfdfdfdfdd d d d }d } fdD} d| vr+|D]} | d|| <d| vrdD]} | d|| <d| vrdD]} | d|| <d| vrdD]} | d|| <d| vr| d|d<|D]} | | vr| | || <|S)Nc"tSr=) BoolFormatdatasrBz!_get_formatdict..s 4((rDc"tSr=) IntegerFormatrsrBrz!_get_formatdict..s}T**rDc.tSNrlFloatingFormatrr2r:r3r8r4srBrz!_get_formatdict..s& )Y$vGGGrDc.tSrrrsrBrz!_get_formatdict..s&^ )Y$vGGGrDc.tSrComplexFloatingFormatrsrBrz!_get_formatdict..s' 5 )Y$v!G!G!GrDc.tSrrrsrBrz!_get_formatdict..s'$9 )Y$v%G%G%GrDc&tSr)DatetimeFormat)rr:srBrz!_get_formatdict..sN4???rDc"tSr=)TimedeltaFormatrsrBrz!_get_formatdict..s_T22rDctSr=)rr>rDrBrz!_get_formatdict..s.rDctSr=)rr>rDrBrz!_get_formatdict..s rDctSr=)rr>rDrBrz!_get_formatdict..sKrD) rXintfloat longfloat complexfloatlongcomplexfloatdatetime timedeltaobjectvoidnumpystrcfdS)NcSr=r>rsrBrz3_get_formatdict..indirect..sqrDr>rs`rBindirectz!_get_formatdict..indirectsyyyrDc$g|] }| | Sr=r>)r?r@r9s rB z#_get_formatdict..s"IIIq ! 0H0H0H0HrDallint_kind)r float_kind)rr complex_kind)rrstr_kindr)keys) rr3r2r4r8r:r9rx formatdictrfkeyskeys ``````` rB_get_formatdictrs )(((****GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG?????2222((""''))J&IIIIINN,,III E>>!(( = ="*(9U+;"<"< 3    B B"*(9Z+@"A"A 3 5 - D D"*(9\+B"C"C 3 U " "; F F"*(9^+D"E"E 3   %-Xi .C%D%DJz "??$$ ; ;Ce||"*(9S>":": 3 rDc b|j}|j}t|fi|}||dSt|tjr|dSt|tjr:t|tjr|dS|dSt|tjr:t|tj r|dS|dSt|tj r:t|tj r|dS|d St|tj tj fr|dSt|tjr|d St|tjr|d St|tjr)|jt%j|fi|S|d S|dS) z; find the right formatting function for the dtype_ NrrXrrrrrrrrr)dtyperr issubclass_ntr%integer timedelta64floatingrcomplexfloating clongfloatstr_bytes_ datetime64object_rnamesStructuredVoidFormat from_data)rrgdtype_dtypeobjrs rB_get_format_functionrs*ZF{H 1111J%z*%''' Hci ( ((!z&!### Hck * *( h 0 0 '*:k*,, ,$:e$&& & Hcl + +( h . . )*:k*,, ,&:g&(( ( Hc1 2 2( h / / 01:0133 3-:n-// / Hsx4 5 5 (%z*%''' Hcn - - (%z*%''' Hck * *(#z(#%%% Hch ' '( < #'1$BB'BB B%:f%'' '%z*%'''rD...cfd}|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 cjttjfd}|S)Nct|tf}|vrS| |g|Ri||S#|wxYwr=)idr adddiscard)selfrwrxrf fillvalue repr_runnings rBwrapperz>_recursive_guard..decorating_function..wrappersT((IKK'Cl""    S ! ! ! *q//////$$S)))) $$S))))s AA3)set functoolswraps)rrrrs` @rBdecorating_functionz-_recursive_guard..decorating_functionsMuu    * * * * * *   *rDr>)rrs` rB_recursive_guardrs$ rDrOc .t|}|jdkr|}|j|dkrd}t||d}nd}t |fi|}d}|dt |zz }t |||d|||d||d}|S) Nr>r1rr0rrOr5r:)rr~sizerrr| _formatArray) rrg separatorprefixrsummary_insertformat_functionnext_line_prefixlsts rB _array2stringr s 1::Dw"}} v $$$ w{';<<+4;;7;;OCKK' q/7;+?'GK4H%wx'8 : :C JrDc |fSr=r>)rmax_line_widthr3suppress_smallrrstyler9r1r0r8r2suffixr:s rB_array2string_dispatcherr(s 4KrD)modulec   t||| ||dd| || | }t}|||ddkrJ|tjurt }|jdkr)|jj || Sn*|tjurtj dtd|ddkr|dxxt| zcc<|jd krd St!||||S) a Return a string representation of an array. Parameters ---------- a : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision : int or None, optional Floating point precision. Defaults to ``numpy.get_printoptions()['precision']``. 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. Defaults to ``numpy.get_printoptions()['suppress']``. 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)``. It should be noted that the content of prefix and suffix strings are not included in the output. 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.bytes_` and `numpy.str_` 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 'numpystr' threshold : int, optional Total number of array elements which trigger summarization rather than full repr. Defaults to ``numpy.get_printoptions()['threshold']``. edgeitems : int, optional Number of array items in summary at beginning and end of each dimension. Defaults to ``numpy.get_printoptions()['edgeitems']``. 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. Defaults to ``numpy.get_printoptions()['sign']``. floatmode : str, optional Controls the interpretation of the `precision` option for floating-point types. Defaults to ``numpy.get_printoptions()['floatmode']``. 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]) >>> 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)}) '[0x0 0x1 0x2]' Nr:rQr>zT'style' argument is deprecated and no longer functional except in 1.13 'legacy' moderzrTr5r z[])rjrnrrrorc_NoValuerr~rritemr]r^DeprecationWarningr|rr)rrr3rrrrr9r1r0r8r2rr: overridesrgs rBrr1s*l#9i#1>4#'IvGGI""$$G NN9xC BK  E 7b==QW]25?? " bk ! ! 6(Q 8 8 8 8x3 F + v{{t GY 7 77rDct|t|z|k}|dkr"t|t|krd}|r||dzz }|}||z }||fS)NrQF )r|rstrip)slineword line_widthrr: needs_wraps rB _extendLiners{TSYY&3J || t99,-- - -J  T[[]]T !!DLD d7NrDcL|}t|dks|dkrt||||||Std|D}t||z|krHt|t|kr(||dzz }||dz}|}nt|dz}||dz }|ddD]!}||dzz }||z}"|t|dz } || dzz }||fS) zS Extends line with nicely formatted (possibly multi-line) string ``word``. rrQc34K|]}t|VdSr=r|)r?rs rBrMz%_extendLine_pretty..s(66#d))666666rDrr rON) splitlinesr|rmaxr) rrrrrr:wordsmax_word_lengthindent suffix_lengths rB_extendLine_prettyrs= OO  E 5zzQ&C--1dD*6FOOO6666666O D O#j00 II,-- - - T[[]]T !!%(*!T3 aacc  T[[]]T !!}#c%)nn4MM# D d7NrDcVfd d||dS#dwxYw)zgformatArray is designed for two modes of operation: 1. Full output 2. Summarized output c <t|}j|z }|dkr|S|dz}dkr|}n|tdz }j|}odz|k}|r} } nd} |} d} |dkrLdkr%|tz } n?|t ttdz } |} t | D]/}||fz||}t | | || |\} } | z } 0|r(t| | | |\} } dkr| dz } n| z } t | dd D]0}|| fz||}t | | || |\} } | z } 1dkr|} |d z||}t | | || |\} } | | z } nd} d |dz zz}t | D]}||fz||}| ||z|zz } |rdkr | |zd zz } n | |z|zz } t | dd D]}|| fz||}| ||z|zz } |d z||}| ||zz } d | t|dzdz} | S)z 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 r rOrQ]rzrrrHr )r rz, [N)r|r}r~rr rangerr)rfhanging_indent curr_widthr{ axes_leftnext_hanging_indent next_widtha_len show_summary leading_itemstrailing_itemsr elem_widthrirline_sepnestedr edge_itemsrr:recurserrrs rBr$z_formatArray..recursers 5zzFTM >>"?1U8,, ,-s2 S==#JJ#c#hh.J %>!J,*>  #&M'NNM"N  >>}}'#i.>.>.@.@*A*AA '#c)2B2B2D2D.E.Es3xx*P*PP !D=)) " "x .A:NN,tT:~vGG4 ! &%t^ZQQ4S==DLDDI%D>1b11 " "x! /BJOO,tT:~vGG4 !}}' 8EEM+> KKD(4z>6CCGAt IAAA ''))D)a-,@@H=)) 8 8!%1$,0CZPP^f,x77 DS==.86AAAA.88CCA>1b11 8 8!%A2%-1D",..^f,x77Xeem-@*MMF &( (A !C''(() )C /rDr>)rfrrNr>) rrrrrr#rr:r$s `` ````@rBrr s```````````D xb'7#-///4s $(c^|dS|dkr"td||S)Nr r z{} must be >= 0)rYrK)rnames rB_none_or_positive_argr's7yr1uu*11$77888 HrDc,eZdZdZddddZdZdZdS) rz' Formatter for subtypes of np.floating FNrlcTt|tr|rdnd}||_|jdkr|jdkr|dkrd}||_|dkrd|_n||_t |jd|_||_||_d|_ d|_ | |dS) NrNr/rQr>rOrFr3F) r_rX_legacyr~r2r3r'rr8 exp_formatlarge_exponent fillFormat)rrr3r2rr8r:s rB__init__zFloatingFormat.__init__s dD ! ! ('33CD <3  zRDCKK"  !DNN&DN.t~{KK, # rDc|t|}t||dk}t|dkrstj|}tj|}t d5|dksjs|dks ||z dkrd_dddn #1swxYwYt|dkr,d_ d_ d_ d _ d_ d_njrd \jd ks jd krd \fd|D}t#d|D\}}} t#d|D\} } t d| Ddz _ d_ t d| D_j__ jd krd_ nt d| D_ j dzjz_ nd \jd krd \fd|D}t#d|D\} } jd kr"dt d| Dz_ nt d| D_ t d| D_ d _ _ jdvrj x__d_ nd_ d_jd kr<jdkr1t)tj|sxj dz c_ |j|jkrjdkp%t)|t/|dk} tt0d } tt0d!| z}j dz}t j | |z ||z _ dSdS)"Nr ignore)overgחAg-C6?g@@T.r )r2TrErQ)r@Fc 3\K|]&}t|jjdkV'dS)rN)r3rFtrimr8N)rr3r8r?rrr4rFs rBrMz,FloatingFormat.fillFormat..s]**'qDN&,4di3>NPPP******rDc3@K|]}|dVdS)riN) partitionr?rs rBrMz,FloatingFormat.fillFormat..s.*J*J1;;s+;+;*J*J*J*J*J*JrDc3@K|]}|dVdSr2Nsplitr8s rBrMz,FloatingFormat.fillFormat..s,'H'H 'H'H'H'H'H'HrDc34K|]}t|VdSr=rr8s rBrMz,FloatingFormat.fillFormat..s(991A999999rDrr@c34K|]}t|VdSr=rr8s rBrMz,FloatingFormat.fillFormat..( ; ;AQ ; ; ; ; ; ;rDr)c34K|]}t|VdSr=rr8s rBrMz,FloatingFormat.fillFormat..(#=#=qCFF#=#=#=#=#=#=rDrzc 3^K|]'}t|jdjdkV(dS)TrN)r3 fractionalrFr4r8N)rr3r8r5s rBrMz,FloatingFormat.fillFormat..s`** 'qDN26.44,0I,<>>>******rDc3@K|]}|dVdSr:r;r8s rBrMz,FloatingFormat.fillFormat..s,'C'C 'C'C'C'C'C'CrDc3ZK|]&}t|dV'dS)z-+N)r|lstripr8s rBrMz,FloatingFormat.fillFormat..s4'N'NAHHTNN(;(;'N'N'N'N'N'NrDc34K|]}t|VdSr=rr8s rBrMz,FloatingFormat.fillFormat..rArDc34K|]}t|VdSr=rr8s rBrMz,FloatingFormat.fillFormat..r?rD)rErGrOr/r6r7)rrr|rcr minrrr+pad_left pad_rightr4exp_sizerF min_digitsr2r*zipr3r8rsignbitrrrn)rr finite_vals abs_non_zeromax_valmin_valstrs frac_strs_exp_strsint_part frac_partneginfnanleninflenoffsetr4rFs` @@rBr-zFloatingFormat.fillFormats8D>>*  K1,< =>> |   ! !f\**Gf\**Gx((( + +d??4+>? 6))WW_u-D-D&*DO + + + + + + + + + + + + + + + {  q DMDNDIDMDK"DOO _/ $$LD&~((DLC,?,?) f******(***D&)*J*JT*J*J*J%K "Iq("%'H'Hi'H'H'H"I Hi9999999A=DMDI ; ; ; ; ;;;DN"nDO DK|s"" ! !$#=#=H#=#=#= = = !]Q.?DNN$LD&~(() f******) ***D #&'C'Cd'C'C'C"D Hi|s"" !C'N'NX'N'N'N$N$N N ##=#=H#=#=#= = =  ; ; ; ; ;;;DNDM DK~!;;;37>A  "# <#  yCBJ{,C,C(D(D "  9 ( ( (Y#%CT%++->-B)C)CF233F233ft||j |j |j |j|jdk|j|j St!||j |j |j d |j|jdk|j|j S)Nr0)invalidrNrr6r r/r7rOr)r3rMrFr4r8rJ exp_digitsT)r3rMrFrCr4r8rJrK)rcrrrdr8rnrJrKr|r+rr3rMrFr4rLr)rrr8rets rB__call__zFloatingFormat.__call__s{1~~ Q(+++ Q Q8A;;;"&)s"2"233D!::CC"#a%%33DI4D4DSS"D!::CDMDN:Q>SIJSP Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q Q ? @%a0415-1[+/9+/9+;/3}15@@@ @&a0415-1[15+/9+/9+;/3}04@@@ @sBB55B9<B9F)__name__ __module__ __qualname____doc__r.r-rbr>rDrBrrse116RQRQRQh@@@@@rDrTr@c t|d}t|d}t|d}t|d}|dkr|dkr||krtdt||||||||S)a 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` is given fewer digits than necessary can be printed. If `min_digits` is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If `False`, digits are generated as if printing an infinite-precision value and stopping after `precision` digits, rounding the remaining value with unbiased rounding 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. min_digits : non-negative integer or None, optional Minimum number of digits to print. This only has an effect for `unique=True`. In that case more digits than necessary to uniquely identify the value may be printed and rounded unbiased. -- versionadded:: 1.21.0 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' r3rJr`rMr 2min_digits must be less than or equal to precision)r3rFr4r8rJr`rM)r'rYr)rr3rFr4r8rJr`rMs rBr r sJ&i==I$Xz::H&z<@@J&z<@@JA~~)a--J,B,BMNNN a9V#'dX)3  L L LLrDc "t|d}t|d}t|d}t|d}|s|dkrtd|dkr|dkr||krtdt||||||||| S) a 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` is given fewer digits than necessary can be printed, or if `min_digits` is given more can be printed, in which cases the last digit is rounded with unbiased rounding. If `False`, digits are generated as if printing an infinite-precision value and stopping after `precision` digits, rounding the remaining value with unbiased rounding fractional : boolean, optional If `True`, the cutoffs of `precision` and `min_digits` refer to the total number of digits after the decimal point, including leading zeros. If `False`, `precision` and `min_digits` refer 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. min_digits : non-negative integer or None, optional Minimum number of digits to print. Only has an effect if `unique=True` in which case additional digits past those necessary to uniquely identify the value may be printed, rounding the last additional digit. -- versionadded:: 1.21.0 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' r3rJrKrMr z4precision must be greater than 0 if fractional=Falseri)r3rFrCr4r8rJrKrM)r'rYr) rr3rFrCr4r8rJrKrMs rBr r jsZ&i==I$Xz::H%i==I&z<@@J -)q..,-- -A~~)a--J,B,BMNNN a9V)3$#'((1j J J JJrDceZdZdZdZdS)rc &|jdkritttt j|ttt j|}nd}d||_dS)Nr z%{}d)rr r|rrcrIrK)rr max_str_lens rBr.zIntegerFormat.__init__sq 9q==c#bfTll"3"344!#bfTll"3"34466KKKmmK00 rDc|j|zSr=rJrrs rBrbzIntegerFormat.__call__s{QrDNrdrerfr.rbr>rDrBrrs2111rDrceZdZdZdZdS)rc .|jdkrdnd|_dS)Nr>z TrueTrue)r~truestr)rrrxs rBr.zBoolFormat.__init__s#'*"2"2ww rDc|r|jndS)NFalse)rtros rBrbzBoolFormat.__call__s -t||g-rDNrpr>rDrBrrs2??? .....rDrc(eZdZdZ ddddZdZdS)rz. Formatter for subtypes of np.complexfloating FNrlct|tr|rdnd}|x}}|dkrd}d}t|j||||||_t|j|||d||_dS)NrNr/rQrGr*)r8r:)r_rXrreal real_formatimag imag_format) rrr3r2rr8r:floatmode_realfloatmode_imags rBr.zComplexFloatingFormat.__init__s dD ! ! ('33CD*33 S==,N&N) FI~~f   * FI~~V   rDc||j}||j}t |}|d|dz||dz}||zS)Nj)rzryr|r{r|r)rrrr sps rBrbzComplexFloatingFormat.__call__sh   QV $ $   QV $ $__ crcFSL1RSS6 !1u rDrc)rdrerfrgr.rbr>rDrBrrsM88 '+     (rDrc eZdZdZdZdZdS)_TimelikeFormatc |t|}t|dkrutt|t j|t|t j|}nd}t||jkrt|d}d||_d ||_ dS)Nr z%{}sz'NaT') rr|r _format_non_natrcrIrrK_formatrjust_nat)rrnon_natrms rBr.z_TimelikeFormat.__init__sd |$ w<rDrBrrsA / / /""":::::rDrc4eZdZ dfd ZfdZdZxZS)rN same_kindFc|-|jjdkrt|jd}nd}|d}||_||_||_||_t|dS)NMr rnaive) rkindrtimezoneunitcastingr:superr.)rrrrrr: __class__s rBr.zDatetimeFormat.__init__s{ <w|s""$QW--a0  H      rDc|jdkr||St|S)NrQ)r:rrrb)rrrs rBrbzDatetimeFormat.__call__,s< ;#  ''** *ww"""rDcLdt||j|j|jzS)N'%s')rrr)rrrrros rBrzDatetimeFormat._format_non_nat1s2*1)--1],0L:::: :rD)NNrF)rdrerfr.rbr __classcell__)rs@rBrrsk>"""rDN)rdrerfrr>rDrBrr8s######rDrc eZdZdZdZdZdS)SubArrayFormatc H||_|d|_|d|_dS)Nr1r0)rr1r#)rrrgs rBr.zSubArrayFormat.__init__>s&. -!+.rDc^|j|jkrdnd|_||S)Nrr)rr1r format_array)rrs rBrbzSubArrayFormat.__call__Cs0'(v'>'>eeB  ###rDcttj|dkr|Sjr[|jddjzkrBfd|djDjgzfd|j dDz}nfd|D}dd|zdzS) Nr rzc:g|]}|Sr>rr?a_rs rBrz/SubArrayFormat.format_array..Ms'EEE2""2&&EEErDc:g|]}|Sr>rrs rBrz/SubArrayFormat.format_array..Os'HHHR4$$R((HHHrDc:g|]}|Sr>rrs rBrz/SubArrayFormat.format_array..Rs';;;2**2..;;;rDrrHr)rcr}rrr~r#rZ)rr formatteds` rBrzSubArrayFormat.format_arrayGs 71::??''** *   <171:$/0A#A#AEEEE3CDO3C1DEEE&'(HHHH1do5E5F5F3GHHHI I <;;;;;;ITYYy)))C//rDN)rdrerfr.rbrr>rDrBrr=sA/// $$$ 0 0 0 0 0rDrc4eZdZdZdZedZdZdS)rz 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__. c||_dSr=)format_functions)rrs rBr.zStructuredVoidFormat.__init___s 0rDc g}|jjD]M}t||fi|}|j|jdkr t |fi|}||N||S)z This is a second way to initialize StructuredVoidFormat, using the raw data as input. Added to avoid changing the signature of __init__. r>)rrrr~rappend)clsrrgr field_namers rBrzStructuredVoidFormat.from_databs ** 5 5J24 3COOwOOOz*%+r11"0"L"LG"L"L  # #O 4 4 4 4s#$$$rDcdt||jD}t|dkrd|dSdd|S)Nc*g|]\}}||Sr>r>)r?fieldrs rBrz1StructuredVoidFormat.__call__..qs6   & OE " "   rDrz({},)r z({})rH)rNrr|rKrZ)rr str_fieldss rBrbzStructuredVoidFormat.__call__pst  *-a1F*G*G    z??a  >>*Q-00 0==:!6!677 7rDN)rdrerfrgr. classmethodrrbr>rDrBrrWsW111 % %[ %88888rDrc\tjt|fit|S)z 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. )rrrrnrs rB_void_scalar_reprr{s/ G  )%(( F Fo F Fq I IIrDctj|}tddkr|jtkrdS|jdS|jsdS|jtvS)a 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=int8) r:rQF)rcrrnrr%risnative _typelessdata)rs rBdtype_is_impliedrs_2 HUOOEx C''EJ%,?,?u {u >u : &&rDct|jtjjkrt |S|jt |St|jtrdt |zS|j }|j sdt |zS|r=|d r| st |}|S)z Convert a dtype to a short form which evaluates to the same dtype. The intent is roughly that the following holds >>> from numpy import * >>> dt = np.int64([1, 2]).dtype >>> assert eval(dtype_short_repr(dt)) == dt Nrr ) r__repr__rcrrrrrr&r&risalphaisalnum)rtypenames rBdtype_short_reprrs E{{rx000E{{ {5zz EJ ) )#E ""zH >#E """!,,.."83C3C3E3E">> OrDc | td}t|turt|j}nd}t |jo |jdk}|dz}|rdnd}tdd kr9|jd kr.|jjs"t| } n@|jdks |jd kr|||||d || } ndt|j} || z|z} |r| Sd t|j} t| | ddzz } d} tdd kr8t|jjt rddt|dzzz} n1| t| zdz|krddt|dzzz} | | z| zS)zEInternal version of array_repr() that allows overriding array2string.Nr5rr (),r:rQr>)r rH)rz [], shape=z dtype={})rrrO)rnrrrdrrrr~rrrrKrr|rfindrr&)arrrr3rr class_name skipdtyperrrarr_str dtype_str last_line_lenspacers rB_array_repr_implementationrs(5 Cyy#YY'   ++<1 I # F &SS3F!S(( IOOCIOO388:: Ad**l3 >888+!%SY1slV#G""#3CI#>#>??I LLGMM$$7$7!$;rrr3rs rB_array_repr_dispatcherrs 6MrDc&t||||S)a  Return the string representation of an array. Parameters ---------- arr : ndarray Input array. max_line_width : int, optional Inserts newlines if text is longer than `max_line_width`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision : int, optional Floating point precision. Defaults to ``numpy.get_printoptions()['precision']``. 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. Defaults to ``numpy.get_printoptions()['suppress']``. 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. ])' )rrs rBrrs Z & ^Y 8 88rDcht|trt|St|Sr=)r_bytesrr)rAs rB_guarded_repr_or_strr4s*!UAww q66MrDc$tddkr8|jdkr-|jjs!t |S|jdkr-t tj |dS|||||ddS)zDInternal version of array_str() that allows overriding array2string.r:rQr>rOr) rnr~rrrrrrcr __getitem__)rrr3rrs rB_array_str_implementationr;s !S(( GrMM!'-M16688}}  w"}}$BJ$:$:1b$A$ABBB <>9nc2 N NNrDc|fSr=r>rrr3rs rB_array_str_dispatcherrOs 4KrDc&t||||S)aa 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`. Defaults to ``numpy.get_printoptions()['linewidth']``. precision : int, optional Floating point precision. Defaults to ``numpy.get_printoptions()['precision']``. 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. Defaults to ``numpy.get_printoptions()['suppress']``. See Also -------- array2string, array_repr, set_printoptions Examples -------- >>> np.array_str(np.arange(3)) '[0 1 2]' )rrs rBrrTs H % >9n 6 66rD __wrapped__)rc|6|rtjtdStjtdStj||S)a 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? >>> _ = 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])' Nrr )rr_default_array_repr_default_array_str)rrs rBrrsNf y  I12EqII I12DaHH H-a666rD) NNNNNNNNNNN) NNNNNNNNNN)r>)r)rOr) NNNNNNNNNNNN)NTr@FNNN)NTTr@FNNN)NNN)T)brg__all__ __docformat__rr`r[_threadr ImportError _dummy_threadrkrcrrrumathrrrrrrrrrrrr fromnumericrnumericrrrr r!r"r#r$r%r&rr'r(rer] contextlibr\rnrjrrrucontextmanagerrrrrrrrrrrrrrrrr'rr r rrrrrrrrrrrrrrrrrrrgetattr_array2string_implpartialrrrr>rDrBrsJ  A A A#  (!!!!!!!(((''''''''(!!!!!!3333333333330000000000000000003333333333%%%%%%%%%%%%%%%%%%:::::::: k  BFJNIM1111h G?CHL:>o!JNo!o!o!o!o!d GB%%%  G $$$BHHHH(///b&(&(&(R<:+/48.2:>   1'BBB#'4 $B{dddd2n8 n8n8n8n8CBn8b   6tttl   N@N@N@N@N@N@N@N@b GADBF'+LLLLLLLL^ G6: