
    Khu                    F	   S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J
r
Jr  SSKrSSKrSSKJrJr  SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSKJrJrJ r J!r!J"r"J#r#J$r$J%r%  SSKJ&r&J'r'J(r(  SSK)rSS	K*J+r+  SS
K,J-r-  SSK.J/r/  / SQr0 " S S\15      r2\2r3Sr4\Rj                  " \Rl                  5      Rn                  r8 \Rr                  Ru                  S5      r;Sr< \Rz                  S:  a!  \;R|                  R~                  R                  rAOISSKBrBSSKCrC\BR                  " \;R                  S5      =(       d    SS S9r>\>R~                  R                  rA \A(       d  \;R                  S5      \8:w  a  Sr<\R                  " 5       S;   rJ\R                  R                  S:H  rM\N" \S5      rO\P" \SS5      SL=(       a    \O(       + rQ\R                  R                  R                  rUSrV\R                  " S5      =(       d    SrXS\X;   a  SrV\Y" \R                  " S5      5      rZ\R                  " \R<                  5      R                  S:H  r]SkS  jr^\R                  S!:X  a    SlS" jr_SmS# jr`O0\R                  SS$ S%:X  a  S&\R                  " 5        S'34S( jr`OS) r`\R                  SS$ S%:X  a  S&\R                  " 5        S'3/ 4S* jrbO/ 4S+ jrb  SnS- jrcSoSS..S/ jjrdS0 reSpS1 jrf  SpS2 jrg  SqSS,S3.S4 jjrh\+" S5S6/S7S8/S9S:9SoSS..S; jj5       ri\+" S5S6/S7S8/S9S:9  SrS< j5       rjSoSS..S= jjrkS> rlS? rmSsS@ jrn/ 4SA jroSSKprp " SB SC\pR                  5      rr\r" SD5      rsSE rtSF ruStSG jrvSuSH jrwSI rx  SvSS..SJ jjrySwSK jrzSuSL jr{StSM jr|SN r}SO r~\R                  StSP j5       rSQ r\R                  StSR j5       rSS r\STSU4SV jr " SW SX\15      r\R                  SY 5       r\R                  SZ 5       r " S[ S\\GR                  5      r " S] S^5      r\R                  StS_ j5       rS` rSa rSb rSc rSd rSe rSf rSg r\" 5       rSh r   SxSi jrSySj jrg! \F a    SrA GNf = f! \Rr                  R                   a    S=r<rA GNf = f)zz*
Utility function to facilitate testing.

    N)partialwraps)mkdtempmkstemp)SkipTest)WarningMessage)intpfloat32emptyarange
array_reprndarrayisnatarray)isfiniteisnanisinf)_rename_parameter)pd_NA)StringIO)/assert_equalassert_almost_equalassert_approx_equalassert_array_equalassert_array_lessassert_string_equalassert_array_almost_equalassert_raisesbuild_err_msgdecorate_methodsjiffiesmemusageprint_assert_equalrundocs	runstringverbosemeasureassert_assert_array_almost_equal_nulpassert_raises_regexassert_array_max_ulpassert_warnsassert_no_warningsassert_allcloseIgnoreExceptionclear_and_catch_warningsr   KnownFailureExceptiontemppathtempdirIS_PYPYHAS_REFCOUNTIS_WASMsuppress_warningsassert_array_compareassert_no_gc_cyclesbreak_cyclesHAS_LAPACK64	IS_PYSTONIS_MUSLcheck_support_sveNOGIL_BUILDIS_EDITABLEIS_INSTALLED
NUMPY_ROOTrun_threadedIS_64BITc                       \ rS rSrSrSrg)r1   5   z<Raise this exception to mark a test as a known failing test. N__name__
__module____qualname____firstlineno____doc____static_attributes__rG       N/var/www/html/env/lib/python3.13/site-packages/numpy/testing/_private/utils.pyr1   r1   5   s    FrO   r1   numpyT)      zdirect_url.jsonz{}c                 .    [         R                  " S0 U D6$ )NrG   )typesSimpleNamespace)datas    rP   <lambda>rX   M   s    )>)>)F)FrO   )object_hookF)wasm32wasm64pypypyston_version_infogetrefcountHOST_GNU_TYPE muslPy_GIL_DISABLED   c                 `    SnU (       d   U" 5       n[        U5      eg! [          a    Un Nf = f)a1  
Assert that works in release mode.
Accepts callable msg to allow deferring evaluation until failure.

The Python built-in ``assert`` does not work when executing code in
optimized mode (the ``-O`` flag) - no byte-code is generated for it.

For documentation on usage, refer to the Python documentation.

TN)	TypeErrorAssertionError)valmsg__tracebackhide__smsgs       rP   r(   r(   n   sA     	5D T""   	D	s    --ntc                    SS K nUc  UR                  nUR                  XPUS X145      nUR                  5       n UR	                  X5      n	 UR                  U5        UR                  X5      u  pUUR                  U	5        UR                  U5        $ ! UR                  U	5        f = f! UR                  U5        f = f)Nr   )	win32pdhPDH_FMT_LONGMakeCounterPath	OpenQuery
AddCounterCollectQueryDataGetFormattedCounterValueRemoveCounter
CloseQuery)objectcounterinstanceinumformatmachinerm   pathhqhctyperg   s               rP   GetPerformanceAttributesr      s     	>**F''(D)-)8 9!		$$$R.B+))"-$==bI	&&r*# &&r*#s#   B* %B 1B* B''B* *B=c                 <    SS K n[        SSXUR                  S 5      $ )Nr   ProcesszVirtual Bytes)rm   r   rn   )processNamerx   rm   s      rP   r"   r"      s&    '	?(3(0(=(=tE 	ErO      linuxz/proc/z/statc                      [        U 5       nUR                  5       R                  S5      nSSS5        [        WS   5      $ ! , (       d  f       N= f! [         a     gf = f)z=
Return virtual memory size in bytes of the running python.

 N   )openreadlinesplitint	Exception)_proc_pid_statfls      rP   r"   r"      sV    
	n%JJL&&s+ &qu: &%  		s'   A  AA 
AA 
A! A!c                      [         e)z;
Return memory usage of running python. [Not implemented]

)NotImplementedErrorrG   rO   rP   r"   r"      s
    
 "!rO   c                 `   SSK nU(       d  UR                  UR                  5       5         [        U 5       nUR                  5       R	                  S5      nSSS5        [        WS   5      $ ! , (       d  f       N= f! [         a%    [        SUR                  5       US   -
  -  5      s $ f = f)
Return number of jiffies elapsed.

Return number of jiffies (1/100ths of a second) that this
process has been scheduled in user mode. See man 5 proc.

r   Nr   rS   d   )timeappendr   r   r   r   r   )r   
_load_timer   r   r   s        rP   r!   r!      s     	diik*	<n%JJL&&s+ &qu: &%  	<sdiikJqM9:;;	<s(   A>  A-A> -
A;7A> >,B-,B-c                     SSK nU (       d  U R                  UR                  5       5        [        SUR                  5       U S   -
  -  5      $ )r   r   Nr   )r   r   r   )r   r   s     rP   r!   r!      s=     	diik*3$))+
15677rO   ACTUALDESIREDc                    SU-   /n[        U5      nU(       aN  UR                  S5      S:X  a(  [        U5      S[        U5      -
  :  a  US   S-   U-   /nOUR                  U5        U(       a  [	        U 5       H  u  px[        U[        5      (       a  [        [        US9n	O[        n	 U	" U5      n
U
R                  S5      S
:  a'  SR                  U
R                  5       S S
 5      n
U
S-  n
UR                  SXG    SU
 35        M     SR                  U5      $ ! [         a&  nS[        U5      R                   SU S	3n
 S nANS nAff = f)N
O   r   r   )	precisionz[repr failed for <z>: ]rR   z...: )strfindlenr   	enumerate
isinstancer   r   r   reprr   r   rI   countjoin
splitlines)arrayserr_msgheaderr&   namesr   rh   iar_funcrexcs               rP   r   r      s4   &=/C'lG<<#GrCK7G(Gq6C<')*CJJwf%DA!W%% yAE1I wwt}q IIallnRa01U
JJ58*Bqc*+ &  99S>  E(a)9)9(:#cU!DEs   )D
E%EEstrictc          	      6   Sn[        U[        5      (       a  [        U [        5      (       d  [        [        [	        U 5      5      5      e[        [        U 5      [        U5      X#5        UR                  5        H7  u  pgX`;  a  [        [        U5      5      e[        X   X   SU< SU 3U5        M9     g[        U[        [        45      (       ao  [        U [        [        45      (       aT  [        [        U 5      [        U5      X#5        [        [        U5      5       H  n[        X   X   SU< SU 3U5        M     gSSKJnJn	Jn
  SSKJnJnJn  [        X5      (       d  [        X5      (       a  ['        XX#US	9$ [)        X/X#S
9n U" U 5      =(       d    U" U5      nU(       a]  U" U 5      (       a  U" U 5      nU" U 5      nOU nSnU" U5      (       a  U" U5      nU" U5      nOUnSn [        UU5        [        UU5        U	" U5      U	" U 5      :w  a  [        U5      e [/        U5      n[/        U 5      n[0        R2                  " U5      R4                  R                  [0        R2                  " U 5      R4                  R                  :H  nU(       a  U(       a  U(       a  g[        U5      e [9        U5      n[9        U 5      nU(       a  U(       a  g[0        R2                  " U 5      n[0        R2                  " U5      nUR4                  R:                  S;   d  UR4                  R:                  S;   a  [7        S5      eUS:X  a#  U S:X  a  U
" U5      U
" U 5      :X  d  [        U5      e X:X  d  [        U5      eg! [*        [,        4 a    Sn GNf = f! [         a    [        U5      ef = f! [,        [*        [6        4 a     GNf = f! [,        [*        [6        4 a     Nwf = f! [<        [>        4 a$  nSUR@                  S   ;   a  [        U5      ee SnAff = f)a$  
Raises an AssertionError if two objects are not equal.

Given two objects (scalars, lists, tuples, dictionaries or numpy arrays),
check that all elements of these objects are equal. An exception is raised
at the first conflicting values.

This function handles NaN comparisons as if NaN was a "normal" number.
That is, AssertionError is not raised if both objects have NaNs in the same
positions.  This is in contrast to the IEEE standard on NaNs, which says
that NaN compared to anything must return False.

Parameters
----------
actual : array_like
    The object to check.
desired : array_like
    The expected object.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.
strict : bool, optional
    If True and either of the `actual` and `desired` arguments is an array,
    raise an ``AssertionError`` when either the shape or the data type of
    the arguments does not match. If neither argument is an array, this
    parameter has no effect.

    .. versionadded:: 2.0.0

Raises
------
AssertionError
    If actual and desired are not equal.

See Also
--------
assert_allclose
assert_array_almost_equal_nulp,
assert_array_max_ulp,

Notes
-----
By default, when one of `actual` and `desired` is a scalar and the other is
an array, the function checks that each element of the array is equal to
the scalar. This behaviour can be disabled by setting ``strict==True``.

Examples
--------
>>> np.testing.assert_equal([4, 5], [4, 6])
Traceback (most recent call last):
    ...
AssertionError:
Items are not equal:
item=1
 ACTUAL: 5
 DESIRED: 6

The following comparison does not raise an exception.  There are NaNs
in the inputs, but they are in the same positions.

>>> np.testing.assert_equal(np.array([1.0, 2.0, np.nan]), [1, 2, np.nan])

As mentioned in the Notes section, `assert_equal` has special
handling for scalars when one of the arguments is an array.
Here, the test checks that each value in `x` is 3:

>>> x = np.full((2, 5), fill_value=3)
>>> np.testing.assert_equal(x, 3)

Use `strict` to raise an AssertionError when comparing a scalar with an
array of a different shape:

>>> np.testing.assert_equal(x, 3, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal
<BLANKLINE>
(shapes (2, 5), () mismatch)
 ACTUAL: array([[3, 3, 3, 3, 3],
       [3, 3, 3, 3, 3]])
 DESIRED: array(3)

The `strict` parameter also ensures that the array data types match:

>>> x = np.array([2, 2, 2])
>>> y = np.array([2., 2., 2.], dtype=np.float32)
>>> np.testing.assert_equal(x, y, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal
<BLANKLINE>
(dtypes int64, float32 mismatch)
 ACTUAL: array([2, 2, 2])
 DESIRED: array([2., 2., 2.], dtype=float32)
Tzkey=r   Nzitem=r   )r   isscalarsignbitiscomplexobjrealimagr   r&   FMmz0cannot compare to a scalar with a different typezelementwise == comparison)!r   dictrf   r   r   r   r   itemslisttuplerangenumpy._corer   r   r   rQ   r   r   r   r   r   
ValueErrorre   r   npasarraydtyper   r   charDeprecationWarningFutureWarningargs)actualdesiredr   r&   r   ri   kr   r   r   r   r   r   r   rh   
usecomplexactualractualidesiredrdesirediisdesnatisactnatdtypes_matchisdesnanisactnanarray_actualarray_desiredes                               rP   r   r      s   F '4  &$'' d6l!344S[#g,AMMODA$T!W--GJ$qe2gY0G " $
 	'D%=))j$.O.OS[#g,As7|$AGJ%uBwi0H " % 	66..&""j&B&B!&7)/1 	1
)7
DC
!&)B\'-B
 6lG6lGGG  G}HG}HHH	&(+(+
 HV,,S!!>=

7+1166

6*00556 $S))>= zz&)

7+##t+##((D0 & '> ? ? a<FaK7#wv6$S))

! %% "O 	" 
&  	& %%	&( z#67 6 z#67  . &!&&)3 %%sh   
M; -N #B N- $N- 0$O	 BO	 *O$ ;NNN*-OO	O! O!$P4PPc                    SnSSK nX:X  dz  [        5       nUR                  U 5        UR                  S5        UR                   " X5        UR                  S5        UR                   " X%5        [        UR	                  5       5      eg)a]  
Test if two objects are equal, and print an error message if test fails.

The test is performed with ``actual == desired``.

Parameters
----------
test_string : str
    The message supplied to AssertionError.
actual : object
    The object to test for equality against `desired`.
desired : object
    The expected result.

Examples
--------
>>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 1])
>>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 2])
Traceback (most recent call last):
...
AssertionError: Test XYZ of func xyz failed
ACTUAL:
[0, 1]
DESIRED:
[0, 2]

Tr   Nz failed
ACTUAL: 
z
DESIRED: 
)pprintr   writerf   getvalue)test_stringr   r   ri   r   rh   s         rP   r#   r#     sm    8 j		+		'(f"		- g#S\\^,, rO   c                   ^ ^^^^ SnSSK Jn  SSKJnJnJn	   U" T 5      =(       d    U" T5      n
U UUUU4S jnU
(       aY  U" T 5      (       a  U" T 5      nU	" T 5      nOT nSnU" T5      (       a  U" T5      nU	" T5      nOTnSn [        XTS9  [        XTS9  [        T U[        [        45      (       d  [        TU[        [        45      (       a  [        T TTT5      $  [        T5      (       a  [        T 5      (       di  [        T5      (       d  [        T 5      (       a2  [        T5      (       a  [        T 5      (       d  [        U" 5       5      e gTT :X  d  [        U" 5       5      eg [#        TT -
  5      [$        R&                  " S	S
T* -  -  5      :  a  [        U" 5       5      eg! [         a    Sn
 GNf = f! [         a    [        U" 5       5      ef = f! [        [         4 a     Nf = f)aj  
Raises an AssertionError if two items are not equal up to desired
precision.

.. note:: It is recommended to use one of `assert_allclose`,
          `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
          instead of this function for more consistent floating point
          comparisons.

The test verifies that the elements of `actual` and `desired` satisfy::

    abs(desired-actual) < float64(1.5 * 10**(-decimal))

That is a looser test than originally documented, but agrees with what the
actual implementation in `assert_array_almost_equal` did up to rounding
vagaries. An exception is raised at conflicting values. For ndarrays this
delegates to assert_array_almost_equal

Parameters
----------
actual : array_like
    The object to check.
desired : array_like
    The expected object.
decimal : int, optional
    Desired precision, default is 7.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.

Raises
------
AssertionError
  If actual and desired are not equal up to specified precision.

See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
                 relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

Examples
--------
>>> from numpy.testing import assert_almost_equal
>>> assert_almost_equal(2.3333333333333, 2.33333334)
>>> assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 10 decimals
 ACTUAL: 2.3333333333333
 DESIRED: 2.33333334

>>> assert_almost_equal(np.array([1.0,2.3333333333333]),
...                     np.array([1.0,2.33333334]), decimal=9)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 9 decimals
<BLANKLINE>
Mismatched elements: 1 / 2 (50%)
Max absolute difference among violations: 6.66669964e-09
Max relative difference among violations: 2.85715698e-09
 ACTUAL: array([1.         , 2.333333333])
 DESIRED: array([1.        , 2.33333334])

Tr   )r   r   Fc                  *   > ST-  n [        TT/TTU S9$ )N*Arrays are not almost equal to %d decimals)r&   r   )r   )r   r   decimalr   r   r&   s    rP   _build_err_msg+assert_almost_equal.<locals>._build_err_msgI  s(    >Hfg.$*, 	,rO   )r   N      ?      $@)r   r   rQ   r   r   r   r   r   rf   r   r   r   r   r   r   r   re   absr   float64)r   r   r   r   r&   ri   r   r   r   r   r   r   r   r   r   r   s   `````           rP   r   r     s   J #..
!&)B\'-B
, ,
 6lG6lGGG  G}HG}HHH	37C7C &7E4011'GUD#9::('7KK !!hv&6&6W~~vg5==()9:: ,9
  &(()9:: '7 7V

31A+A BB^-.. CY  
0  	3 !122	3$  + s6   F) F< !A1G G )F98F9<GG-,G-c           	      h   SnSSK n[        [        X45      u  pX:X  a  gUR                  " SS9   SUR                  " U5      UR                  " U 5      -   -  nUR
                  " SUR                  " UR                  " U5      5      5      nSSS5         UW-  n U W-  n	[        X/US	U-  US
9n
 [        U5      (       a  [        U 5      (       d^  [        U5      (       d  [        U 5      (       a-  [        U5      (       a  [        U 5      (       d  [        U
5      e gX:X  d  [        U
5      eg UR                  " X-
  5      UR
                  " SUS-
  * 5      :  a  [        U
5      eg! , (       d  f       N= f! [         a    Sn Nf = f! [         a    Sn	 Nf = f! [        [        4 a     Nf = f)a  
Raises an AssertionError if two items are not equal up to significant
digits.

.. note:: It is recommended to use one of `assert_allclose`,
          `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
          instead of this function for more consistent floating point
          comparisons.

Given two numbers, check that they are approximately equal.
Approximately equal is defined as the number of significant digits
that agree.

Parameters
----------
actual : scalar
    The object to check.
desired : scalar
    The expected object.
significant : int, optional
    Desired precision, default is 7.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.

Raises
------
AssertionError
  If actual and desired are not equal up to specified precision.

See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
                 relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

Examples
--------
>>> np.testing.assert_approx_equal(0.12345677777777e-20, 0.1234567e-20)
>>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345671e-20,
...                                significant=8)
>>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345672e-20,
...                                significant=8)
Traceback (most recent call last):
    ...
AssertionError:
Items are not equal to 8 significant digits:
 ACTUAL: 1.234567e-21
 DESIRED: 1.2345672e-21

the evaluated condition that raises the exception is

>>> abs(0.12345670e-20/1e-21 - 0.12345672e-20/1e-21) >= 10**-(8-1)
True

Tr   Nignore)invalidg      ?
   g        z-Items are not equal to %d significant digits:)r   r&   r      )rQ   mapfloaterrstater   powerfloorlog10ZeroDivisionErrorr   r   r   rf   re   r   )r   r   significantr   r&   ri   r   scale
sc_desired	sc_actualrh   s              rP   r   r   v  s   v EF#45V 
X	&rvvg78RXXbhhuo67 
'u_
UN	 	7>LC !!hv&6&6W~~vg5==(-- ,9
  ((-- '7 
vvj$%#q7I)JJS!! K; 
'	&
  
  	$ *+ sI   AE)E: F 1A,F F )
E7:F	F	FFF10F1)r   r   c	          
        ^^^^^
^2 SnSSK JnJnJm2JnJnJnJn  [        R                  " U5      n[        R                  " U5      nXnnS nS nS nUS4UUU
UU4S jjn U	(       a:  UR                  UR                  :H  =(       a    UR                  UR                  :H  nOEUR                  S	:H  =(       d    UR                  S	:H  =(       d    UR                  UR                  :H  nU(       dr  UR                  UR                  :w  a  S
UR                   SUR                   S3nOSUR                   SUR                   S3n[        X/TU-   TTT
TS9n[        U5      e[        R                  " S5      nU" U5      (       aC  U" U5      (       a6  U(       a  U" XUSS9nU(       a  UU" XU24S jSS9-  nUU" XU24S jSS9-  nGO,U" U5      (       aO  U" U5      (       aB  U(       a:  UR                  R                  UR                  R                  :X  a  U" X[         SS9nOU" U5      (       a  U" U5      (       a  UR                  nU(       a  UUR                  :X  a  [#        US5      (       a  [%        UR&                  [(        5      =(       a     [        R                  " UR&                  5      nSn [        UR&                  5        U(       d  U(       a  U" XXR                  R&                  S9nUR,                  S:  a  UU)    UU)    p!UR.                  S:X  a  g OU(       a  g U " X5      n[        R0                  " U5      n [%        U[        5      (       a  Un[3        U/5      n!O UR5                  5       n!U!R                  5       nUS:w  Ga_  U!R.                  U!R7                  [8        S9-
  n"UR,                  S:w  a  UR.                  OU!R.                  n#SU"-  U#-  n$SR;                  U"U#U$5      /n%U" SS9   [<        R>                  " [*        5         [A        X-
  5      n&[        RB                  " UR                  [        RD                  5      (       a#  [A        X!-
  5      n'[        RF                  " U&U'U&S9  U&U    n(U" U(5      n)[I        U&SU5      U:X  a  U%RK                  S[M        U)5      -   5        OU%RK                  SU" U)5      -   5        [        R                  " US:g  5      n*[        RN                  " U U*5      n+U" U+) 5      (       a  [3        T25      n,O?U&U+   n-[        RP                  " UU&R                  5      n.U.U+   n/U" U-[A        U/5      -  5      n,[I        U&SU5      U:X  a  U%RK                  S [M        U,5      -   5        OU%RK                  S U" U,5      -   5        S S S 5        S S S 5        [M        T5      mTS!S!RS                  U%5      -   -  m[        UU/TTTT
TS9n[        U5      eg ! [*         a    Sn GN6f = f! , (       d  f       Ng= f! , (       d  f       Np= f! [T         a7    SS K+n0U0RY                  5       n1S"U1 S#T 3m[        X/TTTT
TS9n[U        U5      ef = f)$NTr   )array2stringr   infr   allmaxobject_c                 4    U R                   R                  S;   $ )Nz?bhilqpBHILQPefdgFDGr   r   xs    rP   isnumber&assert_array_compare.<locals>.isnumber  s    ww||555rO   c                 4    U R                   R                  S;   $ )Nr   r  r  s    rP   istime$assert_array_compare.<locals>.istime  s    ww||t##rO   c                 4    U R                   R                  S:H  $ )NTr  r  s    rP   	isvstring'assert_array_compare.<locals>.isvstring  s    ww||s""rO   nanc           	        > SnU" U 5      nU" U5      n[         R                  " XV:H  5      R                  5       S:w  a   [        X/TSU-  -   TT	T
TS9n[	        U5      e[        U[        5      (       d  UR                  S:X  a  [         R                  " U5      $ [        U[        5      (       d  UR                  S:X  a  [         R                  " U5      $ U$ )zsHandling nan/inf.

Combine results of running func on x and y, checking that they are True
at the same locations.

Tz
%s location mismatch:r&   r   r   r   r   )r   boolr  r   rf   r   ndim)r  yfunchasvalri   x_idy_idrh   r   r   r   r   r&   s           rP   func_assert_same_pos2assert_array_compare.<locals>.func_assert_same_pos  s     !AwAw 774< $$&$.3 $+F#%C !%% dD!!TYY!^774= d##tyyA~774= KrO   rG   z	
(shapes z, z
 mismatch)z	
(dtypes r  F)r  r  c                    > U T7:H  $ NrG   xyr   s    rP   rX   &assert_array_compare.<locals>.<lambda>0      sd
rO   z+infc                    > U T* :H  $ r  rG   r  s    rP   rX   r!  3  r"  rO   z-infNaT	na_objectr   r   r   z&Mismatched elements: {} / {} ({:.3g}%)r   )r  outr   z*Max absolute difference among violations: z*Max relative difference among violations: r   zerror during assertion:

z

)-r   r   r   r   r   r  r  r  r   
asanyarrayshaper   r   rf   r  r   r   hasattrr   r%  r   re   r  sizelogical_notr   ravelsumr	   rz   
contextlibsuppressr   
issubdtypeunsignedintegerminimumgetattrr   r   logical_andbroadcast_tor   r   	traceback
format_exc)3
comparisonr  r  r   r&   r   r   	equal_nan	equal_infr   r   ri   r   r   r   r  r  r  oxoyr  r  r  r  condreasonrh   flaggeddtis_nanbool_errorsrg   invalidsreduced
n_mismatch
n_elementspercent_mismatchremarkserrorerror2reduced_errormax_abs_errornonzerononzero_and_invalidmax_rel_errornonzero_invalid_errorbroadcasted_ynonzero_invalid_yr8  efmtr   s3      ````   `                                       @rP   r8   r8     s    / / / 	aA
aA B6$# ).e % %NJ77agg%<!''QWW*<DGGrM2QWW]Iqww!''7IDww!''!%aggYb	D%aggYb	D '"(!)(/&+*35C !%%''%.A;;8A;;.q%N/5J7=? ? /5J7=? ? AYY6!99QWW\\QWW\\9.q%Nq\\illBR177]wr;/G/G$R\\59 1((2<<0 $& [251B1BDG <<!gX;7(qvv{ >>#&c4  DSElGiikG;;=D 4< $(??J)0):J"Z/*<8??
,<>?G h'((3JE}}QWWb.@.@AA!$QU

5&e<$)(OM$'$6Mugw77BH!-012  H*=9:; !gga1foG*,..7*K'//00(-c
056I0J-(*5;;(G,9:M,N)(+,A.12C.D-E )F ugw77BH!-012  H*=9:;K 4 (T 'lGtdii000GR'(/&+*35C !%%q = ! $"#K$P 43 ('b  ##%.tfDAQFGWV"'9>osr   "IX& 5W1 
AX& X& (CX& ;XFX#X+AX& 1X=X&  XX& 
X	X
X#X& &AY'r  r  r   r   z2.0.0)dep_versionc          
      @    Sn[        [        R                  XUUSUS9  g)a`  
Raises an AssertionError if two array_like objects are not equal.

Given two array_like objects, check that the shape is equal and all
elements of these objects are equal (but see the Notes for the special
handling of a scalar). An exception is raised at shape mismatch or
conflicting values. In contrast to the standard usage in numpy, NaNs
are compared like numbers, no assertion is raised if both objects have
NaNs in the same positions.

The usual caution for verifying equality with floating point numbers is
advised.

.. note:: When either `actual` or `desired` is already an instance of
    `numpy.ndarray` and `desired` is not a ``dict``, the behavior of
    ``assert_equal(actual, desired)`` is identical to the behavior of this
    function. Otherwise, this function performs `np.asanyarray` on the
    inputs before comparison, whereas `assert_equal` defines special
    comparison rules for common Python types. For example, only
    `assert_equal` can be used to compare nested Python lists. In new code,
    consider using only `assert_equal`, explicitly converting either
    `actual` or `desired` to arrays if the behavior of `assert_array_equal`
    is desired.

Parameters
----------
actual : array_like
    The actual object to check.
desired : array_like
    The desired, expected object.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.
strict : bool, optional
    If True, raise an AssertionError when either the shape or the data
    type of the array_like objects does not match. The special
    handling for scalars mentioned in the Notes section is disabled.

    .. versionadded:: 1.24.0

Raises
------
AssertionError
    If actual and desired objects are not equal.

See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
                 relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

Notes
-----
When one of `actual` and `desired` is a scalar and the other is array_like,
the function checks that each element of the array_like object is equal to
the scalar. This behaviour can be disabled with the `strict` parameter.

Examples
--------
The first assert does not raise an exception:

>>> np.testing.assert_array_equal([1.0,2.33333,np.nan],
...                               [np.exp(0),2.33333, np.nan])

Assert fails with numerical imprecision with floats:

>>> np.testing.assert_array_equal([1.0,np.pi,np.nan],
...                               [1, np.sqrt(np.pi)**2, np.nan])
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal
<BLANKLINE>
Mismatched elements: 1 / 3 (33.3%)
Max absolute difference among violations: 4.4408921e-16
Max relative difference among violations: 1.41357986e-16
 ACTUAL: array([1.      , 3.141593,      nan])
 DESIRED: array([1.      , 3.141593,      nan])

Use `assert_allclose` or one of the nulp (number of floating point values)
functions for these cases instead:

>>> np.testing.assert_allclose([1.0,np.pi,np.nan],
...                            [1, np.sqrt(np.pi)**2, np.nan],
...                            rtol=1e-10, atol=0)

As mentioned in the Notes section, `assert_array_equal` has special
handling for scalars. Here the test checks that each value in `x` is 3:

>>> x = np.full((2, 5), fill_value=3)
>>> np.testing.assert_array_equal(x, 3)

Use `strict` to raise an AssertionError when comparing a scalar with an
array:

>>> np.testing.assert_array_equal(x, 3, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal
<BLANKLINE>
(shapes (2, 5), () mismatch)
 ACTUAL: array([[3, 3, 3, 3, 3],
       [3, 3, 3, 3, 3]])
 DESIRED: array(3)

The `strict` parameter also ensures that the array data types match:

>>> x = np.array([2, 2, 2])
>>> y = np.array([2., 2., 2.], dtype=np.float32)
>>> np.testing.assert_array_equal(x, y, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not equal
<BLANKLINE>
(dtypes int64, float32 mismatch)
 ACTUAL: array([2, 2, 2])
 DESIRED: array([2., 2., 2.], dtype=float32)
TzArrays are not equal)r   r&   r   r   N)r8   operator__eq__)r   r   r   r&   r   ri   s         rP   r   r     s&    x &7!(1G &(rO   c           
      n   ^^^^	^
 SnSSK Jm	Jm
  SSKJm  SSKJm  UUUU	U
4S jn[        X`XUST-  TS9  g	)
a	  
Raises an AssertionError if two objects are not equal up to desired
precision.

.. note:: It is recommended to use one of `assert_allclose`,
          `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
          instead of this function for more consistent floating point
          comparisons.

The test verifies identical shapes and that the elements of ``actual`` and
``desired`` satisfy::

    abs(desired-actual) < 1.5 * 10**(-decimal)

That is a looser test than originally documented, but agrees with what the
actual implementation did up to rounding vagaries. An exception is raised
at shape mismatch or conflicting values. In contrast to the standard usage
in numpy, NaNs are compared like numbers, no assertion is raised if both
objects have NaNs in the same positions.

Parameters
----------
actual : array_like
    The actual object to check.
desired : array_like
    The desired, expected object.
decimal : int, optional
    Desired precision, default is 6.
err_msg : str, optional
  The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.

Raises
------
AssertionError
    If actual and desired are not equal up to specified precision.

See Also
--------
assert_allclose: Compare two array_like objects for equality with desired
                 relative and/or absolute precision.
assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal

Examples
--------
the first assert does not raise an exception

>>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan],
...                                      [1.0,2.333,np.nan])

>>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
...                                      [1.0,2.33339,np.nan], decimal=5)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 5 decimals
<BLANKLINE>
Mismatched elements: 1 / 3 (33.3%)
Max absolute difference among violations: 6.e-05
Max relative difference among violations: 2.57136612e-05
 ACTUAL: array([1.     , 2.33333,     nan])
 DESIRED: array([1.     , 2.33339,     nan])

>>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
...                                      [1.0,2.33333, 5], decimal=5)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not almost equal to 5 decimals
<BLANKLINE>
nan location mismatch:
 ACTUAL: array([1.     , 2.33333,     nan])
 DESIRED: array([1.     , 2.33333, 5.     ])

Tr   )numberresult_type)r2  )anyc                 (  >  T" [        U 5      5      (       d  T" [        U5      5      (       a`  [        U 5      n[        U5      nX#:H  R                  5       (       d  gU R                  UR                  s=:X  a  S:X  a  O  OX:H  $ X)    n X)    nT
" US5      n[
        R                  " X5      n[        X-
  5      nT" UR                  T	5      (       d  UR                  [
        R                  5      nUSST* -  -  :  $ ! [        [        4 a     Nf = f)NFr   g      ?r   r   )r   r  r,  re   r   r   r)  r   r   astyper   )r  r  xinfidyinfidr   zr   r2  npanyr[  r\  s         rP   compare*assert_array_almost_equal.<locals>.comparez  s    	U1X%a//qq(--// 66QVV(q(6MgJgJ Ar"MM!#J!''6**$A3)))) ./ 		s   AC> 'C> 
C> >DDr   )r   r&   r   r   N)r   r[  r\  numpy._core.numerictypesr2  numpy._core.fromnumericr]  r8   )r   r   r   r   r&   ri   rd  r2  rc  r[  r\  s     `    @@@@rP   r   r   &  s;    ^ /34* *4 '!(AGK rO   c                D    Sn[        [        R                  XUUSSUSS9	  g)a  
Raises an AssertionError if two array_like objects are not ordered by less
than.

Given two array_like objects `x` and `y`, check that the shape is equal and
all elements of `x` are strictly less than the corresponding elements of
`y` (but see the Notes for the special handling of a scalar). An exception
is raised at shape mismatch or values that are not correctly ordered. In
contrast to the  standard usage in NumPy, no assertion is raised if both
objects have NaNs in the same positions.

Parameters
----------
x : array_like
  The smaller object to check.
y : array_like
  The larger object to compare.
err_msg : string
  The error message to be printed in case of failure.
verbose : bool
    If True, the conflicting values are appended to the error message.
strict : bool, optional
    If True, raise an AssertionError when either the shape or the data
    type of the array_like objects does not match. The special
    handling for scalars mentioned in the Notes section is disabled.

    .. versionadded:: 2.0.0

Raises
------
AssertionError
  If x is not strictly smaller than y, element-wise.

See Also
--------
assert_array_equal: tests objects for equality
assert_array_almost_equal: test objects for equality up to precision

Notes
-----
When one of `x` and `y` is a scalar and the other is array_like, the
function performs the comparison as though the scalar were broadcasted
to the shape of the array. This behaviour can be disabled with the `strict`
parameter.

Examples
--------
The following assertion passes because each finite element of `x` is
strictly less than the corresponding element of `y`, and the NaNs are in
corresponding locations.

>>> x = [1.0, 1.0, np.nan]
>>> y = [1.1, 2.0, np.nan]
>>> np.testing.assert_array_less(x, y)

The following assertion fails because the zeroth element of `x` is no
longer strictly less than the zeroth element of `y`.

>>> y[0] = 1
>>> np.testing.assert_array_less(x, y)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not strictly ordered `x < y`
<BLANKLINE>
Mismatched elements: 1 / 3 (33.3%)
Max absolute difference among violations: 0.
Max relative difference among violations: 0.
 x: array([ 1.,  1., nan])
 y: array([ 1.,  2., nan])

Here, `y` is a scalar, so each element of `x` is compared to `y`, and
the assertion passes.

>>> x = [1.0, 4.0]
>>> y = 5.0
>>> np.testing.assert_array_less(x, y)

However, with ``strict=True``, the assertion will fail because the shapes
do not match.

>>> np.testing.assert_array_less(x, y, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not strictly ordered `x < y`
<BLANKLINE>
(shapes (2,), () mismatch)
 x: array([1., 4.])
 y: array(5.)

With ``strict=True``, the assertion also fails if the dtypes of the two
arrays do not match.

>>> y = [5, 5]
>>> np.testing.assert_array_less(x, y, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Arrays are not strictly ordered `x < y`
<BLANKLINE>
(dtypes float64, int64 mismatch)
 x: array([1., 4.])
 y: array([5, 5])
Tz'Arrays are not strictly ordered `x < y`F)r  r  )r   r&   r   r<  r   r   N)r8   rX  __lt__)r  r  r   r&   r   ri   s         rP   r   r     s,    T !!( I#( &)+rO   c                     [        X5        g r  )exec)astrr   s     rP   r%   r%     s
    rO   c                    SnSSK n[        U [        5      (       d  [        [	        [        U 5      5      5      e[        U[        5      (       d  [        [	        [        U5      5      5      eX:X  a  g[        UR                  5       R                  U R                  S5      UR                  S5      5      5      n/ nU(       GaO  UR                  S5      nUR                  S5      (       a  M1  UR                  S5      (       a  U/nUR                  S5      nUR                  S5      (       a"  UR                  U5        UR                  S5      nUR                  S5      (       d  [        [	        U5      5      eUR                  U5        U(       aK  UR                  S5      n	U	R                  S5      (       a  UR                  U	5        OUR                  SU	5        USS USS :X  a  GM/  UR                  U5        GMC  [        [	        U5      5      eU(       d  gS	S
R                  U5      R!                  5        3n
X:w  a  [        U
5      eg)aN  
Test if two strings are equal.

If the given strings are equal, `assert_string_equal` does nothing.
If they are not equal, an AssertionError is raised, and the diff
between the strings is shown.

Parameters
----------
actual : str
    The string to test for equality against the expected string.
desired : str
    The expected string.

Examples
--------
>>> np.testing.assert_string_equal('abc', 'abc')
>>> np.testing.assert_string_equal('abc', 'abcd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
...
AssertionError: Differences in strings:
- abc+ abcd?    +

Tr   Nz  z- z? z+    zDifferences in strings:
r`   )difflibr   r   rf   r   r   r   Differrd  r   pop
startswithr   insertextendr   rstrip)r   r   ri   ro  diff	diff_listd1r   d2d3rh   s              rP   r   r     s   6 fc""T$v,/00gs##T$w-011 (():):4)@""4(* +DI
XXa[====A!B}}T""XXa[==&&$T"X..HHRLXXa[==&&HHRLKK2&!"vABQT"X&&%bggi&8&?&?&A%B
CCS!! rO   c                   ^ SSK Jn  SSKnU c%  [        R                  " S5      nUR
                  S   n [        R                  R                  [        R                  R                  U 5      5      S   nU" XP5      nUR                  5       R                  U5      nUR                  SS9n/ mU(       a  U4S jn	OSn	U H  n
UR                  XS	9  M     UR                  S:  a%  U(       a  [        S
SR!                  T5      -  5      egg)a  
Run doctests found in the given file.

By default `rundocs` raises an AssertionError on failure.

Parameters
----------
filename : str
    The path to the file for which the doctests are run.
raise_on_error : bool
    Whether to raise an AssertionError when a doctest fails. Default is
    True.

Notes
-----
The doctests can be run by the user/developer by adding the ``doctests``
argument to the ``test()`` call. For example, to run all tests (including
doctests) for ``numpy.lib``:

>>> np.lib.test(doctests=True)  # doctest: +SKIP
r   )exec_mod_from_locationNr   __file__Fr   c                 &   > TR                  U 5      $ r  )r   )srh   s    rP   rX   rundocs.<locals>.<lambda>{  s    

1rO   r'  zSome doctests failed:
%sr   )numpy.distutils.misc_utilr|  doctestsys	_getframe	f_globalsosr|   splitextbasenameDocTestFinderr   DocTestRunnerrunfailuresrf   r   )filenameraise_on_errorr|  r  r   namemtestsrunnerr(  testrh   s              @rP   r$   r$   X  s    , AMM!;;z*77BGG,,X67:Dt.A!!#((+E""5"1F
C%

4
!  ~8499S>IJJ  .rO   c                     U (       a  U S   $ SSK nSn UR                  USSS9nSUR                  ;   nU R                  U5        U S   $ ! [        UR                  4 a    Sn N0f = f)z

gh-22982
r   NlscpuT)capture_outputtextsveF)
subprocessr  stdoutOSErrorSubprocessErrorr   )__cacher  cmdoutputresults        rP   r>   r>     sy    
 qz
CDtD&--' NN61: Z//0 s    A
 
A%$A%c                       \ rS rSrS rSrg)_Dummyi  c                     g r  rG   )selfs    rP   nop
_Dummy.nop  s    rO   rG   N)rI   rJ   rK   rL   r  rN   rG   rO   rP   r  r    s    rO   r  r  c                  2    Sn[         R                  " U 0 UD6$ )a  
assert_raises(exception_class, callable, *args, **kwargs)
assert_raises(exception_class)

Fail unless an exception of class exception_class is thrown
by callable when invoked with arguments args and keyword
arguments kwargs. If a different type of exception is
thrown, it will not be caught, and the test case will be
deemed to have suffered an error, exactly as for an
unexpected exception.

Alternatively, `assert_raises` can be used as a context manager:

>>> from numpy.testing import assert_raises
>>> with assert_raises(ZeroDivisionError):
...     1 / 0

is equivalent to

>>> def div(x, y):
...     return x / y
>>> assert_raises(ZeroDivisionError, div, 1, 0)

T)_dassertRaises)r   kwargsri   s      rP   r   r     s    2 ??D+F++rO   c                 :    Sn[         R                  " X/UQ70 UD6$ )a  
assert_raises_regex(exception_class, expected_regexp, callable, *args,
                    **kwargs)
assert_raises_regex(exception_class, expected_regexp)

Fail unless an exception of class exception_class and with message that
matches expected_regexp is thrown by callable when invoked with arguments
args and keyword arguments kwargs.

Alternatively, can be used as a context manager like `assert_raises`.
T)r  assertRaisesRegex)exception_classexpected_regexpr   r  ri   s        rP   r*   r*     s%     R4R6RRrO   c                     Uc(  [         R                  " S[        R                  -  5      nO[         R                  " U5      nU R                  nSSKJn  UR                  5        Vs/ s H  oT" U5      (       d  M  UPM     nnU Hq  n [        US5      (       a  UR                  nOUR                  n UR                  U5      (       d  MG  UR                  S5      (       a  M_  [        XU" U5      5        Ms     gs  snf ! [         a     M  f = f)a  
Apply a decorator to all methods in a class matching a regular expression.

The given decorator is applied to all public methods of `cls` that are
matched by the regular expression `testmatch`
(``testmatch.search(methodname)``). Methods that are private, i.e. start
with an underscore, are ignored.

Parameters
----------
cls : class
    Class whose methods to decorate.
decorator : function
    Decorator to apply to methods
testmatch : compiled regexp or str, optional
    The regular expression. Default value is None, in which case the
    nose default (``re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep)``)
    is used.
    If `testmatch` is a string, it is compiled to a regular expression
    first.

Nz(?:^|[\\b_\\.%s-])[Tt]estr   )
isfunctioncompat_func_name_)recompiler  sep__dict__inspectr  valuesr+  r  rI   AttributeErrorsearchrr  setattr)	cls	decorator	testmatchcls_attrr  _mmethodsfunctionfuncnames	            rP   r    r      s    . JJ;bffDE	JJy)	||H #$OO-@-bBr-G@	x!344#44#,, H%%h.A.A#.F.FC9X#67   A  		s$   &C::C:C?&C??
DDc                     [         R                  " S5      nUR                  UR                  pT[	        U SU S3S5      nSn[        5       nXq:  a  US-  n[        XeU5        Xq:  a  M  [        5       U-
  nSU-  $ )a  
Return elapsed time for executing code in the namespace of the caller.

The supplied code string is compiled with the Python builtin ``compile``.
The precision of the timing is 10 milli-seconds. If the code will execute
fast on this timescale, it can be executed many times to get reasonable
timing accuracy.

Parameters
----------
code_str : str
    The code to be timed.
times : int, optional
    The number of times the code is executed. Default is 1. The code is
    only compiled once.
label : str, optional
    A label to identify `code_str` with. This is passed into ``compile``
    as the second argument (for run-time error messages).

Returns
-------
elapsed : float
    Total elapsed time in seconds for executing `code_str` `times` times.

Examples
--------
>>> times = 10
>>> etime = np.testing.measure('for i in range(1000): np.sqrt(i**2)', times=times)
>>> print("Time for a single execution : ", etime / times, "s")  # doctest: +SKIP
Time for a single execution :  0.005 s

r   zTest name: r   rk  r   g{Gz?)r  r  f_localsr  r  r!   rk  )	code_strtimeslabelframelocsglobscoder   elapseds	            rP   r'   r'     s|    B MM!E..%//%8{5'3V<D	AiG
)	QT$ ) i'!G'>rO   c                    [         (       d  gSSKnSSKnUR                  " S5      R	                  SS5      nUnSnUR
                  " 5          [        R                  " U5      n[        S5       H  nU " X45      nM     [        [        R                  " U5      U:  5        UR                  " 5         Ag! UR                  " 5         f = f)z[
Check that ufuncs don't mishandle refcount of object `1`.
Used in a few regression tests.
Tr   Ni'  r   r      )r5   gcrQ   r   reshapedisabler  r^   r   r(   enable)	opr  r   bcr   rcjds	            rP   _assert_valid_refcountr  1  s    
 <
		)$$S#.A	A	AJJL__QrA1A "b()
			 			s   AB2 2Cc                   ^^^^ SnSSK mUUUU4S jn	TR                  " U 5      TR                  " U5      pSTS STS 3n
[        XU[        U5      XjTUS9  g)	u  
Raises an AssertionError if two objects are not equal up to desired
tolerance.

Given two array_like objects, check that their shapes and all elements
are equal (but see the Notes for the special handling of a scalar). An
exception is raised if the shapes mismatch or any values conflict. In
contrast to the standard usage in numpy, NaNs are compared like numbers,
no assertion is raised if both objects have NaNs in the same positions.

The test is equivalent to ``allclose(actual, desired, rtol, atol)`` (note
that ``allclose`` has different default values). It compares the difference
between `actual` and `desired` to ``atol + rtol * abs(desired)``.

Parameters
----------
actual : array_like
    Array obtained.
desired : array_like
    Array desired.
rtol : float, optional
    Relative tolerance.
atol : float, optional
    Absolute tolerance.
equal_nan : bool, optional.
    If True, NaNs will compare equal.
err_msg : str, optional
    The error message to be printed in case of failure.
verbose : bool, optional
    If True, the conflicting values are appended to the error message.
strict : bool, optional
    If True, raise an ``AssertionError`` when either the shape or the data
    type of the arguments does not match. The special handling of scalars
    mentioned in the Notes section is disabled.

    .. versionadded:: 2.0.0

Raises
------
AssertionError
    If actual and desired are not equal up to specified precision.

See Also
--------
assert_array_almost_equal_nulp, assert_array_max_ulp

Notes
-----
When one of `actual` and `desired` is a scalar and the other is
array_like, the function performs the comparison as if the scalar were
broadcasted to the shape of the array.
This behaviour can be disabled with the `strict` parameter.

Examples
--------
>>> x = [1e-5, 1e-3, 1e-1]
>>> y = np.arccos(np.cos(x))
>>> np.testing.assert_allclose(x, y, rtol=1e-5, atol=0)

As mentioned in the Notes section, `assert_allclose` has special
handling for scalars. Here, the test checks that the value of `numpy.sin`
is nearly zero at integer multiples of π.

>>> x = np.arange(3) * np.pi
>>> np.testing.assert_allclose(np.sin(x), 0, atol=1e-15)

Use `strict` to raise an ``AssertionError`` when comparing an array
with one or more dimensions against a scalar.

>>> np.testing.assert_allclose(np.sin(x), 0, atol=1e-15, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Not equal to tolerance rtol=1e-07, atol=1e-15
<BLANKLINE>
(shapes (3,), () mismatch)
 ACTUAL: array([ 0.000000e+00,  1.224647e-16, -2.449294e-16])
 DESIRED: array(0)

The `strict` parameter also ensures that the array data types match:

>>> y = np.zeros(3, dtype=np.float32)
>>> np.testing.assert_allclose(np.sin(x), y, atol=1e-15, strict=True)
Traceback (most recent call last):
    ...
AssertionError:
Not equal to tolerance rtol=1e-07, atol=1e-15
<BLANKLINE>
(dtypes float64, float32 mismatch)
 ACTUAL: array([ 0.000000e+00,  1.224647e-16, -2.449294e-16])
 DESIRED: array([0., 0., 0.], dtype=float32)

Tr   Nc                 P   > TR                   R                  R                  XTTTS9$ )N)rtolatolr;  )_corenumericisclose)r  r  r  r;  r   r  s     rP   rd   assert_allclose.<locals>.compare  s.    xx''4d1: ( < 	<rO   zNot equal to tolerance rtol=gz, atol=)r   r&   r   r;  r   )rQ   r)  r8   r   )r   r   r  r  r;  r   r&   r   ri   rd  r   r   s     ```      @rP   r.   r.   K  sd    ~ < < mmF+R]]7-CG+D874(CF'3w<!(9 &(rO   c                    SnSSK nUR                  " U 5      nUR                  " U5      nX$R                  " UR                  " XV:  XV5      5      -  nUR                  " UR                  " X-
  5      U:*  5      (       de  UR
                  " U 5      (       d  UR
                  " U5      (       a  SU S3nO%UR                  " [        X5      5      n	SU SU	S S3n[        U5      eg)	aE  
Compare two arrays relatively to their spacing.

This is a relatively robust method to compare two arrays whose amplitude
is variable.

Parameters
----------
x, y : array_like
    Input arrays.
nulp : int, optional
    The maximum number of unit in the last place for tolerance (see Notes).
    Default is 1.

Returns
-------
None

Raises
------
AssertionError
    If the spacing between `x` and `y` for one or more elements is larger
    than `nulp`.

See Also
--------
assert_array_max_ulp : Check that all items of arrays differ in at most
    N Units in the Last Place.
spacing : Return the distance between x and the nearest adjacent number.

Notes
-----
An assertion is raised if the following condition is not met::

    abs(x - y) <= nulp * spacing(maximum(abs(x), abs(y)))

Examples
--------
>>> x = np.array([1., 1e-10, 1e-20])
>>> eps = np.finfo(x.dtype).eps
>>> np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)

>>> np.testing.assert_array_almost_equal_nulp(x, x*eps + x)
Traceback (most recent call last):
  ...
AssertionError: Arrays are not equal to 1 ULP (max is 2)

Tr   NzArrays are not equal to z ULPz ULP (max is r  ))	rQ   r   spacingwherer  r   r  	nulp_diffrf   )
r  r  nulpri   r   axayrefrh   max_nulps
             rP   r)   r)     s    b 	B	B
BHHRWb56
6C66"&&-3&''??1!3!3,TF$7Cvvio.H,TF-|1MCS!! (rO   c                     SnSSK n[        XU5      nUR                  " Xb:*  5      (       d  [        SX%R                  " U5      4-  5      eU$ )a  
Check that all items of arrays differ in at most N Units in the Last Place.

Parameters
----------
a, b : array_like
    Input arrays to be compared.
maxulp : int, optional
    The maximum number of units in the last place that elements of `a` and
    `b` can differ. Default is 1.
dtype : dtype, optional
    Data-type to convert `a` and `b` to if given. Default is None.

Returns
-------
ret : ndarray
    Array containing number of representable floating point numbers between
    items in `a` and `b`.

Raises
------
AssertionError
    If one or more elements differ by more than `maxulp`.

Notes
-----
For computing the ULP difference, this API does not differentiate between
various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000
is zero).

See Also
--------
assert_array_almost_equal_nulp : Compare two arrays relatively to their
    spacing.

Examples
--------
>>> a = np.linspace(0., 1., 100)
>>> res = np.testing.assert_array_max_ulp(a, np.arcsin(np.sin(a)))

Tr   NzCArrays are not almost equal up to %g ULP (max difference is %g ULP))rQ   r  r  rf   r  )r   r  maxulpr   ri   r   rets          rP   r+   r+     sW    T 
A%
 C66#-   >$ffSk23 4 	4 JrO   c                   ^ SSK mU(       a!  TR                  " XS9n TR                  " XS9nO$TR                  " U 5      n TR                  " U5      nTR                  " X5      nTR                  " U 5      (       d  TR                  " U5      (       a  [	        S5      eTR
                  " U /US9n TR
                  " U/US9nTR                  U TR                  " U 5      '   TR                  UTR                  " U5      '   U R                  UR                  :X  d'  [        SU R                  < SUR                  < 35      eU4S jn[        U 5      n[        U5      nU" XVU5      $ )a  For each item in x and y, return the number of representable floating
points between them.

Parameters
----------
x : array_like
    first input array
y : array_like
    second input array
dtype : dtype, optional
    Data-type to convert `x` and `y` to if given. Default is None.

Returns
-------
nulp : array_like
    number of representable floating point numbers between each item in x
    and y.

Notes
-----
For computing the ULP difference, this API does not differentiate between
various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000
is zero).

Examples
--------
# By definition, epsilon is the smallest number such as 1 + eps != 1, so
# there should be exactly one ULP between 1 and 1 + eps
>>> nulp_diff(1, 1 + np.finfo(x.dtype).eps)
1.0
r   Nr&  z'_nulp not implemented for complex arrayz#Arrays do not have the same shape: z - c                 N   > TR                   " X-
  US9nTR                  " U5      $ Nr&  )r   r   )rxryvdtrv  r   s       rP   _diffnulp_diff.<locals>._diffa  s#    zz"'-vvd|rO   )rQ   r   common_typer   r   r   r  r   r*  r   integer_repr)r  r  r   tr  r  r  r   s          @rP   r  r  +  s   @ JJq&JJq&JJqMJJqM
qA	qR__Q//!"KLL
!AA
!AAVVAbhhqkNVVAbhhqkN77agg''177, - 	- 
aB	aBrO   c                 ~    U R                  U5      nUR                  S:X  d  X#US:     -
  X3S:  '   U$ US:  a  X#-
  nU$ )Nr   r   )viewr,  )r  r  compr  s       rP   _integer_reprr  j  sN    
 
BGGqLrAvJ&6

 I 6BIrO   c                    SSK nU R                  UR                  :X  a&  [        XR                  UR                  " S5      5      $ U R                  UR
                  :X  a&  [        XR                  UR                  " S5      5      $ U R                  UR                  :X  a&  [        XR                  UR                  " S5      5      $ [        SU R                   35      e)zMReturn the signed-magnitude interpretation of the binary representation
of x.r   Ni i   l         zUnsupported dtype )
rQ   r   float16r  int16r
   int32r   int64r   )r  r   s     rP   r  r  y  s     ww"**Q"((6*:;;	
BJJ	Q"((6*:;;	
BJJ	Q"((6*:;;-aggY788rO   c              #      #    Sn[        5        nUR                  U 5      nS v   [        U5      S:  d  Ub  SU 3OSn[        SU-   5      e S S S 5        g ! , (       d  f       g = f7f)NTr    when calling r`   zNo warning raised)r7   recordr   rf   )warning_classr  ri   supr   name_strs         rP   _assert_warns_contextr    sc     		JJ}%1vz262Bv.H !4x!?@@  
		s   A'=A	A'
A$ A'c                 
   U(       d  U(       d  [        U 5      $ [        U5      S:  a  SU;   a  [        S5      e[        S5      eUS   nUSS n[        XR                  S9   U" U0 UD6sSSS5        $ ! , (       d  f       g= f)a  
Fail unless the given callable throws the specified warning.

A warning of class warning_class should be thrown by the callable when
invoked with arguments args and keyword arguments kwargs.
If a different type of warning is thrown, it will not be caught.

If called with all arguments other than the warning class omitted, may be
used as a context manager::

    with assert_warns(SomeWarning):
        do_something()

The ability to be used as a context manager is new in NumPy v1.11.0.

Parameters
----------
warning_class : class
    The class defining the warning that `func` is expected to throw.
func : callable, optional
    Callable to test
*args : Arguments
    Arguments for `func`.
**kwargs : Kwargs
    Keyword arguments for `func`.

Returns
-------
The value returned by `func`.

Examples
--------
>>> import warnings
>>> def deprecated_func(num):
...     warnings.warn("Please upgrade", DeprecationWarning)
...     return num*num
>>> with np.testing.assert_warns(DeprecationWarning):
...     assert deprecated_func(4) == 16
>>> # or passing a func
>>> ret = np.testing.assert_warns(DeprecationWarning, deprecated_func, 4)
>>> assert ret == 16
r   matchzAassert_warns does not use 'match' kwarg, use pytest.warns insteadz(assert_warns(...) needs at least one argr   Nr  )r  r   RuntimeErrorrI   )r  r   r  r  s       rP   r,   r,     s    V $]33	TQf+  EFF7D8D	}==	AT$V$ 
B	A	As   "A44
Bc              #      #    Sn[         R                  " SS9 n[         R                  " S5        S v   [        U5      S:  a  U b  SU  3OSn[	        SU SU 35      e S S S 5        g ! , (       d  f       g = f7f)	NTr  alwaysr   r  r`   zGot warningsr   )warningscatch_warningssimplefilterr   rf   )r  ri   r   r
  s       rP   _assert_no_warnings_contextr    sr     		 	 	-h'q6A:262Bv.H <zA3!?@@  
.	-	-s   A9AA(	A9(
A62A9c                      U (       d
  [        5       $ U S   nU SS n [        UR                  S9   U" U 0 UD6sSSS5        $ ! , (       d  f       g= f)a  
Fail if the given callable produces any warnings.

If called with all arguments omitted, may be used as a context manager::

    with assert_no_warnings():
        do_something()

The ability to be used as a context manager is new in NumPy v1.11.0.

Parameters
----------
func : callable
    The callable to test.
\*args : Arguments
    Arguments passed to `func`.
\*\*kwargs : Kwargs
    Keyword arguments passed to `func`.

Returns
-------
The value returned by `func`.

r   r   Nr  )r  rI   r   r  r  s      rP   r-   r-     sI    2 *,,7D8D	$$--	8T$V$ 
9	8	8s   A
Abinary   c              #   ,  ^ ^
^#    SnSn[        S5       GHy  m
[        T
S-   [        T
S-   U5      5       GHT  mUS:X  a  U U
U4S jn[        T4T S9T
S nXe" 5       UT
T
TT S	4-  4v   U" 5       nXwUT
T
TT S
4-  4v   USS U" 5       SS UT
S-   T
TS-
  T S	4-  4v   USS U" 5       SS UT
T
S-   TS-
  T S	4-  4v   U" 5       SS U" 5       SS UT
T
S-   TS-
  T S4-  4v   U" 5       SS U" 5       SS UT
S-   T
TS-
  T S4-  4v   US:X  d  M  U U
U4S jnU U
U4S jn	[        T4T S9T
S nXh" 5       U	" 5       UT
T
T
TT S	4-  4v   U" 5       nXwU	" 5       UT
T
T
TT S4-  4v   U	" 5       nXx" 5       XtT
T
T
TT S4-  4v   USS U" 5       SS U	" 5       SS UT
S-   T
T
TS-
  T S	4-  4v   USS U" 5       SS U	" 5       SS UT
T
S-   T
TS-
  T S	4-  4v   USS U" 5       SS U	" 5       SS UT
T
T
S-   TS-
  T S	4-  4v   U" 5       SS U" 5       SS U	" 5       SS UT
S-   T
T
TS-
  T S4-  4v   U" 5       SS U" 5       SS U	" 5       SS UT
T
S-   T
TS-
  T S4-  4v   U" 5       SS U" 5       SS U	" 5       SS UT
T
T
S-   TS-
  T S4-  4v   GMW     GM|     g7f)a  
generator producing data with different alignment and offsets
to test simd vectorization

Parameters
----------
dtype : dtype
    data type to produce
type : string
    'unary': create data for unary operations, creates one input
             and output array
    'binary': create data for unary operations, creates two input
             and output array
max_size : integer
    maximum size of data to produce

Returns
-------
if type is 'unary' yields one output, one input array and a message
containing information on the data
if type is 'binary' yields one output array, two input array and a message
containing information on the data

z,unary offset=(%d, %d), size=%d, dtype=%r, %sz1binary offset=(%d, %d, %d), size=%d, dtype=%r, %srR   rn  unaryc                     > [        TT S9TS  $ r  r   r   or  s   rP   rX   %_gen_alignment_data.<locals>.<lambda>  s    fQe4QR8rO   r&  Nzout of placezin placer   r   aliasedr  c                     > [        TT S9TS  $ r  r  r  s   rP   rX   r!  &      vau5ab9rO   c                     > [        TT S9TS  $ r  r  r  s   rP   rX   r!  '  r$  rO   z	in place1z	in place2)r   r  r   )r   r   max_sizeufmtbfmtinpr(  r  inp1inp2r   r  s   `         @@rP   _gen_alignment_datar,    s    2 :D>D1Xq1uc!a%23Aw8QD.qr235$!Q5.)I"IIIEDAq!UJ#????!"gsuSbz4UAq1ue^<,= = =#2hab	4Aq1ue^<,= = =eCRj#%)TAq1ueY7.8 8 8eABisTUAq1ueY7.8 8 8x99QD.qr24646D1a7-8 8 8FDFD1a4%5 5 5F1a4%5 5 5!"gtvcr{DF3BKUAq!a%?:@ @ @#2hqr
DF3BKAq!a%?:@ @ @#2hsTVABZ1q5!a%?:@ @ @fQRj$&"+tvcr{DUAq!a%	:=; ; ;fSbk46!":tvcr{DAq!a%	:=; ; ;fSbk46#2;qr
D1q5!a%	:=; ; ;K 4 s   DJFJc                       \ rS rSrSrSrg)r/   i?  z/Ignoring this exception due to disabled featurerG   NrH   rG   rO   rP   r/   r/   ?  s    5rO   r/   c               /      #    [        U 0 UD6n Uv   [        R                  " U5        g! [        R                  " U5        f = f7f)zContext manager to provide a temporary test folder.

All arguments are passed as this to the underlying tempfile.mkdtemp
function.

N)r   shutilrmtree)r   r  tmpdirs      rP   r3   r3   D  s8      d%f%Fffs   A* AAAc               /      #    [        U 0 UD6u  p#[        R                  " U5         Uv   [        R                  " U5        g! [        R                  " U5        f = f7f)a  Context manager for temporary files.

Context manager that returns the path to a closed temporary file. Its
parameters are the same as for tempfile.mkstemp and are passed directly
to that function. The underlying file is removed when the context is
exited, so it should be closed at that time.

Windows does not allow a temporary file to be opened if it is already
open, so the underlying file must be closed after opening before it
can be opened again.

N)r   r  closeremove)r   r  fdr|   s       rP   r2   r2   S  sC      ''HBHHRL

		$		$s   $AA AAAc                   L   ^  \ rS rSrSrSrSU 4S jjrU 4S jrU 4S jrSr	U =r
$ )	r0   ii  a  Context manager that resets warning registry for catching warnings

Warnings can be slippery, because, whenever a warning is triggered, Python
adds a ``__warningregistry__`` member to the *calling* module.  This makes
it impossible to retrigger the warning in this module, whatever you put in
the warnings filters.  This context manager accepts a sequence of `modules`
as a keyword argument to its constructor and:

* stores and removes any ``__warningregistry__`` entries in given `modules`
  on entry;
* resets ``__warningregistry__`` to its previous state on exit.

This makes it possible to trigger any warning afresh inside the context
manager without disturbing the state of warnings outside.

For compatibility with Python 3.0, please consider all arguments to be
keyword-only.

Parameters
----------
record : bool, optional
    Specifies whether warnings should be captured by a custom
    implementation of ``warnings.showwarning()`` and be appended to a list
    returned by the context manager. Otherwise None is returned by the
    context manager. The objects appended to the list are arguments whose
    attributes mirror the arguments to ``showwarning()``.
modules : sequence, optional
    Sequence of modules for which to reset warnings registry on entry and
    restore on exit. To work correctly, all 'ignore' filters should
    filter by one of these modules.

Examples
--------
>>> import warnings
>>> with np.testing.clear_and_catch_warnings(
...         modules=[np._core.fromnumeric]):
...     warnings.simplefilter('always')
...     warnings.filterwarnings('ignore', module='np._core.fromnumeric')
...     # do something that raises a warning but ignore those in
...     # np._core.fromnumeric
rG   c                    > [        U5      R                  U R                  5      U l        0 U l        [
        TU ]  US9  g )Nr  )setunionclass_modulesmodules_warnreg_copiessuper__init__)r  r  r;  	__class__s      rP   r>  !clear_and_catch_warnings.__init__  s7    7|))$*<*<=!'rO   c                    > U R                    HO  n[        US5      (       d  M  UR                  nUR                  5       U R                  U'   UR                  5         MQ     [        TU ]  5       $ N__warningregistry__)r;  r+  rC  copyr<  clearr=  	__enter__)r  modmod_regr?  s      rP   rF  "clear_and_catch_warnings.__enter__  sY    <<Cs12211,3LLN$$S)	  
 w ""rO   c                   > [         TU ]  " U6   U R                   Hg  n[        US5      (       a  UR                  R                  5         X R                  ;   d  M?  UR                  R                  U R                  U   5        Mi     g rB  )r=  __exit__r;  r+  rC  rE  r<  update)r  exc_inforG  r?  s      rP   rK  !clear_and_catch_warnings.__exit__  si    (#<<Cs122''--/***''..t/C/CC/HI	  rO   )r<  r;  )FrG   )rI   rJ   rK   rL   rM   r:  r>  rF  rK  rN   __classcell__)r?  s   @rP   r0   r0   i  s&    (R M(
#J JrO   r0   c                   z    \ rS rSrSrSS jrS r\SSS4S jr\SS4S	 jr	\SS4S
 jr
S rS rSS.S jrS rSrg)r7   i  a
  
Context manager and decorator doing much the same as
``warnings.catch_warnings``.

However, it also provides a filter mechanism to work around
https://bugs.python.org/issue4180.

This bug causes Python before 3.4 to not reliably show warnings again
after they have been ignored once (even within catch_warnings). It
means that no "ignore" filter can be used easily, since following
tests might need to see the warning. Additionally it allows easier
specificity for testing warnings and can be nested.

Parameters
----------
forwarding_rule : str, optional
    One of "always", "once", "module", or "location". Analogous to
    the usual warnings module filter mode, it is useful to reduce
    noise mostly on the outmost level. Unsuppressed and unrecorded
    warnings will be forwarded based on this rule. Defaults to "always".
    "location" is equivalent to the warnings "default", match by exact
    location the warning warning originated from.

Notes
-----
Filters added inside the context manager will be discarded again
when leaving it. Upon entering all filters defined outside a
context will be applied automatically.

When a recording filter is added, matching warnings are stored in the
``log`` attribute as well as in the list returned by ``record``.

If filters are added and the ``module`` keyword is given, the
warning registry of this module will additionally be cleared when
applying it, entering the context, or exiting it. This could cause
warnings to appear a second time after leaving the context if they
were configured to be printed once (default) and were already
printed before the context was entered.

Nesting this context manager will work as expected when the
forwarding rule is "always" (default). Unfiltered and unrecorded
warnings will be passed out and be matched by the outer level.
On the outmost level they will be printed (or caught by another
warnings context). The forwarding rule argument can modify this
behaviour.

Like ``catch_warnings`` this context manager is not threadsafe.

Examples
--------

With a context manager::

    with np.testing.suppress_warnings() as sup:
        sup.filter(DeprecationWarning, "Some text")
        sup.filter(module=np.ma.core)
        log = sup.record(FutureWarning, "Does this occur?")
        command_giving_warnings()
        # The FutureWarning was given once, the filtered warnings were
        # ignored. All other warnings abide outside settings (may be
        # printed/error)
        assert_(len(log) == 1)
        assert_(len(sup.log) == 1)  # also stored in log attribute

Or as a decorator::

    sup = np.testing.suppress_warnings()
    sup.filter(module=np.ma.core)  # module must match exactly
    @sup
    def some_function():
        # do something which causes a warning in np.ma.core
        pass
c                 N    SU l         / U l        US;  a  [        S5      eXl        g )NF>   oncer  modulelocationzunsupported forwarding rule.)_entered_suppressionsr   _forwarding_rule)r  forwarding_rules     rP   r>  suppress_warnings.__init__  s.      "JJ;<< /rO   c                     [        [        S5      (       a  [        R                  " 5         g U R                   H0  n[        US5      (       d  M  UR                  R                  5         M2     g )N_filters_mutatedrC  )r+  r  r[  _tmp_modulesrC  rE  )r  rS  s     rP   _clear_registries#suppress_warnings._clear_registries  sS    8/00 %%' ''Fv455**002 (rO   r`   NFc                 :   U(       a  / nOS nU R                   (       a  Uc  [        R                  " SXS9  O`UR                  R	                  SS5      S-   n[        R                  " SXUS9  U R
                  R                  U5        U R                  5         U R                  R                  X[        R                  " U[        R                  5      X445        U$ U R                  R                  X[        R                  " U[        R                  5      X445        U$ )Nr  categorymessage.\.$ra  rb  rS  )rU  r  filterwarningsrI   replacer\  addr]  _tmp_suppressionsr   r  r  IrV  )r  ra  rb  rS  r  module_regexs         rP   _filtersuppress_warnings._filter	  s    FF==~''xB  &66sEBSH''x') !!%%f-&&(""))BJJw$=vNP  %%BJJw$=vNP rO   c                 &    U R                  XUSS9  g)a'  
Add a new suppressing filter or apply it if the state is entered.

Parameters
----------
category : class, optional
    Warning class to filter
message : string, optional
    Regular expression matching the warning message.
module : module, optional
    Module to filter for. Note that the module (and its file)
    must match exactly and cannot be a submodule. This may make
    it unreliable for external modules.

Notes
-----
When added within a context, filters are only added inside
the context and will be forgotten when the context is exited.
Fra  rb  rS  r  Nrm  r  ra  rb  rS  s       rP   filtersuppress_warnings.filter$	  s    ( 	h! 	 	#rO   c                 $    U R                  XUSS9$ )a  
Append a new recording filter or apply it if the state is entered.

All warnings matching will be appended to the ``log`` attribute.

Parameters
----------
category : class, optional
    Warning class to filter
message : string, optional
    Regular expression matching the warning message.
module : module, optional
    Module to filter for. Note that the module (and its file)
    must match exactly and cannot be a submodule. This may make
    it unreliable for external modules.

Returns
-------
log : list
    A list which will be filled with all matched warnings.

Notes
-----
When added within a context, filters are only added inside
the context and will be forgotten when the context is exited.
Trp  rq  rr  s       rP   r  suppress_warnings.record;	  s!    6 ||Xv#'  ) 	)rO   c                    U R                   (       a  [        S5      e[        R                  U l        [        R
                  U l        U R                  S S  [        l        SU l         / U l        [        5       U l	        [        5       U l
        / U l        U R                   Hy  u  pp4nUb  US S 2	 Uc  [        R                  " SXS9  M)  UR                  R                  SS5      S-   n[        R                  " SXUS9  U R                  R!                  U5        M{     U R"                  [        l        U R%                  5         U $ )	Nz%cannot enter suppress_warnings twice.Tr  r`  rc  rd  re  rf  )rU  r  r  showwarning
_orig_showfilters_filtersrj  r8  r\  
_forwardedlogrV  rg  rI   rh  ri  _showwarningr]  )r  catmessr  rG  r}  rl  s          rP   rF  suppress_warnings.__enter__Y	  s   ==FGG".. ((==+!#E%&*&8&8"CqsF{''s:  #||33C?#E''s') !!%%c* '9  $00 rO   c                     U R                   [        l        U R                  [        l        U R                  5         SU l        U ? U ?g )NF)ry  r  rx  r{  rz  r]  rU  )r  rM  s     rP   rK  suppress_warnings.__exit__y	  s7    #== OMrO   )use_warnmsgc                   U R                   U R                  -   S S S2    H  u  ppn[        X(5      (       d  M  U
R                  UR                  S   5      c  M:  Uc?  Ub:  [        XUU40 UD6nU R                  R                  U5        UR                  U5          g UR                  R                  U5      (       d  M  Ub:  [        XUU40 UD6nU R                  R                  U5        UR                  U5          g    U R                  S:X  a-  Uc  U R                  " XX4/UQ70 UD6  g U R                  U5        g U R                  S:X  a  UR                  U4nO>U R                  S:X  a  UR                  X#4nOU R                  S:X  a  UR                  X#U4nWU R                  ;   a  g U R                  R                  U5        Uc  U R                  " XX4/UQ70 UD6  g U R                  U5        g )Nr   r   r  rR  rS  rT  )rV  rj  
issubclassr  r   r   r}  r   r}  rr  rW  ry  _orig_showmsgr|  ri  )r  rb  ra  r  linenor  r   r  r  r  patternrG  recrh   	signatures                  rP   r~  suppress_warnings._showwarning	  s    ""T%;%;;TrT*C%CG#8))MM',,q/2>;,W-3?7=?,

3 \\,,X66,W-3?7=?,

3+*C2   H,"8 1!%1)/1  "";/  F* x0I""h. x:I""j0 x6BI'I&OOGx &$ &$& {+rO   c                 4   ^ ^ [        T5      UU 4S j5       nU$ )zG
Function decorator to apply certain suppressions to a whole
function.
c                  N   > T   T" U 0 UD6sS S S 5        $ ! , (       d  f       g = fr  rG   )r   r  r  r  s     rP   new_func,suppress_warnings.__call__.<locals>.new_func	  s    T,V, s   
$r   )r  r  r  s   `` rP   __call__suppress_warnings.__call__	  s"    
 
t	- 
	- rO   )	rU  r{  r|  rW  ry  rV  r\  rj  r}  )r  )rI   rJ   rK   rL   rM   r>  r]  Warningrm  rs  r  rF  rK  r~  r  rN   rG   rO   rP   r7   r7     sZ    HR0
3  '4 2 &r$ #. &r$ )<@ )-1,f
rO   r7   c              #   n  #    Sn[         (       d  S v   g [        [        R                  " 5       5        [        R                  " 5         [        R
                  " 5       n [        S5       H  n[        R                  " 5       S:X  d  M    O   [        S5      e[        R                  " [        R                  5        S v   [        R                  " 5       n[        R                  S S  n[        R                  S S 2	 [        R                  " U5        [        R                  " 5         U(       aF  U b  SU  3OSn[        SR                  UU[        U5      SR!                  S U 5       5      5      5      eg ! [        R                  S S 2	 [        R                  " U5        [        R                  " 5         f = f7f)	NTr   r   z]Unable to fully collect garbage - perhaps a __del__ method is creating more reference cycles?r  r`   zXReference cycles were found{}: {} objects were collected, of which {} are shown below:{}c           	   3      #    U  HX  nS R                  [        U5      R                  [        U5      [        R
                  " U5      R                  SS5      5      v   MZ     g7f)z
  {} object with id={}:
    {}r   z
    N)rz   r   rI   idr   pformatrh  ).0r   s     rP   	<genexpr>/_assert_no_gc_cycles_context.<locals>.<genexpr>	  sX      
  1!	 8>>Q((1q)11$A   1s   A A")r5   r(   r  	isenabledr  	get_debugr   collectr  	set_debugDEBUG_SAVEALLgarbager  rf   rz   r   r   )r  ri   gc_debugr   n_objects_in_cyclesobjects_in_cyclesr
  s          rP   _assert_no_gc_cycles_contextr  	  sI     <BLLNJJL||~HsAzz|q   56 6 	R%%& !jjlJJqMJJqM
X
		.2.>^D6*B-V#%& 
  1 	
 	
 	 JJqM
X
		s'   AF5%E2 AE2 &BF52A F22F5c                      U (       d
  [        5       $ U S   nU SS n [        UR                  S9   U" U 0 UD6  SSS5        g! , (       d  f       g= f)a  
Fail if the given callable produces any reference cycles.

If called with all arguments omitted, may be used as a context manager::

    with assert_no_gc_cycles():
        do_something()

Parameters
----------
func : callable
    The callable to test.
\*args : Arguments
    Arguments passed to `func`.
\*\*kwargs : Kwargs
    Keyword arguments passed to `func`.

Returns
-------
Nothing. The result is deliberately discarded to ensure that all cycles
are found.

r   r   Nr  )r  rI   r  s      rP   r9   r9   	  sI    0 +--7D8D	%4==	9df 
:	9	9s   	A
Ac                      [         R                  " 5         [        (       aU  [         R                  " 5         [         R                  " 5         [         R                  " 5         [         R                  " 5         gg)a  
Break reference cycles by calling gc.collect
Objects can call other objects' methods (for instance, another object's
 __del__) inside their own __del__. On PyPy, the interpreter only runs
between calls to gc.collect, so multiple calls are needed to completely
release all cycles.
N)r  r  r4   rG   rO   rP   r:   r:   
  s;     JJLw











 rO   c                     ^ ^ SSK mU U4S jnU$ )z:Decorator to skip a test if not enough memory is availabler   Nc                 6   >^  [        T 5      UU U4S j5       nU$ )Nc                     > [        T5      nUb  TR                  U5         T" U 0 UD6$ ! [         a    TR                  S5         g f = f)NzMemoryError raised)check_free_memoryskipMemoryErrorxfail)r   kwrh   
free_bytesr  pytests      rP   wrapper3requires_memory.<locals>.decorator.<locals>.wrapper-
  sM    #J/CC 3Q~"~% 3123s   * AAr  )r  r  r  r  s   ` rP   r  "requires_memory.<locals>.decorator,
  s     	t		3 
		3 rO   )r  )r  r  r  s   ` @rP   requires_memoryr  (
  s     rO   c                    Sn[         R                  R                  U5      nUb   [        U5      nU S-   SU S3nO$[        5       nUc  SnS	nOU S-  nUS-  nU S
U S3nX0:  a  U$ S$ ! [         a  n[	        SU SU 35      eSnAff = f)z
Check whether `free_bytes` amount of memory is currently free.
Returns: None if enough memory available, otherwise error message
NPY_AVAILABLE_MEMNzInvalid environment variable r   g    eAz@ GB memory required, but environment variable NPY_AVAILABLE_MEM=z setzCould not determine available memory; set NPY_AVAILABLE_MEM environment variable (e.g. NPY_AVAILABLE_MEM=16GB) to run the test.r   z GB memory required, but z GB available)r  environget_parse_sizer   _get_mem_available)r  env_var	env_valuemem_freer   rh   free_bytes_gbmem_free_gbs           rP   r  r  >
  s    
 "G

w'I	O"9-H s"# $$$-;d4 &'C H&,M"S.K"O#<[MWC'31T1%  	O<WIRuMNN	Os   A* *
B
4BB
c                    SSSSSSSSSSSSSS	S
.n[         R                  " SR                  SR                  UR	                  5       5      5      [         R
                  5      nUR                  U R                  5       5      nU(       a  UR                  S5      U;  a  [        SU < S35      e[        [        UR                  S5      5      XR                  S5         -  5      $ )z3Convert memory size strings ('12 GB' etc.) to floatr   i  i@B i ʚ;l    J)   i   i   @l        )r`   r  r   r  r  r  kbmbgbtbkibmibgibtibz^\s*(\d+|\d+\.\d+)\s*({0})\s*$|rn  zvalue z not a valid size)r  r  rz   r   keysrk  r  lowergroupr   r   r   )size_strsuffixessize_rer  s       rP   r  r  ]
  s    AgG'GGGMH
 jj:AA!#$&DD*G 	hnn&'A
(*6(->?@@uQWWQZ 8GGAJ#7788rO   c                      SSK n U R                  5       R                  $ ! [        [        4 a     Of = f[
        R                  R                  S5      (       a  0 n[        S5       nU HF  nUR                  5       n[        US   5      S-  XS   R                  S5      R                  5       '   MH     SSS5        O! , (       d  f       O= fSU;   a  US   $ US	   US
   -   $ g)z5Return available memory in bytes, or None if unknown.r   Nr   z/proc/meminfor   r  :memavailablememfreecached)psutilvirtual_memory	availableImportErrorr  r  platformrr  r   r   r   stripr  )r  infor   lineps        rP   r  r  m
  s    $$&000(  ||w''/"aJJL03AaD	D0@qTZZ_**,-  #""
 T!''	?T(^33s     33'AB==
Cc                 ^   ^  [        [        S5      (       d  T $ [        T 5      U 4S j5       nU$ )z
Decorator to temporarily turn off tracing for the duration of a test.
Needed in tests that check refcounting, otherwise the tracing itself
influences the refcounts
gettracec                     > [         R                  " 5       n [         R                  " S 5        T" U 0 UD6[         R                  " U5        $ ! [         R                  " U5        f = fr  )r  r  settrace)r   r  original_tracer  s      rP   r  _no_tracing.<locals>.wrapper
  sE     \\^N-T"T,V,^,^,s   A A$)r+  r  r   )r  r  s   ` rP   _no_tracingr  
  s4     3
##	t	- 
	- rO   c                  ~     [         R                  " S5      R                  S5      S   n U $ ! [         a    Sn  U $ f = f)NCS_GNU_LIBC_VERSIONr   r   0.0)r  confstrrsplitr   )vers    rP   _get_glibc_versionr  
  sH    jj./66s;A> J  Js   (, <<c                 4    [         S:g  =(       a	    [         U :  $ )Nr  )	_glibcverr  s    rP   rX   rX   
  s    yE1Ci!mCrO   c                    [        U5       GH  n[        R                  R                  US9 nUc  / nOU" 5       nU(       a'  [        R
                  " U5      n	UR                  U	5        U(       a   [        U5       V
s/ s H	  oU
/UQ7PM     nn
O[        U5       V
s/ s H  o/UQ7PM
     nn
 / nU H!  nUR                  UR                  " U6 5        M#     [        U5      U:  a  U(       a  W	R                  5         U H  nUR                  5         M     SSS5        GM     gs  sn
f s  sn
f ! [        W5      U:  a  U(       a  W	R                  5         f f f = f! , (       d  f       GM`  = f)z&Runs a function many times in parallel)max_workersN)r   
concurrentfuturesThreadPoolExecutor	threadingBarrierr   submitr   abortr  )r  r  
pass_countpass_barrierouter_iterationsprepare_argsr  tper   barrierr   all_argsr  argr   s                  rP   rC   rC   
  s:    #$  333L##~#++K8G$6;K6HI6H1,t,6HI383EF3EaMDM3EF$#CNN3::s#34 $ w<+-,MMO
 ) ML % JF w<+-,MMO 3?-% MLsB   AE=D%ED*,E/)D/?E%
E/*EE
E,	c                     U [         L d  U S:w  a  [        R                  R                  XS9$ [        R                  R                  US9$ )Nunsetr%  coerce)r  )r   r   dtypesStringDTyper  s     rP   get_stringdtype_dtyper  
  sA    EY'1yy$$y$HHyy$$F$33rO   )r`   )Nr   NN)pythonr   )zItems are not equal:Tr   rc   )r`   T)   r`   T)r`   Tr`      TT)r
  r`   T)NTr  )r   N)gHz>r   Tr`   T)r   )rc   FFr   N)T)rM   r  r  pathlibr  r  r  rX  r  	functoolsr   r   r/  r0  tempfiler   r   unittest.caser   r   r   	sysconfigconcurrent.futuresr  r  importlib.metadata	importlibrQ   r   r   r	   r
   r   r   r   r   r   r   r   r   r   numpy.linalg._umath_linalgnumpy._utilsr   numpy._core.tests._natyper   ior   __all__r   r1   KnownFailureTestr&   Pathr}  parentrB   metadatadistributionnp_distrA   version_infoorigindir_infoeditabler@   jsonrU   loads	read_textr  locate_filePackageNotFoundErrorr{   r6   implementationr  r4   r+  r<   r5  r5   linalg_umath_linalg_ilp64r;   r=   get_config_var_vr  r?   r   itemsizerD   r(   r   r"   getpidr!   r   r   r#   r   r   r8   r   r   r   r%   r   r$   r>   unittestTestCaser  r  r   r*   r    r'   r  r.   r)   r+   r  r  r  contextmanagerr  r,   r  r-   r,  r/   r3   r2   r  r0   r7   r  r9   r:   r  r  r  r  r  r  r  _glibc_older_thanrC   r  rG   rO   rP   <module>r3     sJ   
 
   	 	   $   % " #      F F F ( ( ! * + 
"	I 	
 ) 
\\"++&--
  --g6G Lw&!..11::K ZZ!!"34<FF !//22K 7..w7:E



 4
4



!
!V
+C./	sM40<NY||))00

 o.4"	R<G9++,=>?88BGG%%*#( 77d?;??C$8E 	\\"1 "(U ; 
" <<w!'		}E:r <*  8 +AGH:Oe Od&-R{/| AC $a"H MO@DG#(0EGT C:)4'J~(#~( K~(B C:)4'JBD&*p  Kp fp+ p+fD"N+K\ ! , X 
 E],:S ,^+\
4 CG(,j(8=j(Z<"~1h<~9 A A8%v A A%D &Hr B;J	i 	
    *?Jx66 ?JDS Sl 0
 0
fB$,2>9 0(  	D  2767":4gS   .. '!&&L;'s+   Q> +0Q/ AQ/ /Q;:Q;>R R 