
    Kh,                        S r / SQrSrSSKrSSKrSSKr SSKJr  SSK
rSSKJr  SSKJrJrJrJr  SS	KJr  SS
KJrJrJrJrJrJr  SSKJr  SSKJrJrJ r   SSKJ!r!J"r"J#r#J$r$J%r%J&r&  SSK'J(r(J)r)  SSK*J+r+  SSK,r,SSK-r-SSK.r.    SJS jr/\)" S5         SKSSS.S jj5       r0   SKSSS.S jjr1\)" S5      S 5       r2S r3\)" S5      \.Rh                  S 5       5       r*SLS jr5S r6S r7S r8S r9S r:SMS jr;\;" 5       SNS! j5       r<    SJSS".S# jjr=\(" \=SS$9SSSSS \R|                  SSSSSS 4SS".S% jj5       r?S& r@S' rAS( rBS) rC " S* S+5      rD\)" S5         SOS, j5       rE\)" S5         SPS- j5       rF " S. S/5      rG " S0 S15      rH " S2 S35      rI " S4 S55      rJ " S6 S7\J5      rK " S8 S9\J5      rL " S: S;5      rM " S< S=5      rNSQS> jrO\#\$\%\R                  /rQS? rRS@ rSSSS\?4SA jrT SRSB jrU\(" \USS$9SRSC j5       rV\;" 5       SD 5       rWSSS\?4SE jrX SRSF jrY\(" \YSS$9SRSG j5       rZ\[" \?SH\?5      r\\R                  " \X\\SI9r^\R                  " \T\\SI9r_g! \ a
    SSK	Jr   GNNf = f)SzXArray printing function

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

)array2string	array_str
array_reprset_printoptionsget_printoptionsprintoptionsformat_float_positionalformat_float_scientificrestructuredtext    N)	get_ident   )numerictypes)absoluteisinfisfiniteisnat)
multiarray)arraydragon4_positionaldragon4_scientificdatetime_as_stringdatetime_datandarray)any)concatenateasarrayerrstate)longlongintcint_float64
complex128flexible)array_function_dispatch
set_module)format_optionsc                    [        [        5       R                  5       5       VVs0 s H  u  pUc  M
  X_M     nnnUb  [        U5      US'   / SQnXS/-   ;  a$  [	        SSR                  S U 5       5      -   5      eUS;  a  [	        S5      eU
S	L a  [        R                  US
'   OU
S	:X  a3  [        R                  " SU
< S3[        SS9  [        R                  US
'   OIU
S:X  a  SUS
'   O=U
S:X  a  SUS
'   O1U
S:X  a  SUS
'   O%U
S:X  a  SUS
'   OU
c  O[        R                  " SSS9  UbP  [        U[        R                  5      (       d  [        S5      e[        R                   " U5      (       a  [	        S5      eU b   ["        R$                  " U 5      US'   U$ U$ s  snnf ! [         a  n[        S5      UeSnAff = f)za
Make a dictionary out of the non-None arguments, plus conversion of
*legacy* and sanity checks.
Nsuppress)fixeduniquemaxprecmaxprec_equalz floatmode option must be one of , c              3   D   #    U  H  nS R                  U5      v   M     g7f)z"{}"Nformat).0ms     H/var/www/html/env/lib/python3.13/site-packages/numpy/_core/arrayprint.py	<genexpr>%_make_options_dict.<locals>.<genexpr>C   s     "CU6==#3#3Us    )N-+ z+sign option must be one of ' ', '+', or '-'FlegacyzPassing `legacy=z` is deprecated.   
stacklevel1.13q   1.21y   1.25}   z2.1   zUlegacy printing option can currently only be '1.13', '1.21', '1.25', '2.1, or `False`zthreshold must be numericzIthreshold must be non-NAN, try sys.maxsize for untruncated representation	precisionzprecision must be an integer)listlocalsitemsbool
ValueErrorjoinsysmaxsizewarningswarnFutureWarning
isinstancenumbersNumber	TypeErrornpisnanoperatorindex)rD   	threshold	edgeitems	linewidthr(   nanstrinfstrsign	formatter	floatmoder9   override_reprkvoptionsmodeses                    r3   _make_options_dictrf   2   s    !%VX^^%5 6H 6!tqt 6GH"8n
;E&;"CU"CCD E 	E ((FGGKK	5vj(89a	
  KK	6		6		6		5	'34	6 )W^^4478888I J K K 	C#+>>)#<GK  N7Ng I`  	C:;B	Cs"   	FF F# #
F>-F99F>numpyr9   r`   c
                "    [        XX#UXVXxU	XS9  g)a  
Set printing options.

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

Parameters
----------
precision : int or None, optional
    Number of digits of precision for floating point output (default 8).
    May be None if `floatmode` is not `fixed`, to print as many digits as
    necessary to uniquely specify the value.
threshold : int, optional
    Total number of array elements which trigger summarization
    rather than full repr (default 1000).
    To always use the full repr without summarization, pass `sys.maxsize`.
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
    If True, always print floating point numbers using fixed point
    notation, in which case numbers equal to zero in the current precision
    will print as zero.  If False, then scientific notation is used when
    absolute value of the smallest number is < 1e-4 or the ratio of the
    maximum absolute value to the minimum is > 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 '-')

    .. versionchanged:: 2.0
         The sign parameter can now be an integer type, previously
         types were floating-point types.

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 ``'1.25'`` approximates printing of 1.25 which mainly means
    that numeric scalars are printed without their type information, e.g.
    as ``3.0`` rather than ``np.float64(3.0)``.

    If set to ``'2.1'``, shape information is not given when arrays are
    summarized (i.e., multiple elements replaced with ``...``).

    If set to `False`, disables legacy mode.

    Unrecognized strings will be ignored with a warning for forward
    compatibility.

    .. versionchanged:: 1.22.0
    .. versionchanged:: 2.2

override_repr: callable, optional
    If set a passed function will be used for generating arrays' repr.
    Other options will be ignored.

See Also
--------
get_printoptions, printoptions, 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:

>>> import numpy as np
>>> 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], shape=(10,))

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.  ], shape=(10,))

rh   N)_set_printoptions)rD   rX   rY   rZ   r(   r[   r\   r^   r]   r_   r9   r`   s               r3   r   r   q   s    h iI(iy#B    c
                    [        XX#XEXhUX5      nX|S'   XS'   [        R                  " 5       U-  nUR                  U5        US   S:X  a  SUS'   [        R                  " U5      $ )Nr^   r`   r9   r>   r6   r]   )rf   r&   getupdateset)rD   rX   rY   rZ   r(   r[   r\   r^   r]   r_   r9   r`   new_optupdated_opts                 r3   rj   rj   *  sw     !y!)6!*4G %K,O $$&0Kw8#!Fk**rk   c                      [         R                  " 5       R                  5       n SSSSSS[        R                  S0U S      U S'   U $ )	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
    - sign : str
    - formatter : dict of callables
    - floatmode : str
    - legacy : str or False

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

See Also
--------
set_printoptions, printoptions

Examples
--------
>>> import numpy as np

>>> np.get_printoptions()
{'edgeitems': 3, 'threshold': 1000, ..., 'override_repr': None}

>>> np.get_printoptions()['linewidth']
75
>>> np.set_printoptions(linewidth=100)
>>> np.get_printoptions()['linewidth']
100

r>   r=   r@   r?   rB   rA   Fr9   )r&   rm   copyrK   rL   )optss    r3   r   r   >  sO    T $$&DVS&#vs{{E
8nDN Krk   c                  2    [         R                  " 5       S   $ )z'Return the legacy print mode as an int.r9   )r&   rm    rk   r3   _get_legacy_print_moderw   o  s    ))rk   c               /      #    [        U 0 UD6n [        5       v   [        R                  " U5        g! [        R                  " U5        f = f7f)aZ  Context 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
--------
>>> import numpy as np

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

N)rj   r   r&   reset)argskwargstokens      r3   r   r   t  s@     8 t.v.E$  U#U#s   A2 AA

Ac                 <   [        U5      nX0R                  :X  a  X   $ U R                  U   SU-  :  aI  [        [	        XU[
        R                  SU -   5      [	        XU[
        R                  U* S -   5      4US9$ [	        XU[
        R                  SS -   5      $ )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)lenndimshaper   _leading_trailingrT   	index_exp)arY   rW   r   s       r3   r   r     s     u:Dvv~xwwt}q{"aEBLL)4L,LMaEBLL)4M,MN
  	
 !ur||A/FGGrk   c                 R    [        U 5      [        L a  SnOSnUR                  U 5      $ )z?Object arrays containing lists should be printed unambiguously z
list({!r})z{!r})typerE   r0   )ofmts     r3   _object_formatr     s%    Aw$::a=rk   c                     [        U [        R                  [        R                  45      (       a  [	        U R                  5       5      $ [	        U 5      $ N)rP   rT   str_bytes_repritemxs    r3   repr_formatr     s5    !bggryy)**AFFH~7Nrk   c                     [        U [        R                  [        R                  45      (       a  [	        U R                  5       5      $ [	        U 5      $ r   )rP   rT   r   r   strr   r   s    r3   
str_formatr     s5    !bggryy)**1668}q6Mrk   c                |  ^ ^^^^^ U 4S jU U4S jU UUUUU4S jU UUUUU4S jU UUUUU4S jU UUUUU4S jU U4S jU 4S jS	 S
 S S.nS n	Ub  UR                  5        V
s/ s H  oU
   c  M
  U
PM     nn
SU;   a$  UR                  5        H  nU	" US   5      X'   M     SU;   a  S H  nU	" US   5      X'   M     SU;   a  S H  nU	" US   5      X'   M     SU;   a  S H  nU	" US   5      X'   M     SU;   a  U	" US   5      US'   UR                  5        H  nX;   d  M
  U	" Xl   5      X'   M     U$ s  sn
f )Nc                     > [        T 5      $ r   )
BoolFormatdatas   r3   <lambda>!_get_formatdict.<locals>.<lambda>  s
    
4(rk   c                     > [        T T5      $ r   )IntegerFormat)r   r]   s   r3   r   r     s    }T40rk   c            	          > [        T TTTTTS9$ Nr9   FloatingFormatr   r_   r9   rD   r]   r(   s   r3   r   r     s    )Y$vGrk   c            	          > [        T TTTTTS9$ r   r   r   s   r3   r   r     s    ^)Y$vGrk   c            	          > [        T TTTTTS9$ r   ComplexFloatingFormatr   s   r3   r   r     s     5)Y$v!Grk   c            	          > [        T TTTTTS9$ r   r   r   s   r3   r   r     s    $9)Y$v%Grk   c                     > [        T TS9$ r   )DatetimeFormat)r   r9   s   r3   r   r     s    N4?rk   c                     > [        T 5      $ r   )TimedeltaFormatr   s   r3   r   r     s
    _T2rk   c                      [         $ r   )r   rv   rk   r3   r   r     s    .rk   c                      [         $ r   )r   rv   rk   r3   r   r     s    
rk   c                      [         $ r   )r   rv   rk   r3   r   r     s    Krk   )rH   intfloat	longfloatcomplexfloatlongcomplexfloatdatetime	timedeltaobjectvoidnumpystrc                    ^  U 4S j$ )Nc                     > T $ r   rv   r   s   r3   r   3_get_formatdict.<locals>.indirect.<locals>.<lambda>  s    qrk   rv   r   s   `r3   indirect!_get_formatdict.<locals>.indirect  s	    rk   allint_kind)r   
float_kind)r   r   complex_kind)r   r   str_kindr   )keys)r   rD   r_   r(   r]   r9   r^   r{   
formatdictr   ra   fkeyskeys   ``````       r3   _get_formatdictr     s_    )0G GG GG GG G?2("')J& %NN,I,q!,IE>!("*9U+;"<
 )"*9Z+@"A
 5 -"*9\+B"C
 .U";"*9^+D"E
 <%-i
.C%DJz"??$C|"*9>":
 % ' Js   &	D93D9c                 f   U R                   nUR                  n[        U 40 UD6nUc
  US   " 5       $ [        U[        R
                  5      (       a
  US   " 5       $ [        U[        R                  5      (       a3  [        U[        R                  5      (       a
  US   " 5       $ US   " 5       $ [        U[        R                  5      (       a3  [        U[        R                  5      (       a
  US   " 5       $ US   " 5       $ [        U[        R                  5      (       a3  [        U[        R                  5      (       a
  US   " 5       $ US   " 5       $ [        U[        R                  [        R                  45      (       a
  US   " 5       $ [        U[        R                  5      (       a
  US	   " 5       $ [        U[        R                  5      (       a
  US
   " 5       $ [        U[        R                   5      (       a.  UR"                  b  [$        R&                  " U 40 UD6$ US   " 5       $ US   " 5       $ )z3
find the right formatting function for the dtype_
r   rH   r   r   r   r   r   r   r   r   r   )dtyper   r   
issubclass_ntrH   integertimedelta64floating
longdoublecomplexfloatingclongdoubler   r   
datetime64object_r   namesStructuredVoidFormat	from_data)r   rc   dtype_dtypeobjr   s        r3   _get_format_functionr     s    ZZF{{H 11J*%''	Hchh	'	'&!##	Hckk	*	*h00k*,,e$&&	Hcll	+	+h//k*,,g&((	Hc11	2	2h000133n-//	Hsxx4	5	5*%''	Hcnn	-	-*%''	Hckk	*	*(#%%	Hchh	'	'<<#'11$B'BBf%''*%''rk   c                    ^  U 4S jnU$ )z
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                 b   >^ ^ [        5       m[        R                  " T 5      U UU4S j5       nU$ )Nc                    > [        U 5      [        5       4nUT;   a  T$ TR                  U5         T" U /UQ70 UD6TR                  U5        $ ! TR                  U5        f = fr   )idr   adddiscard)selfrz   r{   r   f	fillvaluerepr_runnings       r3   wrapper>_recursive_guard.<locals>.decorating_function.<locals>.wrapper&  sc    T(IK'Cl"  S!*///$$S)$$S)s   A A!)ro   	functoolswraps)r   r   r   r   s   ` @r3   decorating_function-_recursive_guard.<locals>.decorating_function#  s,    u			* 
	* rk   rv   )r   r   s   ` r3   _recursive_guardr     s      rk   r8    c                     [        U 5      nU R                  S:X  a  Un U R                  US   :  a  Sn[        XAS   5      nOSn[	        U40 UD6nSnUS[        U5      -  -  n[        XUS   XrUS   XQS   5      nU$ )	Nrv   rX   ...rY   r   r8   rZ   r9   )r   r   sizer   r   r   _formatArray)	r   rc   	separatorprefixr   summary_insertformat_functionnext_line_prefixlsts	            r3   _array2stringr   7  s    
 1:Dww"}vv$$ {';< +4;7;O CK'
q7;+?'GK4H%x'8:C Jrk   r   c                    U 4$ r   rv   )r   max_line_widthrD   suppress_smallr   r   styler^   rX   rY   r]   r_   suffixr9   s                 r3   _array2string_dispatcherr   T  s     4Krk   )modulec                   [        X(U	XSSXX5      n[        R                  " 5       R                  5       nUR	                  U5        US   S::  aW  U[
        R                  L a  [        nU R                  S:X  a-  U R                  R                  c  U" U R                  5       5      $ O-U[
        R                  La  [        R                  " S[        SS9  US   S:  a  US==   [        U5      -  ss'   U R                   S	:X  a  g
[#        XXE5      $ )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']``.

    .. versionchanged:: 2.0
         The sign parameter can now be an integer type, previously
         types were floating-point types.

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.

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
--------
>>> import numpy as np
>>> 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]'

Nr9   r>   rv   zT'style' argument is deprecated and no longer functional except in 1.13 'legacy' moder~   r;   rZ   r   z[])rf   r&   rm   rs   rn   rT   _NoValuer   r   r   r   r   rM   rN   DeprecationWarningr   r   r   )r   r   rD   r   r   r   r   r^   rX   rY   r]   r_   r   r9   	overridesrc   s                   r3   r   r   ]  s    t #9#14#'IGI   "'')GNN9xCBKKE77b=QWW]]2?"	bkk	! 6(Q	8 x3F+ 	vv{Y77rk   c                     [        U5      [        U5      -   U:  nUS:  a  [        U5      [        U5      ::  a  SnU(       a  XR                  5       S-   -  n UnX-  nX4$ )Nr>   F
)r   rstrip)slineword
line_widthr   r9   
needs_wraps          r3   _extendLiner    s`    TSY&3J|t9,--J	[[]T!!LD7Nrk   c                    UR                  5       n[        U5      S:X  d  US::  a  [        XX#XE5      $ [        S U 5       5      n[        U5      U-   U:  a7  [        U5      [        U5      :  a  XR	                  5       S-   -  n XFS   -   nUnO[        U5      S-  nXS   -  nUSS  H  nXR	                  5       S-   -  n X-   nM     U[        US   5      -
  n	XS-  -  nX4$ )	zK
Extends line with nicely formatted (possibly multi-line) string ``word``.
r   r>   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r   )r1   r
  s     r3   r4   %_extendLine_pretty.<locals>.<genexpr>)  s     6#d))   r  r   r8   N)
splitlinesr   r  maxr  )
r  r	  r
  r  r   r9   wordsmax_word_lengthindentsuffix_lengths
             r3   _extendLine_prettyr  !  s     OOE
5zQ&C-1D6FOO666OD	O#j0I,--	[[]T!!(*!T3aac
	[[]T!!}  $c%)n4M#D7Nrk   c                 L   ^ ^^^^^^ U UUUUUU4S jm T" SUUS9Sm$ ! Smf = f)z[formatArray is designed for two modes of operation:

1. Full output

2. Summarized output

c           	        > [        U 5      nTR                  U-
  nUS:X  a  T" TU    5      $ US-   nTS::  a  UnOU[        S5      -
  nTR                  U   nT=(       a    ST-  U:  nU(       a  Tn	Tn
OSn	Un
SnUS:X  Ga  TS::  a  U[        TR                  5       5      -
  nO/U[	        [        TR                  5       5      [        S5      5      -
  nUn[        U	5       H$  nT" X4-   XV5      n[        XXUT5      u  pUT-  nM&     U(       a!  [        XTXT5      u  pTS::  a  US-  nOUT-  n[        U
SS	5       H%  nT" X* 4-   XV5      n[        XXUT5      u  pUT-  nM'     TS::  a  UnT" U S
-   XV5      n[        XXUT5      u  pX-  nOSnTR                  5       SUS-
  -  -   n[        U	5       H  nT" X4-   XV5      nXU-   U-   -  nM     U(       a  TS::  a  XT-   S-   -  nO
XT-   U-   -  n[        U
SS	5       H  nT" X* 4-   UU5      nXU-   U-   -  nM     T" U S
-   XV5      nXU-   -  nSU[        U5      S -   S-   nU$ )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   r8   r>   ]r~   r   r   r-   r  )r  r  z, 
[N)r   r   r   r  r  ranger  r  )rW   hanging_indent
curr_widthr   	axes_leftnext_hanging_indent
next_widtha_lenshow_summaryleading_itemstrailing_itemsr  
elem_widthr	  ir
  line_sepnestedr   
edge_itemsr   r9   recurserr   r   s                     r3   r.  _formatArray.<locals>.recurserE  s    5zFFTM	>"1U8,, -s2S=#J#c#h.J%>!J,*>&M'NM"N  >}'#i.>.>.@*AA
'#	((*+SX+ 
 "D=).AN,T~vG	!	 * %^Z S=DLDI%D>1b1/BO,T~vG	!	 2 }'
EEM+>KD(>6CGA IA A '')D)a-,@@H=)!DL"5 f,x77	 * S= .86AAA.88CCA>1b1!%2%-1D",.f,x77 2
 eem-@MF&((A !C'())C/rk   rv   )rW   r   r!  Nrv   )	r   r   r  r   r   r-  r   r9   r.  s	   ``  ````@r3   r   r   <  s2    f fP	b'7#-/ 4s    #c                 N    U c  gU S:  a  [        SR                  U5      5      eU $ )Nr  r   z{} must be >= 0)rI   r0   )r   names     r3   _none_or_positive_argr2    s-    y1u*11$788Hrk   c                   6    \ rS rSrSrS	SS.S jjrS rS rSrg)
r   i  z&Formatter for subtypes of np.floating Nr   c                `   [        U[        5      (       a  U(       a  SOSnX`l        U R                  S::  a  UR                  S:w  a  US:X  a  SnX0l        US:X  a  S U l        OX l        [        U R
                  S5      U l        X@l        XPl        SU l	        SU l
        U R                  U5        g )	Nr7   r6   r>   rv   r8   r*   rD   F)rP   rH   _legacyr   r_   rD   r2  r   r]   
exp_formatlarge_exponent
fillFormat)r   r   rD   r_   r   r]   r9   s          r3   __init__FloatingFormat.__init__  s     dD!!3CD<<3zzRDCK" !DN&N.t~~{K,	#rk   c                   ^ ^^ U[        U5         n[        X"S:g     5      n[        U5      S:w  aj  [        R                  " U5      n[        R
                  " U5      n[        SS9   US:  d  T R                  (       d  US:  d  XE-  S:  a  ST l        S S S 5        [        U5      S:X  a,  ST l	        ST l
        ST l        S	T l        ST l        S T l        GOT R                  (       a  S
u  mmT R                  S:X  d  T R                   S::  a  Su  mmU UU4S jU 5       n[#        S U 5       6 u  pxn	[#        S U 5       6 u  p[	        S U	 5       5      S-
  T l        ST l        [	        S U 5       5      T l        T R$                  T l        TT l        T R                   S::  a  ST l	        O[	        S U
 5       5      T l	        T R                  S-   T R$                  -   T l
        OS
u  mmT R                  S:X  a  Su  mmU UU4S jU 5       n[#        S U 5       6 u  pT R                   S::  a  S[	        S U
 5       5      -   T l	        O[	        S U
 5       5      T l	        [	        S U 5       5      T l
        S	T l        TT l        T R                  S;   a   T R                  =T l        T l        ST l        OST l        ST l        T R                   S:  aI  T R&                  S:X  a9  [)        [        R*                  " U5      5      (       d  T =R                  S-  sl	        UR,                  UR,                  :w  a  T R&                  S:g  =(       d    [)        U[/        U5         S:  5      nT R                  S-   n[0        R2                  " 5       n[	        T R                  [        US    5      U-
  [        US!   5      U-   U-
  5      T l	        g g ! , (       d  f       GN;= f)"Nr   ignore)overg    חAg-C6?g     @@T.r  )r>  Tr)   r>   )ra   Fc           	   3   l   >#    U  H)  n[        UTR                  TTTR                  S :H  S9v   M+     g7f)r7   )rD   r*   trimr]   N)r   rD   r]   r1   r   r   r@  r*   s     r3   r4   ,FloatingFormat.fillFormat.<locals>.<genexpr>  s6      *( 'qDNN&,4dii3>NP(s   14c              3   B   #    U  H  oR                  S 5      v   M     g7f)re   N)	partitionr1   r  s     r3   r4   rB    s     *JT;;s+;+;T   c              3   B   #    U  H  oR                  S 5      v   M     g7fr>  NsplitrE  s     r3   r4   rB    s     'HiirF  c              3   8   #    U  H  n[        U5      v   M     g 7fr   r  rE  s     r3   r4   rB    s     91Ar  r   ra   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r  rE  s     r3   r4   rB          ;AQr  r:   c              3   8   #    U  H  n[        U5      v   M     g 7fr   r  rE  s     r3   r4   rB         #=HqCFFHr  r~   c           
   3   n   >#    U  H*  n[        UTR                  S TTTR                  S:H  S9v   M,     g7f)Tr7   )rD   
fractionalr*   r@  r]   N)r   rD   r]   rA  s     r3   r4   rB    s=      * )	 'qDNN26.44,0II,<> )s   25c              3   B   #    U  H  oR                  S 5      v   M     g7frH  rI  rE  s     r3   r4   rB    s     'CddrF  c              3   V   #    U  H  n[        UR                  S 5      5      v   M!     g7f)z-+N)r   lstriprE  s     r3   r4   rB    s      'NXAHHTN(;(;Xs   ')c              3   8   #    U  H  n[        U5      v   M     g 7fr   r  rE  s     r3   r4   rB    rO  r  c              3   8   #    U  H  n[        U5      v   M     g 7fr   r  rE  s     r3   r4   rB    rM  r  )r)   r,   r8   r6   r[   r\   )r   r   r   rT   r  minr   r   r6  pad_left	pad_rightr@  exp_sizer*   
min_digitsr_   r5  ziprD   r]   r   signbitr   r   r&   rm   )r   r   finite_valsabs_non_zeromax_valmin_valstrs	frac_strs_exp_strsint_part	frac_partneginfoffsetcurrent_optionsr@  r*   s   `              @@r3   r8  FloatingFormat.fillFormat  sN   8D>*  1,< =>|!ff\*Gff\*Gx(d?4+>+> 6)W_u-D&*DO ) {q DMDNDIDMDK"DO__$LD&~~(DLLC,?)f*(*D &)*JT*J%K"I("%'Hi'H"IH999A=DMDI  ; ;;DN"nnDO DK ||s" ! !$#=H#= =!]]Q.?DN$LD&~~()f* )	*D
 #&'Cd'C"DH||s" !C'NX'N$N N ##=H#= =  ; ;;DNDM DK~~!;;37>>A		"#<<#yyCBJJ{,C(D(D" 99(((YY#%CT%+->-B)CF^^a'F,002Os?8#<=FOH-.7&@DM	 )I )(s   &-O
Oc                 B   [         R                  " U5      (       d  [        SS9   [        R                  " 5       n[         R
                  " U5      (       a  U R                  S:X  a  SOSnX2S   -   nO#US:  a  SOU R                  S:X  a  SOSnX2S   -   nS	U R                  U R                  -   S
-   [        U5      -
  -  U-   sS S S 5        $ U R                  (       aY  [        UU R                  U R                  U R                  U R                  U R                  S:H  U R                  U R                   S9$ [#        UU R                  U R                  U R                  SU R                  U R                  S:H  U R                  U R                  S9	$ ! , (       d  f       N= f)Nr<  )invalidr7   r   r[   r   r6   r\   r8   r   )rD   r[  r*   r@  r]   rX  
exp_digitsT)rD   r[  r*   rQ  r@  r]   rX  rY  )rT   r   r   r&   rm   rU   r]   rX  rY  r   r6  r   rD   r[  r*   r@  rZ  r   )r   r   rj  r]   rets        r3   __call__FloatingFormat.__call__1  sS   {{1~~(+"0"4"4"688A;;"&))s"23D!::C"#a%3DII4DS"D!::CMMDNN2Q6SA ,+ ??%a0415-1[[+/99+/99+;/3}}15@ @ &a0415-1[[15+/99+/99+;/3}}04@ @- ,+s   BF
F)r5  r6  rZ  r_   r7  r[  rX  rY  rD   r]   r   r@  r*   F)	__name__
__module____qualname____firstlineno____doc__r9  r8  rp  __static_attributes__rv   rk   r3   r   r     s    14Tl @rk   r   c                     [        US5      n[        US5      n[        US5      n[        US5      nUS:  a  US:  a  Xq:  a  [        S5      e[        XUX4UXgS9$ )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
--------
>>> import numpy as np
>>> 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'
rD   rX  rn  r[  r   2min_digits must be less than or equal to precision)rD   r*   r@  r]   rX  rn  r[  )r2  rI   r   )r   rD   r*   r@  r]   rX  rn  r[  s           r3   r	   r	   T  sn    L &i=I$Xz:H&z<@J&z<@JA~)a-J,BMNNaV#'X)3L Lrk   c	                     [        US5      n[        US5      n[        US5      n[        US5      nU(       d  US:X  a  [        S5      eUS:  a  US:  a  X:  a  [        S5      e[        XUX4XVXxS9	$ )	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
--------
>>> import numpy as np
>>> 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'
rD   rX  rY  r[  r   z4precision must be greater than 0 if fractional=Falserz  )rD   r*   rQ  r@  r]   rX  rY  r[  )r2  rI   r   )	r   rD   r*   rQ  r@  r]   rX  rY  r[  s	            r3   r   r     s    \ &i=I$Xz:H%i=I&z<@J)q. , - 	-A~)a-J,BMNNaV)3#'(1J Jrk   c                   $    \ rS rSrSS jrS rSrg)r   i  c                 >   UR                   S:  a~  [        R                  " U5      n[        R                  " U5      n[	        [        U5      5      nUS:X  a  US:  a  SnUS:  a  US;   a  US-  n[        U[	        [        U5      5      5      nOSnSU U S3U l        g )Nr   r8   r6   z+ r   z{:zd})r   rT   r  rW  r   r   r0   )r   r   r]   data_maxdata_mindata_max_str_lenmax_str_lens          r3   r9  IntegerFormat.__init__  s    99q=vvd|Hvvd|H"3x=1s{x!|1} A% .!#h-02K KD6+c2rk   c                 8    U R                   R                  U5      $ r   r/   r   r   s     r3   rp  IntegerFormat.__call__  s    {{!!!$$rk   r/   N)r6   rs  rt  ru  rv  r9  rp  rx  rv   rk   r3   r   r     s    3%rk   r   c                        \ rS rSrS rS rSrg)r   i  c                 B    UR                   S:w  a  SU l        g SU l        g )Nrv   z TrueTrue)r   truestr)r   r   r{   s      r3   r9  BoolFormat.__init__  s     #'**"2wrk   c                 ,    U(       a  U R                   $ S$ )NFalser  r  s     r3   rp  BoolFormat.__call__  s     t||-g-rk   r  Nr  rv   rk   r3   r   r     s    ?
.rk   r   c                   2    \ rS rSrSr SSS.S jjrS rSrg)	r   i  z-Formatter for subtypes of np.complexfloating Nr   c          	          [        U[        5      (       a  U(       a  SOSnU=pxUS::  a  SnSn[        UR                  X'UXVS9U l        [        UR
                  X(USUS9U l        g )Nr7   r6   r>   r,   r+   )r]   r9   )rP   rH   r   realreal_formatimagimag_format)	r   r   rD   r_   r   r]   r9   floatmode_realfloatmode_imags	            r3   r9  ComplexFloatingFormat.__init__   sm     dD!!3CD*33S=,N&N)FFI~
 *FFI~V
rk   c                     U R                  UR                  5      nU R                  UR                  5      n[	        UR                  5       5      nUS U S-   X4S  -   nX#-   $ )Nj)r  r  r  r  r   r  )r   r   rr*  sps        r3   rp  ComplexFloatingFormat.__call__4  sZ    QVV$QVV$ _crFSL1S6!urk   )r  r  rr  )rs  rt  ru  rv  rw  r9  rp  rx  rv   rk   r3   r   r     s    8
'+
(rk   r   c                   &    \ rS rSrS rS rS rSrg)_TimelikeFormati?  c           
         U[        U5      )    n[        U5      S:  ae  [        [        U R                  [        R                  " U5      5      5      [        U R                  [        R
                  " U5      5      5      5      nOSn[        U5      UR                  :  a  [        US5      nSR                  U5      U l        SR                  U5      U l
        g )Nr      z%{}sz'NaT')r   r   r  _format_non_natrT   rW  r   r0   _formatrjust_nat)r   r   non_natr  s       r3   r9  _TimelikeFormat.__init__@  s    d|$w<!c$"6"6rvvg"GH!$"6"6rvvg"GHJK Kw<$))#k1-K}}[1MM+.	rk   c                     [         er   )NotImplementedErrorr  s     r3   r  _TimelikeFormat._format_non_natN  s    !!rk   c                 v    [        U5      (       a  U R                  $ U R                  U R                  U5      -  $ r   )r   r  r  r  r  s     r3   rp  _TimelikeFormat.__call__R  s/    8899<<$"6"6q"999rk   )r  r  N)rs  rt  ru  rv  r9  r  rp  rx  rv   rk   r3   r  r  ?  s    /":rk   r  c                   B   ^  \ rS rSr  SU 4S jjrU 4S jrS rSrU =r$ )r   iY  c                    > Uc5  UR                   R                  S:X  a  [        UR                   5      S   nOSnUc  SnX0l        X l        X@l        XPl        [        TU ]!  U5        g )NMr   r  naive)	r   kindr   timezoneunitcastingr9   superr9  )r   r   r  r  r  r9   	__class__s         r3   r9  DatetimeFormat.__init__Z  s`     <ww||s"$QWW-a0H 	 	rk   c                 d   > U R                   S::  a  U R                  U5      $ [        TU ]  U5      $ )Nr>   )r9   r  r  rp  )r   r   r  s     r3   rp  DatetimeFormat.__call__m  s0    ;;#''**w""rk   c                 \    S[        UU R                  U R                  U R                  S9-  $ )N'%s')r  r  r  )r   r  r  r  r  s     r3   r  DatetimeFormat._format_non_natr  s.    *1)--1]],0LL: : 	:rk   )r  r9   r  r  )NN	same_kindF)	rs  rt  ru  rv  r9  rp  r  rx  __classcell__)r  s   @r3   r   r   Y  s    <G&#
: :rk   r   c                       \ rS rSrS rSrg)r   iy  c                 6    [        UR                  S5      5      $ )Ni8)r   astyper  s     r3   r  TimedeltaFormat._format_non_natz  s    188D>""rk   rv   N)rs  rt  ru  rv  r  rx  rv   rk   r3   r   r   y  s    #rk   r   c                   &    \ rS rSrS rS rS rSrg)SubArrayFormati~  c                 8    Xl         US   U l        US   U l        g )NrX   rY   )r   rX   r-  )r   r   rc   s      r3   r9  SubArrayFormat.__init__  s     . -!+.rk   c                 j    UR                   U R                  :  a  SOSU l        U R                  U5      $ )Nr   r   )r   rX   r   format_array)r   r   s     r3   rp  SubArrayFormat.__call__  s,    '(vv'>eB  ##rk   c                    [         R                  " U5      S:X  a  U R                  U5      $ U R                  (       a  UR                  S   SU R
                  -  :  al  US U R
                    Vs/ s H  o R                  U5      PM     snU R                  /-   XR
                  * S   Vs/ s H  o R                  U5      PM     sn-   nO U Vs/ s H  o R                  U5      PM     nnSSR                  U5      -   S-   $ s  snf s  snf s  snf )Nr   r~   r  r-   r  )rT   r   r   r   r   r-  r  rJ   )r   r   a_	formatteds       r3   r  SubArrayFormat.format_array  s    771:?''**1771:$//0A#A123CDOO1DE1D2""2&1DE&&'(34oo5E5F3GH3GR$$R(3GHI  :;;2**2.I;TYYy))C// FH <s   .D )DD
)r-  r   r   rX   N)rs  rt  ru  rv  r9  rp  r  rx  rv   rk   r3   r  r  ~  s    /
$0rk   r  c                   4    \ rS rSrSrS r\S 5       rS rSr	g)r   i  z
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                     Xl         g r   format_functions)r   r  s     r3   r9  StructuredVoidFormat.__init__  s     0rk   c                     / nUR                   R                   HK  n[        X   40 UD6nUR                   U   R                  S:w  a  [	        U40 UD6nUR                  U5        MM     U " U5      $ )z
This is a second way to initialize StructuredVoidFormat,
using the raw data as input. Added to avoid changing
the signature of __init__.
rv   )r   r   r   r   r  append)clsr   rc   r  
field_namer   s         r3   r   StructuredVoidFormat.from_data  sr     ****J243COwOOzz*%++r1"0"LG"L##O4	 +
 #$$rk   c                     [        XR                  5       VVs/ s H  u  p#U" U5      PM     nnn[        U5      S:X  a  SR                  US   5      $ SR                  SR	                  U5      5      $ s  snnf )Nr   z({},)r   z({})r-   )r\  r  r   r0   rJ   )r   r   fieldr   
str_fieldss        r3   rp  StructuredVoidFormat.__call__  su     +.a1F1F*G
*G& E"*G 	 
 z?a>>*Q-00==:!677
s   A3r  N)
rs  rt  ru  rv  rw  r9  classmethodr   rp  rx  rv   rk   r3   r   r     s%    1 % %8rk   r   c                 J   [         R                  " 5       R                  5       nUS   S::  a&  [        R                  " [        U 5      40 UD6" U 5      $ UR                  S5      c  0 US'   US   R                  S[        5        [        R                  " [        U 5      40 UD6" U 5      nU(       d  U$ [        U 5      nUR                  R                  SS5      S-   UR                  -   n[        R                  " [        R                  U R                  45      nU SU S	U< S
3$ )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.
r9   rB   r^   r   rg   rT   r>  (z, dtype=))r&   rm   rs   r   r   r   
setdefaultr   r   rt  replacers  rT   r   r   )r   is_reprrc   val_reprr  cls_fqn
void_dtypes          r3   _void_scalar_to_stringr    s       "'')GxC#--eAhB'B1EE{{;'!K##L#6#--eAhB'B1EH
q'Cnn$$Wd3c9CLLHG277AGG,-JYaz*q99rk   c                 
   [         R                  " U 5      n [        R                  " 5       S   S::  a  U R                  [         R
                  :X  a  gU R                  b  gU R                  (       d  gU R                  [        ;   $ )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
--------
>>> import numpy as np
>>> 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)
r9   r>   F)	rT   r   r&   rm   r   rH   r   isnative_typelessdata)r   s    r3   dtype_is_impliedr    sc    6 HHUOEH%,rww1F {{ >>::&&rk   c                    [        U 5      R                  [        R                  R                  :w  a  [	        U 5      $ U R
                  b  [        U 5      $ [        U R                   [        5      (       a  S[        U 5      -  $ U R                  nU R                  (       d  S[        U 5      -  $ U(       a8  US   R                  5       (       a  UR                  5       (       d  [	        U5      nU$ )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
r  r   )r   __repr__rT   r   r   r   r   r   r#   r1  r  isalphaisalnum)r   typenames     r3   dtype_short_reprr    s     E{rxx000E{{{5z	EJJ	)	)E
""zzH>> E
""!,,..83C3C3E3E>Ork   c           
      <   [         R                  " 5       nUS   nUb  U" U 5      $ Uc  US   n[        U 5      [        La  [        U 5      R                  nOSnUS-   nUS   S::  aE  U R
                  S:X  a5  U R                  R                  (       d  [        U R                  5       5      n	O
U" XX#SUS	S
9n	/ n
U R                  S:X  a  U R
                  S:w  d  US   S:  a1  U R                  US   :  a  U
R                  SU R
                   35        [        U R                  5      (       a  U R                  S:X  a'  U
R                  S[        U R                  5       35        U
(       d  X-   S	-   $ X-   S-   nSR                  U
5      S	-   n[        U5      UR!                  S5      S-   -
  nSnUS   S::  a;  [#        U R                  R                  [$        5      (       a  SS[        U5      -  -   nO&U[        U5      -   S-   U:  a  SS[        U5      -  -   nX-   U-   $ )zEInternal version of array_repr() that allows overriding array2string.r`   rZ   r   r  r9   r>   rv   r-   r  )r   r   )r      rX   zshape=zdtype=,r  r   r8   )r&   rm   r   r   rs  r   r   r   r   r   r   r  r  r  rJ   r   rfindr   r#   )arrr   rD   r   r   rj  r`   
class_namer   r   extrasarr_str	extra_strlast_line_lenspacers                  r3   _array_repr_implementationr  !  s    %((*O#O4M S!!(5Cy#Y''

#F!S(IIOCIIOO388:3	5
 FA#))t+x(3.?;77syyk*+CII&&#((a-/		:;<=|c!!lS G		&!C'I LGMM$$7!$;<MFx C'ciinnh//CFO+F	Y	'!	+n	<CK'i''rk   c                     U 4$ r   rv   r  r   rD   r   s       r3   _array_repr_dispatcherr   W  s	    6Mrk   c                     [        XX#5      $ )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
--------
>>> import numpy as np
>>> 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.      ])'

)r  r  s       r3   r   r   \  s    \ &Y8 8rk   c                 X    [        U [        5      (       a  [        U 5      $ [        U 5      $ r   )rP   bytesr   r   )rb   s    r3   _guarded_repr_or_strr    s!    !UAwq6Mrk   c                 J   [         R                  " 5       S   S::  aD  U R                  S:X  a4  U R                  R                  (       d  [        U R                  5       5      $ U R                  S:X  a)  [        [        R                  R                  U S5      5      $ U" XX#SS5      $ )zDInternal version of array_str() that allows overriding array2string.r9   r>   rv   r8   r   )r&   rm   r   r   r   r   r   r  rT   r   __getitem__)r   r   rD   r   r   s        r3   _array_str_implementationr    s{     	X&#-GGrM!''--1668}
 	ww"} $BJJ$:$:1b$ABB9c2NNrk   c                     U 4$ r   rv   r   r   rD   r   s       r3   _array_str_dispatcherr
    s	    4Krk   c                     [        XX#5      $ )a  
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
--------
>>> import numpy as np
>>> np.array_str(np.arange(3))
'[0 1 2]'

)r  r	  s       r3   r   r     s    J %	96 6rk   __wrapped__)r   )NNNNNNNNNNNN)
NNNNNNNNNN)rv   )r   )r8   r   )NTra   FNNN)NTTra   FNNN)T)NNN)`rw  __all____docformat__r   rQ   rK   _threadr   ImportError_dummy_threadrg   rT   r   r   r   umathr   r   r   r   r   r   r   r   r   r   r   fromnumericr   numericr   r   r   r   r   r    r!   r"   r#   r  r$   r%   r   r&   rV   rM   
contextlibrf   r   rj   r   rw   contextmanagerr   r   r   r   r   r   r   r   r   r  r   r  r  r   r2  r   r	   r   r   r   r   r  r   r   r  r   r  rH   r  r  r  r  r   r   r  r  r
  r   getattr_array2string_implpartial_default_array_str_default_array_reprrv   rk   r3   <module>r     s  
A #    
(!  ! 3 3 E E  3 3% % : (    BFJNIM%)<~ G?C;?GKuB  $4uB uBp AE<@HL+ !%D+( G- -`*
 G$  $DH(

0d&(R<  : +/48.2:>	
  1'B#'4 $B{{dddd2r8  	r8 Cr8j6zxR@ R@j GADBF'+ML ML` G6:<AFJYJ YJv% %&. . B: :4:_ :@#o #
0 04"8 "8J:. w
CHH5''TB !D!3(n BF
 /@.8 A.8b   $t!O* @D
 .w?%6 @%6R \=,G &&'@4FH ''(B5GI {5  (''(s   I I+*I+