
    gn.                        d dl Z d dlZd dlZd dlZd dlmZ d dlm	Z	 d dlm
Z
 d Zej                  j                   e j                         dk7  d      d	        Zej                  j                   e j                         dk7  d      d
        Zd Zd Zd Zd Z e	dg      d        Z e	dg      d        Z e	dgd      d        Zd Z e	dgd      d        Z e	dgd      d        Z e	dgd      d        Z e	dgd      d        Z e	d gd      d!        Zd" Zd# Zd$ Z  e	d%gd      d&        Z!d' Z"d( Z#d) Z$d* Z%d2d+Z&d2d,Z'ej                  jQ                  d-g d.       e
d/g0      d1               Z)y)3    N)pyplot)image_comparison)check_figures_equalc                 L   t        j                  t        j                  ddt         j                  z  d      t        j                  ddt         j                  z  d            \  }}t        j                  |      }t        j
                  |      } | j                  ||fi |}|S )Nr         )npmeshgridarangepicossinquiver)axkwargsXYUVQs          Y/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/matplotlib/tests/test_quiver.pydraw_quiverr      sy    ;;ryyAIq1yyAIq13DAq
q	A
q	A		!Q!&!AH    CPythonzRequires CPython)reasonc                      t        j                         \  } }t        |      }|j                  }|j	                          ~t        j                  |      dk(  sJ y )Nr   )pltsubplotsr   r   removesysgetrefcount)figr   r   ttXs       r   test_quiver_memory_leakr$      sH     llnGCBA
##CHHJ	??31$$$r   c            
         t        j                         \  } }t        |      }|j                  |dddddddi      }t	        j
                  |      d	k(  sJ |j                          t	        j
                  |      dk(  sJ y )
N      ?q=
ףp?r   $2 \frac{m}{s}$Wweightboldlabelposfontproperties   )r   r   r   	quiverkeyr    r!   r   )r"   r   r   qks       r   test_quiver_key_memory_leakr2   $   s~     llnGCBA	adA'9"&.%7 
 
9B ??2!###IIK??2!###r   c            	      *   ddg} t        j                  t        d      5  t        j                  |        d d d        t        j                  t        d      5  t        j                  | | | | | |        d d d        y # 1 sw Y   HxY w# 1 sw Y   y xY w)Nr   r   z7takes from 2 to 5 positional arguments but 1 were givenmatchz7takes from 2 to 5 positional arguments but 6 were given)pytestraises	TypeErrorr   r   )r   s    r   test_quiver_number_of_argsr9   3   s    	
AA	K
M  	

1 
K
M % 	

1aAq!$% %	 % %s   A=B	=B	Bc                  V   ddg} g d}t        j                  t        d      5  t        j                  | || |        d d d        t        j                  t        d      5  t        j                  | | ||        d d d        t        j                  t        d      5  t        j                  | | | |       d d d        t        j                  t        d      5  t        j                  | | | | |       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   _xY w# 1 sw Y   y xY w)	Nr   r   )r   r   r/   z?X and Y must be the same size, but X.size is 2 and Y.size is 3.r4   zMArgument U has a size 3 which does not match 2, the number of arrow positionszMArgument V has a size 3 which does not match 2, the number of arrow positionszMArgument C has a size 3 which does not match 2, the number of arrow positions)r6   r7   
ValueErrorr   r   )X2X3s     r   test_quiver_arg_sizesr>   ?   s   
QB	B	  >
@ # 	

2r2r"# 
  B
D # 	

2r2r"# 
  B
D # 	

2r2r"# 
  B
D ' 	

2r2r2&' '# ## ## #' 's/   C; DDD;DDDD(c                     t        j                         \  } }t        j                  t        j                  d      t        j                  d            \  }}t        j
                  |      x}}t        j                  j                  dd      dz
  dz  }|j                  |||||       | j                  j                          y )N   
   r&      angles)r   r   r	   r
   r   	ones_likerandomrandr   canvasdrawr"   r   r   r   r   r   phis          r   test_no_warningsrL   T   s    llnGC;;ryy}biim4DAqLLOA99>>"b!B&#
-CIIaAqI%JJOOr   c                  b   t        j                         \  } }t        j                  t        j                  d      t        j                  d            \  }}t        j
                  |      t        j                  |      }}|j                  ||dd       | j                  j                          y )NrA   r   )
headlengthheadaxislength)
r   r   r	   r
   r   r   r   r   rH   rI   )r"   r   r   r   r   r   s         r   test_zero_headlengthrP   ]   sr     llnGC;;ryy}biim4DAq66!9bffQiqAIIaqI3JJOOr   zquiver_animated_test_image.pngc            
          t        j                         \  } }t        |d      }|j                  |ddddddd	i
       y )NT)animatedr&   r'   r   r(   r)   r*   r+   r,   )r   r   r   r0   r"   r   r   s      r   test_quiver_animaterT   g   sF     llnGCB&ALLCq"4x.@  Br   zquiver_with_key_test_image.pngc                      t        j                         \  } }|j                  d       t        |      }|j	                  |dddddddd	d
d	       y )N皙?r&   gffffff?r   z"$2\, \mathrm{m}\, \mathrm{s}^{-1}$ifigurer)   r+   large)r*   size)anglecoordinatesr-   r.   )r   r   marginsr   r0   rS   s      r   test_quiver_with_keyr]   p   sS    llnGCJJsOBALLCq6%+17 C  Er   zquiver_single_test_image.pngT)remove_textc                      t        j                         \  } }|j                  d       |j                  dgdgdgdg       y )NrV   r   r   )r   r   r\   r   r"   r   s     r   test_quiver_singlera   }   s6    llnGCJJsOIIqcA3aS!r   c                     t        j                         \  } }t        t        j                  dg      t        j                  dg            }|j                  dgdg|d   |d         }d|d   d<   |j                  d   dk(  sJ y )N皙?g       @)uvr   rd   re   r   )r   r   dictr	   arrayr   r   )r"   r   uvq0s       r   test_quiver_copyrj      sr    llnGC	#288SE?	3B	A3RWbg	.BBsGAJ447c>>r   zquiver_key_pivot.pngc                  "   t        j                         \  } }t        j                  ddt        j                  z  dddt        j                  z  df   \  }}|j                  t        j                  |      t        j                  |            }|j                  dd       |j                  dd       |j                  |ddddd	       |j                  |dddd
d
	       |j                  |ddddd	       |j                  |ddddd	       y )Nr   r   y              $@   r&   r   N)r-   ESr)   )r   r   r	   mgridr   r   r   r   set_xlimset_ylimr0   )r"   r   rd   re   qs        r   test_quiver_key_pivotru      s    llnGC88AagcM1QruuWS=01DAq
		"&&)RVVAY'AKKBKKBLLCAsSL1LLAsAsSL1LLCAsSL1LLAsAsSL1r   zquiver_key_xy.pngc                     t        j                  d      } t        j                  d      }| t         j                  dz  z  }t        j                  d|z        }|j
                  }|j                  }t        j                  d      \  }}t        |d      D ]p  \  }}	|j                  dd       |j                  dd       |j                  | |||d	d
ddd
|	
      }
t        dd      D ]  \  }}|j                  |
|dd|dd        r y )N      y              ?r   )rh   xygɿ皙?middlery   g?)pivotunitswidthscalescale_unitsrD   )r{   r&   皙?)r   -   Z   r   r    b)r   r   r   rZ   labelcolor)r	   r   zerosr   exprealimagr   r   ziprr   rs   r   r0   )r   r   rD   rh   r   r   r"   axsr   	angle_strrt   xrZ   s                r   test_quiver_key_xyr      s     			!A
A"%%!)_F	V	B
A
A||AHCS,/ OI
B
D#IIaAq 4&  ( O[9 	OHAuLLa3!5#LN	OOr   zbarbs_test_image.pngc                     t        j                  ddd      } t        j                  | |       \  }}d|z  d|z  }}t        j                         \  }}|j                  ||||t        j                  ||      ddt        ddd	      d
	       y )N      TF      ?r{   333333?	emptybarbspacingheightviridis)
fill_emptyroundingsizescmap)r	   linspacer
   r   r   barbshypotrf   r   r   r   r   r   r"   r   s          r   
test_barbsr      s    
B1A;;q!DAqa4AqAllnGCHHQ1a!QD5$C@  r   zbarbs_pivot_test_image.pngc                     t        j                  ddd      } t        j                  | |       \  }}d|z  d|z  }}t        j                         \  }}|j                  ||||dddt        ddd	
             |j                  ||dd       y )Nr   r   r   TF333333?r   r{   r   r   )r   r   r}   r   1   black)sc)r	   r   r
   r   r   r   rf   scatterr   s          r   test_barbs_pivotr      s    
B1A;;q!DAqa4AqAllnGCHHQ1aD5$C@  BJJq!rWJ%r   zbarbs_test_flip.pngc                      t        j                  ddd      } t        j                  | |       \  }}d|z  d|z  }}t        j                         \  }}|j                  ||||dddt        ddd	
      |dk  	       y)z'Test barbs with an array for flip_barb.r   r   r   TFr   r   r{   r   r   r   )r   r   r}   r   	flip_barbN)r	   r   r
   r   r   r   rf   r   s          r   test_barbs_flipr      s|     	B1A;;q!DAqa4AqAllnGCHHQ1aD5$C@1u  r   c                     t        j                         \  } }t        j                  dg      }t        j                  dg      }|j	                  dgdg||      }d|d<   |j
                  d   dk(  sJ d|d<   |j                  d   dk(  sJ y )Nrc   g@r   r   )r   r   r	   rg   r   rd   re   )r"   r   rd   re   b0s        r   test_barb_copyr      s    llnGC
#A
#A	1#sAq	!BAaD447c>>AaD447c>>r   c                  R   t        j                  d      } t        j                  d      }t         j                  j                  dt        j                  d      z        }t         j                  j                  dt        j
                  |      z        }t         j                  j                  |d<   t         j                  j                  |d<   t        j                         \  }}t        j                  t              5  |j                  | |||       ddd       y# 1 sw Y   yxY w)z=Test error handling when given differing sized masked arrays.r/   g      .@)rx   r   N)r	   r   marg   onesrE   maskedr   r   r6   r7   r;   r   )r   yrd   re   r"   r   s         r   test_bad_masked_sizesr      s    
		!A
		!A
C"''$-'(A
C",,q/)*A55<<AaD55<<AaDllnGC	z	" 
Aq!  s   ?DD&c                  X   t        j                         \  } }t        j                  t        j                  d      t        j                  d            \  }}t        j
                  |      x}}t        j                  j                  dd      dz
  dz  }|j                  |||||d       y )Nr@   rA   r&   rB   ry   rD   r   )	r   r   r	   r
   r   rE   rF   rG   r   rJ   s          r   test_angles_and_scaler      s}    llnGC;;ryy}biim4DAqLLOA99>>"b!B&#
-CIIaAq$I7r   zquiver_xy.pngc            	          t        j                  t        d            \  } }|j                  ddddddd       |j	                  dd       |j                  dd       |j                          y )	Nequal)aspect)
subplot_kwr   r   ry   )rD   r   r   rc   )r   r   rf   r   rr   rs   gridr`   s     r   test_quiver_xyr      sZ     lld'&:;GCIIaAq4qIAKK3KK3GGIr   c                     t        j                         \  } }t        j                  t        j                  d      t        j                  d            \  }}t        j
                  |      x}x}}|j                  |||||      }|j                  |dddd      }| j                  j                          t        |j                        dk(  sJ y )Nr   rC   r   Label)r   r   r	   r
   r   rE   r   r0   rH   rI   lenverts)	r"   r   r   r   r   r   rD   rt   r1   s	            r   test_quiverkey_anglesr      s     llnGC;;ryy|RYYq\2DAq\\!_$A$F
		!Q1V	,A	aAq'	*BJJOOrxx=Ar   c                  F   ddidddddig} | D ]  }t        j                  t         j                   t         j                  d      }t        j                  |      t         j                  z  dz  }t        j                  |      }t        j                  |      }t        j                         }|j                  d      } |j                  ||||fi |}|j                  |d	d	d
d      }	|j                  j                          t        |	j                        d
k(  rJ  y )NrD   ry   r   r   rm      aitoff)
projectionr   r   1 units)r	   r   r   rE   
zeros_liker   rW   add_subplotr   r0   rH   rI   r   r   )
kwargs_listkwargs_dictr   r   vxvyr"   r   rt   r1   s
             r   test_quiverkey_angles_xy_aitoffr     s     
4-	K # "KKr*LLObee#a']]1\\!_jjl___1BIIaB2k2\\!Q1i0

288}!!!"r   c            	      d   ddidddddig} | D ]  }g d}g d}g d}g d}t        j                         \  }} |j                  ||||fi |}|j                  |dd	d
dd       |j                  |ddd
d      }	|j                  j                          t        |	j                        d
k(  rJ  y )NrD   ry   r   r   )r   rz   r   )r   rz   r   )r   rz   r   r   rc   r   zQuiver key, length = 1ro   )r   r   r   r   r-   r   r   )r   r   r   r0   rH   rI   r   r   )
r   r   r   r   r   r   r"   r   rt   r1   s
             r   +test_quiverkey_angles_scale_units_cartesianr   ,  s     
4-	K # ",,.RBIIaAq0K0
Q#3c 	 	C\\!Q1i0

288}!!!"r   c                  *   t        j                         \  } }t        j                  t        j                  d      t        j                  d            \  }}t        j
                  |      x}}|j                  ||||      }|j                  dd       y)zBCheck that it is possible to set all arrow UVC to the same numbersr   r   r   N)r   r   r	   r
   r   rE   r   set_UVC)r"   r   r   r   r   r   rt   s          r   test_quiver_setuvc_numbersr   G  sj     llnGC;;ryy|RYYq\2DAqLLOA
		!Q1AIIaOr   c                    t        j                  ddd      }t        j                  ddd      }t        j                  ||      \  }}d\  }}| j                         }|j	                  ||||d      }	|j                  dd       |j                  dd       |2|j                  |	d	d	d
ddd       |j                  |	ddddddd       y|j                  |	d	d	d
ddd|       |j                  |	ddddddd|	       y)z/Draw Quiver and QuiverKey using zorder argumentr   r   r   r   r|   r}   r&         @Nrx      datar   bluer[   r   r   r      r   r   r[   r   r   rZ   )r[   r   r   zorder)r[   r   r   rZ   r   )r	   r   r
   r   r   rr   rs   r0   )
r"   r   r   r   r   r   r   r   r   rt   s
             r   draw_quiverkey_zorder_argumentr   S  s   
		!QA
		!QA;;q!DAqDAq	B
		!Q1H	-AKKSKKS~
Q1bff 	 	.
QQfB 	 	8 	Q1bffV 	 	=
QQfBv 	 	Gr   c           
         t        j                  ddd      }t        j                  ddd      }t        j                  ||      \  }}d\  }}| j                         }|j	                  ||||d      }	|j                  dd       |j                  dd       |j                  |	ddd	d
dd      }
|j                  |	dddd
ddd      }|#|
j                  |       |j                  |       yy)z*Draw Quiver and QuiverKey using set_zorderr   r   r   r|   r   r&   r   rx   r   r   r   r   r   r   r   r   r   r   N)	r	   r   r
   r   r   rr   rs   r0   
set_zorder)r"   r   r   r   r   r   r   r   r   rt   qk1qk2s               r   draw_quiverkey_setzorderr   j  s    
		!QA
		!QA;;q!DAqDAq	B
		!Q1H	-AKKSKKS
,,q!Q   0C
,,q#q"& b  :Cvv r   r   )r   r   r   Npng)
extensionsc                 8    t        | |       t        ||       y )N)r   )r   r   )fig_testfig_refr   s      r   test_quiverkey_zorderr   ~  s     #8F;WV4r   )N)*platformr    numpyr	   r6   
matplotlibr   r   matplotlib.testing.decoratorsr   r   r   markskipifpython_implementationr$   r2   r9   r>   rL   rP   rT   r]   ra   rj   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   parametrizer    r   r   <module>r      s0    
   $ : = 2H224	A-  /	%/	% 2H224	A-  /
$/
$	%'* 345B 6B 345	E 6	E 12E" F" )*=2 >2 &'T:O ;O. )*= > /0dC& D& ()t< =
8 ?#6 7":"6	G.( ?3(5 ) 45r   