
    Kh (                     4   S r SSKrSSKrSSKJr  SSKJs  Jr  SSKrSSKJ	r	J
r
JrJrJr  SSKJrJrJrJrJrJr  / SQrSSKJr  / S	Qr\\-   rSS
 jrSS jrSS jrS rSS jrSS jr\r SS jr!\!r"  SS jr#SS jr$SS jr%SS jr&SS jr'SS jr(SS jr)g)zMiscellaneous functions for testing masked arrays and subclasses

:author: Pierre Gerard-Marchant
:contact: pierregm_at_uga_dot_edu
:version: $Id: testutils.py 3529 2007-11-13 08:01:14Z jarrod.millman $

    N)ndarray)assert_assert_allcloseassert_array_almost_equal_nulpassert_raisesbuild_err_msg   )mask_orgetmaskmasked_arraynomaskmaskedfilled)almostapproxassert_almost_equalassert_array_almost_equalassert_array_approx_equalassert_array_compareassert_array_equalassert_array_lessassert_closeassert_equalassert_equal_recordsassert_mask_equalassert_not_equalfail_if_array_equal)TestCase)r   r   r   r   r   c                    [        [        U 5      [        U5      5      n[        U 5      n[        U5      nUR                  R                  S:X  d  UR                  R                  S:X  a$  [
        R                  " Xg5      R                  5       $ [        [        USUS9U5      R                  [
        R                  5      n[        [        USUS9S5      R                  [
        R                  5      n	[
        R                  " [        R                  " X-
  5      XC[        R                  " U	5      -  -   5      n
U
R                  5       $ )aj  
Returns true if all components of a and b are equal to given tolerances.

If fill_value is True, masked values considered equal. Otherwise,
masked values are considered unequal.  The relative error rtol should
be positive and << 1.0 The absolute error atol comes into play for
those elements of b that are very small or zero; it says how small a
must be also.

OFcopymaskr	   )r
   r   r   dtypecharnpequalravelr   astypefloat64
less_equalumathabsolute)ab
fill_valuertolatolmd1d2xyds              D/var/www/html/env/lib/python3.13/site-packages/numpy/ma/testutils.pyr   r   )   s     	
GAJ'A	B	B	xx}}rxx}}3xx%%''Re!,j	fRZZ  	|BU3Q7>>rzzJA
ennQU+T5>>!;L4L-LMA779    c                 j   [        [        U 5      [        U5      5      n[        U 5      n[        U5      nUR                  R                  S:X  d  UR                  R                  S:X  a$  [
        R                  " XV5      R                  5       $ [        [        USUS9U5      R                  [
        R                  5      n[        [        USUS9S5      R                  [
        R                  5      n[
        R                  " [
        R                  " Xx-
  5      U5      SU* -  :*  n	U	R                  5       $ )z
Returns True if a and b are equal up to decimal places.

If fill_value is True, masked values considered equal. Otherwise,
masked values are considered unequal.

r    Fr!   r	         $@)r
   r   r   r$   r%   r&   r'   r(   r   r)   r*   aroundabs)
r.   r/   decimalr0   r3   r4   r5   r6   r7   r8   s
             r9   r   r   A   s     	
GAJ'A	B	B	xx}}rxx}}3xx%%''Re!,j	fRZZ  	|BU3Q7>>rzzJA
		"&&-)Twh-??A779r:   c           	          [        [        U 5      [        U5      U5        [        [        U5      5       H  n[        X   X   SU< SU 35        M     g)z3
Asserts the equality of two non-array sequences.

item=
N)r   lenrange)actualdesirederr_msgks       r9   _assert_equal_on_sequencesrI   V   sK    
 Vc'lG43w< VY
eA57),DE !
r:   c                 h   [        U R                  UR                  5        U R                  R                   Hx  n[        R                  " X5      [        R                  " X5      pCU[
        Ld  M9  U[
        Ld  MD  [        [        R                  " X5      [        R                  " X5      5        Mz     g)z=
Asserts that two records are equal.

Pretty crude for now.

N)r   r$   namesoperatorgetitemr   )r.   r/   fafbfs        r9   r   r   a   sw     !''"WW]]$$Q*H,<,<Q,BRfrV|))!/1A1A!1GH  r:   c           	         [        U[        5      (       a  [        U [        5      (       d  [        [        [	        U 5      5      5      e[        [        U 5      [        U5      U5        UR                  5        H2  u  p4X0;  a  [        U SU  35      e[        X   X   SU< SU 35        M4     g[        U[        [        45      (       a%  [        U [        [        45      (       a
  [        XSS9$ [        U [        5      (       d3  [        U[        5      (       d  [        X/U5      nX:X  d  [        U5      egU [        L a	  U[        Ld  U[        L a!  U [        La  [        X/USSS9n[        U5      e[        R                   " U 5      n [        R                   " U5      nU R"                  UR"                  pvUR$                  S	:X  a7  UR$                  S	:X  a'  [        U R'                  5       UR'                  5       SS9$ [)        XU5      $ )
z$
Asserts that two items are equal.

z not in key=rB   N rG   r6   r7   )headerrK   S)
isinstancedictAssertionErrorreprtyper   rC   itemslisttuplerI   r   r   r   
ValueErrorr&   
asanyarrayr$   r%   tolistr   )rE   rF   rG   rH   imsgactual_dtypedesired_dtypes           r9   r   r   p   s    '4  &$'' d6l!344S[#g,8MMODA$s(6(%;<<GJ$qe2gY0GH $ 	'D%=))j$.O.O)&2FFvw'':gw+G+GV-w8  %%	6	Gv$5&F*:V-#BjBo]]6"FmmG$G%+\\7===CM$6$6#$=)&--/*1..*:246 	6 fw77r:   c           	      F   [        U[        5      (       a  [        U [        5      (       d  [        [        [	        U 5      5      5      e[        [        U 5      [        U5      U5        UR                  5        H6  u  p4X0;  a  [        [        U5      5      e[        X   X   SU< SU 35        M8     g[        U[        [        45      (       an  [        U [        [        45      (       aS  [        [        U 5      [        U5      U5        [        [        U5      5       H  n[        X   X   SU< SU 35        M     g[        U [        R                  5      (       d  [        U[        R                  5      (       a  [        XU5      $ [        X/U5      nX:w  d  [        U5      eg)z4
Raises an assertion error if two items are equal.

rR   rB   NrA   )rX   rY   rZ   r[   r\   fail_if_equalrC   r]   r^   r_   rD   r&   r   r   r   )rE   rF   rG   rH   rc   rd   s         r9   rh   rh      sI   
 '4  &$'' d6l!344c&k3w<9MMODA$T!W--&)WZ4uBwi1HI $ 	'D%=))j$.O.Oc&k3w<9s7|$A&)WZ5Ry1IJ %&"**%%GRZZ)H)H"6G<<
)7
3CS!! r:   c                     [        U [        R                  5      (       d  [        U[        R                  5      (       a  [        XUX4S9$ [	        X/X4S9n[        [        X-
  5      U5      S:X  d  [        U5      eg)zr
Asserts that two items are almost equal.

The test is equivalent to abs(desired-actual) < 0.5 * 10**(-decimal).

)r?   rG   verbose)rG   rj   r   N)rX   r&   r   r   r   roundr>   rZ   )rE   rF   r?   rG   rj   rd   s         r9   r   r      st     &"**%%GRZZ)H)H('18K 	K
) ':CW%&0A5S!! 6r:   c           	      h   [        [        U5      [        U5      5      n[        USUSSS9n[        USUSSS9nU[        L a	  U[        Ld  U[        L a!  U[        La  [	        X/X4USS9n[        U5      e[        R                  R                  U UR                  U5      UR                  U5      UXES9$ )zb
Asserts that comparison between two masked arrays is satisfied.

The comparison is elementwise.

F)r"   r#   	keep_masksubokrU   )rG   rj   rV   rK   rG   rj   rV   )
r
   r   r   r   r   r`   r&   testingr   r   )	
comparisonr6   r7   rG   rj   rV   r0   r3   rd   s	            r9   r   r      s     	
GAJ'AQUe5IAQUe5IA	
fqF{6kAKQFG#)=o::**:+,88J+?+,88J+?3:3:	 + K Kr:   c           	      8    [        [        R                  XX#SS9  g)z8
Checks the elementwise equality of two masked arrays.

Arrays are not equalro   N)r   rL   __eq__r6   r7   rG   rj   s       r9   r   r      s    
 !!( 68r:   c           	      "    S n[        X@XUSS9  g)zL
Raises an assertion error if two masked arrays are not equal elementwise.

c                 J    [         R                  " [        X5      5      (       + $ )N)r&   allr   rU   s     r9   compare$fail_if_array_equal.<locals>.compare   s    FF6!<(()r:   rs   ro   Nr   )r6   r7   rG   rj   ry   s        r9   r   r      s    
*Q 68r:   c           	      *   ^ U4S jn[        XPXUSS9  g)p
Checks the equality of two masked arrays, up to given number odecimals.

The equality is checked elementwise.

c                     > [        XST* -  S9$ )<Returns the result of the loose comparison between x and y).r<   )r1   )r   r6   r7   r?   s     r9   ry   *assert_array_approx_equal.<locals>.compare   s    a11r:   Arrays are not almost equalro   Nr{   r6   r7   r?   rG   rj   ry   s     `   r9   r   r      s    2 Q =?r:   c           	      *   ^ U4S jn[        XPXUSS9  g)r}   c                    > [        XT5      $ )r   )r   r   s     r9   ry   *assert_array_almost_equal.<locals>.compare
  s    aG$$r:   r   ro   Nr{   r   s     `   r9   r   r     s    % Q =?r:   c           	      8    [        [        R                  XX#SS9  g)z/
Checks that x is smaller than y elementwise.

zArrays are not less-orderedro   N)r   rL   __lt__ru   s       r9   r   r     s    
 !!( =?r:   c                     U [         L a  [        U[         L 5        U[         L a  [        U [         L 5        [        XUS9  g)z%
Asserts the equality of two masks.

rT   N)r   r   r   )m1m2rG   s      r9   r   r     s4    
 
V|f	V|frw/r:   )Tgh㈵>g:0yE>)   T)rS   )   rS   T)rS   TrS   T)rS   T)r   rS   T)*__doc__rL   numpyr&   r   numpy._core.umath_corer,   numpy.testingr   r   r   r   r   corer
   r   r   r   r   r   __all__maskedunittestr   __some__from_testing__all__r   r   rI   r   r   rh   r   r   r   r   r   r   r   r   r   r    r:   r9   <module>r      s       ! !   I H  
 .
.0*$8N"4 ! "  # MO$(K288???	0r:   