
    wgN=                        d dl Z d dlmZ d dlZd dlmc mZ d dlm	Z	 ej                  Z
 G d d      Zedk(  rdZdez   Zd	\  ZZ ed
d      D ]t  Zdez  Z e j(                  ee      j+                  eedz        Z ej.                  e      Z edez  dz           e edez                eded    dded
   d       v yy)    N)reduce)build_err_msgc                      e Zd Zd Z	 	 ddZddZ ej                  d      d        Z ej                  d      d        Z	 ej                  d      d        Z
 ej                  d      d	        Z ej                  d      d
        Z ej                  d      d        Z ej                  d      d        Z ej                  d      d        Z ej                  d      d        Z ej                  d      d        Zy)ModuleTesterc                    || _         |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _	        t        | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                  | _        |j                   | _        |j"                  | _        |j$                  | _        |j&                  | _        |j(                  | _        |j*                  | _        |j,                  | _        |j.                  | _        |j0                  | _        |j2                  | _        |j4                  | _        	 |j6                  | _        g | _        y # t8        $ r% |j:                  j6                  | _        Y g | _        y w xY wN)moduleallequalarangearrayconcatenatecountequalfilledgetmaskgetmaskarrayidinner	make_maskmaskedmasked_arraymasked_valuesmask_ornomaskonesouterrepeatresizesorttake	transposezerosMaskTypeumathAttributeErrorcore	testnames)selfr	   s     ^/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/numpy/ma/timer_comparison.py__init__zModuleTester.__init__   su   mm\\
!--\\
\\
mm~~"//\\
))mm"//#11~~mmKK	\\
mmmmKK	KK	))\\
	+DJ   	+**DJ	+s   =G $HHc           	      2   | j                  |      }| j                  |      }| j                  | j                  |      | j                  |            }	| j                  | j                  ||	      |      }| j                  | j                  ||	      |      }|j                  j
                  dk7  rx|j                  t        j                        }t        |t        j                        r(|j                  dkD  rd|t        j                  |      <   nt        j                  |      rd}|j                  j
                  dk7  rx|j                  t        j                        }t        |t        j                        r(|j                  dkD  rd|t        j                  |      <   nt        j                  |      rd}	 |j                  dk(  xs |j                  dk(  xs |j                  |j                  k(  }
|
s8t        ||g|d|j                   d|j                   dz   |d	
      }|
sJ |        |||      }|	| j                  ur|r| j                  ||	      }t        |t               r|}
dg}n0|j#                         }|j%                         }
|j'                         }|
sEdd|j)                  d      z  t+        |      z  z
  }t        ||g|d|dz   |d	
      }|
sJ |       yy# t,        $ r"}t        ||g||d	
      }t-        |      |d}~ww xY w)zZ
        Assert that a comparison of two masked arrays is satisfied elementwise.

        maskO   r    z	
(shapes z, z
 mismatch)xy)headernamesd   g      Y@z
(mismatch z%)N)r   r   r   r   dtypecharastypenpfloat64
isinstancendarraysizeisnanshaper   r   boolravelalltolistr   len
ValueError)r(   
comparisonr2   r3   err_msgr4   
fill_valuexfyfmcondmsgvalreducedmatches                   r)   assert_array_comparez!ModuleTester.assert_array_compare/   s    [[^[[^LLa$,,q/:KK))"1)5zBKK))"1)5zBGGLLC$A!RZZ(QVVaZ!""((1+!GGLLC$A!RZZ(QVVaZ!""((1+!	)GGrM2QWW]Iqww!''7ID#QF$+(2177)2aggYj&Q%R+1*4	6
  S tQ"C#
''!'4#t$#))+{{}!..*E'--"223w<??#QF$+=B&D%E+1*4	6
  S t   	)AjQCS/q(	)s   <D-K+ +	L4LLc                 D    | j                  | j                  |||d       y)zH
        Checks the elementwise equality of two masked arrays.

        zArrays are not equal)rH   r4   N)rS   r   )r(   r2   r3   rH   s       r)   assert_array_equalzModuleTester.assert_array_equalf   s'    
 	!!$**aG)? 	" 	A    ignore)rC   c                     t        j                  ddddt        dz  dddddddg      }g d	}| j                  ||
      }|d    y)!
        Tests creation

              ?              @      @      @      $      $@      @r/   r   r   r   r   r   r/   r   r   r   r   r   r,   r   N)r:   r   pir   )r(   r2   rL   xms       r)   test_0zModuleTester.test_0n   sP     HHb"b#r#vr2tS"b"MN0qq)
1rV   c                    t        j                  ddddt        dz  dddddddg      }t        j                  g d	      }g d
}g d}| j                  ||      }| j                  ||      }t        j                  |d|      }|j                  d       ||z
  j                  d      j                         sJ |j                  }|j                  t        d |      k(  sJ | j                  |      t        |      t        d |      z
  k(  sJ dD ]R  }||_        ||_        ||_        ||_        ||_        | j                  |      t        |      t        d |      z
  k(  rRJ  y)rY   rZ   r[   r\   r]   r^   r_   r`   ra   )r^           ra   r\   g      g      rg   r_   r`   rZ   rg   ra   rb   )r   r   r/   r   r   r/   r/   r   r   r   r   r/   r,   g@xDr   c                     | |z  S r   r0   r1   s     r)   <lambda>z%ModuleTester.test_1.<locals>.<lambda>   s
    QqS rV   c                     | |z   S r   r0   r1   s     r)   ri   z%ModuleTester.test_1.<locals>.<lambda>   s
    ac rV   ))      )      c                     | |z   S r   r0   r1   s     r)   ri   z%ModuleTester.test_1.<locals>.<lambda>   s
    !A# rV   N)r:   r   rc   r   whereset_fill_valuer   anyr@   r>   r   r   rE   )	r(   r2   r3   m1m2rd   ymrJ   ss	            r)   test_1zModuleTester.test_1y   sS    HHb"b#r#vr2tS"b"MNHHJK11qr*qr*XXb&!$
&!2~~a $$&'&GGww&!4454zz"~R6/2+F!FFGF! 	LAAGAGBHBHBH::b>SWvor/J%JJKJ	LrV   c                    t        j                  g d      }| j                  |g d      }| j                  |g d      }| j                  |      }t        |       t        |       t	        |d         t	        |d         u sJ |d   |d   k(  sJ d|d<   d|d<   | j                  ||       d|dd	 d|dd	 | j                  |d<   | j                  |dd	 ||d
d
 | j                  |d<   | j                  g dg d      |d
d
 | j                  g dg d      |d
d
 t        j                  d      dz  }| j                  |d      }| j                  g dt              }t        j                  g dt              }|d    |d    |dd j                  dk(  sJ g d}| j                  |      }| j                  |      }||u sJ | j                  |d      }||usJ y
)z2
        Tests conversions and indexing.

        )r/   rn   rk   rl   r/   r   r   r   r,   )r   r/   r   r/   r/   	   rn   c   rl   N)r/   rn   rl   rk   )r   r/   r/   r      rZ   ra   )r/   hellorn   rl   )r   )r   r   r/   r   r   )copy)r:   r   strreprtyperU   r   r   r   r   objectr@   r   )	r(   x1x2x3x4nrL   rt   m3s	            r)   test_2zModuleTester.test_2   s    XXl#ZZZ.ZZZ.ZZ^BRBqE{d2a5k)))!u1~~11B'1Q1Q1++1Q11!!,=1!!,=1YYq\#C(ZZ*F3XX(&1
1
1!Aw}}$$$NN1^^ABww^^AA^&{{rV   c                 6   | j                  d      }| j                  |d<   | j                  |d      }| j                  | j	                  ||g      |      sJ | j                  | j                  |      g d      sJ | j                  |dd      }| j                  |g d       | j                  |dd      }| j                  ||      sJ |j                  dd      }| j                  ||      sJ |j                  dd      }| j                  ||      sJ y	)
z&
        Tests resize/repeat

        rk   rn   )   )r   r   r/   r   r   r   r/   r   )rn   rn   rn   rn   r   axis)r   r   r/   r/   rn   rn   rl   rl   N)r   r   r   r
   r   r   r   rU   )r(   r   y4y5y6y7y8s          r)   test_3zModuleTester.test_3   s    [[^1[[T"}}T--r2h7<<<}}T\\"-/GHHH[[\[2$<=[[QQ['}}R$$$YY|!Y,}}R$$$YYq!_}}R$$$rV   c           	         | j                  d      }t        j                   d      }| j                  |dd |j                  ddd      }|j                  ddd      }| j	                  t        j
                  |d      | j                  |d            sJ | j	                  t        j                  |dd      | j                  |dd            sJ | j	                  t        j                  | j                  |d	      | j                  |d	            | j                  ||            sJ | j	                  t        j                  | j                  |d	      | j                  |d	            | j                  ||            sJ | j                  g d
t              }| j                  |d<   | j                  |g d      }|d	   dk(  sJ |d   dk(  sJ |d   dk(  sJ y)zB
        Test of take, transpose, inner, outer products.

           r|   rm   rn   rl   rk   )rn   r   r/   r/   r   )abcr/   defrn   rl   )r   rl   rk   r   N)r   r:   r   reshaper
   r!   r    r   r   r   r   r   )r(   r2   r3   ts       r)   test_4zModuleTester.test_4   s    KKOIIbM!AIIaAIIaA}}R\\!Y799UVVV}}RWWQ	15tyyIq7QRRR}}RXXdkk!Q&7Q9JK JJq!,. 	. .}}RXXdkk!Q&7Q9JK JJq!,. 	. .JJ.7{{!IIa#tu}}tqyytqyyrV   c                 ^   | j                  d      }| j                  d      }| j                  d      }| j                  |d<   |dz  }| j                  ||dz         sJ |dz  }| j                  ||dz         sJ | j                  d      }| j                  d      }| j                  |d<   |dz  }| j                  ||dz
        sJ |dz  }| j                  ||dz
        sJ | j                  d      dz  }| j                  d      dz  }| j                  |d<   |dz  }| j                  ||dz        sJ |dz  }| j                  ||dz        sJ | j                  d      dz  }| j                  d      dz  }| j                  |d<   |dz  }| j                  ||      sJ |dz  }| j                  ||      sJ | j                  d      dz  }| j                  d      dz  }| j                  |d<   |dz  }| j                  ||dz        sJ || j                  d      z  }| j                  || j	                  d             | j                  d      j                  t        j                        }| j                  d      }| j                  |d<   |dz  }| j                  ||dz         sJ y)z*
        Tests inplace w/ scalar

        
   rn   r/   rZ   r\   )r   N)r   r   r
   rU   r   r9   r:   r;   )r(   r2   r3   rd   s       r)   test_5zModuleTester.test_5   s    KKOKKO[[_1	Q}}Q!$$$
a}}R1%%%KKO[[_1	Q}}Q!$$$
a}}R1%%%KKOC[[_S 1	S}}Q!$$$
c	}}R1%%%KKOA[[_Q1	Q}}Q"""
a}}R###KKOC[[_S 1	S}}Q#&&&
dkk"oDIIe$45KKO""2::.[[_1	R}}QB'''rV   c                 B   | j                  dt        j                        }| j                  d      }| j                  dt        j                        }| j                  |d<   |j                  }| j                  dt        j                        }| j                  |d<   ||z  }||z  }| j                  |||z         sJ | j                  |||z         sJ | j                  |j                  | j                  ||j                              sJ | j                  dt        j                        }| j                  dt        j                        }| j                  |d<   |j                  }| j                  dt        j                        }| j                  |d<   ||z  }||z  }| j                  |||z
        sJ | j                  |||z
        sJ | j                  |j                  | j                  ||j                              sJ | j                  dt        j                        }| j                  dt        j                        }| j                  |d<   |j                  }| j                  dt        j                        }| j                  |d<   ||z  }||z  }| j                  |||z        sJ | j                  |||z        sJ | j                  |j                  | j                  ||j                              sJ | j                  dt        j                        }| j                  dt        j                        }| j                  |d<   |j                  }| j                  dt        j                        }| j                  |d<   ||z  }||z  }y)z)
        Tests inplace w/ array

        r   )r7   rn   N)r   r:   r;   r   r-   r
   r   )r(   r2   r3   rd   rL   as         r)   test_6zModuleTester.test_6!  s    KK"**K-KKO[[2::[.1GGKK"**K-"	Q
a}}Q!$$$}}R1%%%}}RWWdll1aff&=>>>KK"**K-[[2::[.1GGKK"**K-"	Q
a}}Q!$$$}}R1%%%}}RWWdll1aff&=>>>KK"**K-[[2::[.1GGKK"**K-"	Q
a}}Q!$$$}}R1%%%}}RWWdll1aff&=>>>KK"**K-[[2::[.1GGKK"**K-"	Q
arV   c                 2   | j                  dddt        dz  gdz  ddgdgdz  z         | j                  dddt        dz  gdz  ddgdgdz  z         f}dD ]  }	 t        | j                  |      }t        | j                  |      }|d	|j                   } || } || }| j                  |j                  d      |j                  d      |       | j                  |j                  |j                          y	# t        $ r t        t
        |      }Y w xY w)
zTests ufuncrZ   r   r   rn   r/   rm   r,   )sqrtloglog10exp	conjugateN)r   rc   getattrr$   r%   fromnumericr	   ninrU   r   _mask)r(   dfufmfargsurmrs           r)   test_7zModuleTester.test_7U  s    ZZaRT*1,Aq61#a%<Z@ZZaRT*1,Aq61#a%<Z@C 	8A&-TZZ+ a(BWbff:DTBTB##BIIaL"))A,B##BHHbhh79	8* " -[!,-s   C::DDc           
      
   | j                  g dg d      }| j                  d| j                  |d             | j                  d| j                  |g d             | j                  |g dd	
      \  }}| j                  d|       |dk(  sJ | j                  |d d  | j                  |d      | j                  u sJ | j                  g dg d      }|j	                  dd      }| j                  |d d d	f<   | j                  | j                  |d      ddg       | j                  |d	      d   | j                  u sJ | j                  ddg| j                  |d             | j                  |dd	      \  }}| j                  |ddg       g d}g dg dg}| j                  d      }| j                  | j                  |d      d       | j                  | j                  |d|      d       | j                  | j                  d      d| j                  d      z  g      }| j                  | j                  |d       t        j                  j                  t        j
                  d            dz  dz         | j                  | j                  |d      t        j
                  d      dz  dz         | j                  | j                  |d	      | j                  |d      | j                  |d      dz  g       | j                  | j                  |d |      d       | j                  | j                  |d|      g d       | j                  | j                  |d	      | j                  |d      | j                  |d      dz  g       | j                  d      }g d}	g dg dg}
| j                  d      }g d}| j                  | j                  | j                  ||      d      d       | j                  | j                  | j                  ||	      d      d       | j                  | j                  | j                  ||      d      d       | j                  | j                  | j                  | j                  ||      d            d       | j                  ||
      }| j                  | j                  |d       d       | j                  | j                  |d      g d       | j                  | j                  |d	      ddg       | j                  | j                  |d|      g d       y )N)rg   rZ   r\   ra   ry   r,   r\   r   r   )rZ   rZ   r\   rZ   )weightsr/   )r   returnedr]   rn   rg   )r   r   rZ   )r   r/   r/   r/   r/   r   )r/   r   r   r   r   r/   rm   g      @)r   r   ra   g      (@g
@)rg   rZ   r\   ra   r]   r`   )r   r   r/   r/   r   r   )r   r/   r/   r/   r/   r/   )rg   rZ        X@r   r]   g      @r^   )rg   rZ   r   r   r]   r`   )r   rU   averager   r   r   r:   addr   r"   r   r   r   )r(   ottresultwtsw1w2r2   r3   rs   rt   r   m4m5zs                 r)   test_99zModuleTester.test_99x  s    jj)j=T\\#A\%>?T\\#?O\%PQll30@1lMV,czzA||Ca|(DKK787jj)j=kk!QKKAqD	Sq 9C:F||Ca|(+t{{:;:R$,,s,*CDll3Ql;b"X. "45KKNQQ 7=QQ CSIJJADKKN(:;<Q 5rvv}}RYYq\7RSU7UVY7YZQQ 719J29MNQQ 7$,,qq,:QSWS_S_`ahiS_SjmpSp9qrQb A6JQQ CE^_QQ 7$,,qq,:QSWS_S_`ahiS_SjmpSp9qrZZ] "45YYq\T->->q"-EA NPSTT->->q"-EA NPSTT->->q"-EA NPST

4<<8I8I!R8PWX<+Y Z\]^a$Q 5v>QQ 79UVQQ 7#sDQQ CEbcrV   c                 j    | j                  d      }| j                  |dd |j                  ddd      }y )Nr   r|   rm   rn   rl   rk   )r   r   r   )r(   r2   s     r)   test_AzModuleTester.test_A  s0    KKO!AIIaArV   N) r   T)r   )__name__
__module____qualname__r*   rS   rU   r:   errstatere   rw   r   r   r   r   r   r   r   r   r0   rV   r)   r   r      s]    D IK$(5)nA R[[X  R[[XL L6 R[[X( (T R[[X% %& R[[X . R[[X2( 2(h R[[X1 1f R[[X 8  8D R[[X+d +dZ R[[X rV   r   __main__zNfrom __main__ import ModuleTester 
import numpy
tester = ModuleTester(module)
zimport numpy.ma.core as module
)r   r   r/   r   ztester.test_%i()r   z#%iz2..................................................zModuleTester.test_%i.__doc__zcore_current : z.3fz - )timeit	functoolsr   numpyr:   numpy._core.fromnumeric_corer   numpy.testingr   rc   r   r   
setup_base	setup_curnrepeatnlooprangeifuncTimerr   curr   printevalr0   rV   r)   <module>r      s       - - ' UU^ ^B z4J 3Z?IWe1a[ =!A%fll4+227E"HEbggcleai& !d1A567As|3s1vcl;<= rV   