
    P/Ph{:                        d 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Zddl	m
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dlmZ ddlmZ ddlmZ dd	lmZmZ d
 Zej         !                    d          d             Z"d Z#d Z$ edgdd          d             Z%d Z&d Z'd Z(d Z) edgd ej*                    dk    rdnd          d             Z+ ed          d             Z,d  Z-d! Z. ed"gdd# ej*                    d$k    rdnd%&          d'             Z/ ed(gd)          d*             Z0d+ Z1 ed,gd-.          d/             Z2d0 Z3 e            d1             Z4ej         5                    d2d3d4g           ed          d5                         Z6d6 Z7d7 Z8 ed8gdd#9          d:             Z9 e            d;             Z:d< Z; e            d=             Z< ed>g          d?             Z=d@ Z>dA Z?dS )Bz%
Tests specific to the lines module.
    N)SimpleNamespace)cycler)assert_array_equal)_path)MarkerStyle)Path)image_comparisoncheck_figures_equalc            	          d\  } }t          j        ddg          t          j        ddg          }}d}t          t          j        | ||||          dg           dS )zTest a problematic case.)i)  i  g     H@g     W@g     @g(\@r   N)nparrayr   mlinessegment_hits)cxcyxyradiuss        [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/matplotlib/tests/test_lines.pytest_segment_hitsr      s`    FB8T4L!!28S$K#8#8qAFv*2r1a@@1#FFFFF       )rerunsc                     d} t          j        dd|           }t           j                            |           }t	          j                    }t	          j                    }t          j        ||          }|	                    d           t          t          j        |j        j        dd                    }|                    |           t          t          j        |j        j        dd                    }||z  }d}	||	k     sJ d	S )
ac  
    GitHub issue #1256 identified a bug in Line.draw method

    Despite visibility attribute set to False, the draw method was not
    returning early enough and some pre-rendering code was executed
    though not necessary.

    Consequence was an excessive draw time for invisible Line instances
    holding a large number of points (Npts> 10**6)
    i r      sizeFr   )numberrepeat   N)r   linspacerandomnormalpltfiguresubplotr   Line2Dset_visiblemintimeitr   canvasdrawadd_line)
Nr   r   figaxl	t_no_linet_invisible_lineslowdown_factorslowdown_thresholds
             r   test_invisible_Line_renderingr6   $   s     	A
Aq!A
	a  A *,,C	B 	aAMM%
 FM#*/!AFFFGGI KKNNN 6=1MMMNN '2O///////r   c                      t          j                    \  } }t          j                            d           |                    t          j                            dd          dg           d S Nr         r   )r   r   )
linestylesr$   subplotsr   r"   seedcontourrandnr/   r0   s     r   test_set_line_coll_dashrC   P   sU    lnnGCINN1 JJryr2&&K=JAAAAAr   c                  r   t          j        t          d          5  t          j        dg            d d d            n# 1 swxY w Y   t          j        t          d          5  t          j        g d           d d d            n# 1 swxY w Y   t          j        g g           } t          j        t          d          5  |                     d           d d d            n# 1 swxY w Y   t          j        t          d          5  |                     d           d d d            d S # 1 swxY w Y   d S )Nzxdata must bematchr   zydata must ber   z	x must bez	y must be)pytestraisesRuntimeErrorr   r'   	set_xdata	set_ydatalines    r   test_invalid_line_datarN   X   s   	|?	;	;	;  a              	|?	;	;	;  b!               =R  D	|;	7	7	7  q              	|;	7	7	7  q                 sE   >AA$BB
B
C##C'*C'	D,,D03D0line_dashesTg~jth?)remove_texttolc                  |    t          j                    \  } }|                    t          d          dd           d S )N
   r;      	linestylelw)r$   r>   plotrangerB   s     r   test_line_dashesrZ   e   s7     lnnGCGGE"IIG33333r   c                     t          j                    \  } }|                    t          d          d           |                    t          d          d           |                    t          d          d           |                    t          d          d           |                    t          d          d           | j                                         d S )NrS   none)colorrz.3)r   r   r   r   )r   r   r   r$   r>   rX   rY   r+   r,   rB   s     r   test_line_colorsr`   n   s    lnnGCGGE"IIVG$$$GGE"IISG!!!GGE"IITG"""GGE"II\G***GGE"IIYG'''JOOr   c                      t          j        g g           } t          j        t                    5  |                     d           d d d            d S # 1 swxY w Y   d S Nfoobar)r   r'   rG   rH   
ValueError	set_colorrL   s    r   test_valid_colorsrf   x   s    =R  D	z	"	" ! !x   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !   AAAc                      t          j                    \  } }ddddddddd	d
dg ffD ]&}|                    t          d          |           '| j                                         d S )N-solid--dashedz-.dashdot:dotted)r   N)r    r   rS   )rV   r_   )r/   r0   lss      r   test_linestyle_variantsrr   ~   sx    lnnGCGT8YX'Ar7 ) ) 	b		R((((JOOr   c                      t          j        g g           } t          j        t                    5  |                     d           d d d            d S # 1 swxY w Y   d S )Naardvark)r   r'   rG   rH   rd   set_linestylerL   s    r   test_valid_linestylesrv      s    =R  D	z	"	" ' ':&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'rg   zdrawstyle_variants.pngarm64gQ?c                      t          j        d          \  } }g d}t          |j        |          D ]@\  }}|                    t          d          |           |                    dd           Ad S )N   )defaultz	steps-mid	steps-prez
steps-poststepsN  	drawstyle)r   r    )xlimylim)r$   r>   zipflatrX   rY   set)r/   axsdssr0   dss        r   test_drawstyle_variantsr      s     |AHC
L
L
LC
 ch$$ ) )B
dr***
F(((() )r   )png)
extensionsc                 >   |                                  }t          j        d          }|                    |dz   |           |                                 }t	          j                                        dd          }|                    ||||j        z              d S )Nr}   g     @@        )	transform)add_subplotr   arangerX   mtransformsAffine2D	translate	transData)fig_reffig_testr0   r   ts        r   test_no_subslice_with_transformr      s    					B
	$AGGAHa					B((55AGGAqAblNG+++++r   c                      t          j        g g           } t          j        t                    5  |                     d           d d d            d S # 1 swxY w Y   d S rb   )r   r'   rG   rH   rd   set_drawstylerL   s    r   test_valid_drawstylesr      s    =R  D	z	"	" % %8$$$% % % % % % % % % % % % % % % % % %rg   c                     t          j        ddt           j        z  d          } t          j        |           }t	          j                    \  }}|                    | |          \  }|                    d           t          |	                                j
                  dt          |           z  dz
  k    sJ |                    d           t          |	                                j
                  t          |           k    sJ d S )Nr   r    rS   r{   r   rz   )r   r!   pisinr$   r>   rX   r   lenget_pathvertices)r   r   r/   r0   rM   s        r   test_set_drawstyler      s    
Aqw##A
q		AlnnGCGGAqMMED{###t}}'((Ac!ffHQJ6666y!!!t}}'((CFF222222r   line_collection_dashesmpl20x86_64g?)rP   stylerQ   c                      t          j                    \  } }t          j                            d           |                    t          j                            dd          dg           d S r8   r=   rB   s     r   test_set_line_coll_dash_imager      sU     lnnGCINN1JJryr2&&K=JAAAAAr   zmarker_fill_styles.png)rP   c                  @   t          j        g ddddddt          j        g d          g          } d}t          j        d	d	g          }t          j        d
dg          }t	          j                    \  }}t          d          D ]j\  }}t          t          j        j	                  D ]F\  }}	t          |           }
|                    |dz  |z   ||z   d|dz  z  z   |d||	|	d|
|
d           Gk|                    d
dg           |                    ddg           d S )Nr   r   r   gz#ff0000cmr   )r   r   r   
lightgreenr   r   	   zov^<>8sp*hHDdPXrS         ?r    r9   rT   )	marker
markersizemarkerfacecoloralt	fillstylelabel	linewidthr]   markeredgecolormarkeredgewidthg      @   )	itertoolscycler   r   r$   r>   	enumerater   r'   
fillStylesnextrX   set_ylimset_xlim)colorsaltcolorr   r   r/   r0   jr   ifsr]   s              r   test_marker_fill_stylesr      sM   _iiiic3 hyyy113 4 4FH
!QA
!QAlnnGC 011 ' '	6v}788 	' 	'EArLLEGGAFQJAa!e 4!!'/ $)$%  	' 	' 	' 	'	' KKCKKS	r   c                      t          j        g dt          dd          d          \  } |                                 dk    sJ |                                 dk    sJ dS )z=Test that markerfacecolor does not override fillstyle='none'.r   r   r    or\   )r   red)r   markerfacecolorN)r$   rX   r   get_fillstyleget_markerfacecolor)r1   s    r   test_markerfacecolor_fillstyler      sp    	)))Kv$F$F$F"'
) 
) 
)BA??&&&&  ""f,,,,,,r   scaled_linesrz   )r   c            	      z   t          j        dd          } t          j                    \  }}g d}t	          t
          j        d                   }t          t          ||                    D ]N\  }\  }}t          j        ddd          D ]/} |j	        | |t          j
        d          z  d|z  z   f||d	| 0Od S )
Nr       )rl   ro   rm   axes.prop_cycler   rS   2   皙?rU   )r   r!   r$   r>   r   
matplotlibrcParamsr   r   rX   ones)	thr/   r0   lins_stylesr   r   rq   styrW   s	            r   test_lw_scalingr      s    	Q		BlnnGC111K	
#$56	7	7B!#k2"6"677 M M9B+b"b)) 	M 	MBBGB"'"++R/L2"LLLLLL	MM Mr   c                     t          j        t          j        g d                    sJ t          j        t          j        dt          j        dg                    sJ t          j        ddgt          j        gdz  z   ddgz             rJ t          j        t          j        dd	gd
                    rJ dt
          j        j        z  } t          j	        t          j        g| z  t          |                      d S )Nr   r    r   r   r   rT   d   r   r    i   i   z>i4)r   is_sorted_and_has_non_nanr   r   nanr   r'   _subslice_optim_min_sizer$   rX   rY   )ns    r   test_is_sorted_and_has_non_nanr      s    *28III+>+>?????*28QN+C+CDDDDD.1v3/F!Q/OPPPPP.rx58I5/Q/QRRRRR	FM22AHbfX\588$$$$$r   c                     |                                                      ddgd           |                                                     g dg ddddg           d S )Nr   r   z-or   )r   r   r   r    	markevery)r>   steprX   r   r   s     r   test_step_markersr      sc    aVT***IIIyyy$1a&IIIIIr   parentr%   axesc                 ^    t           j                            d           t          j        ddd          }t           j                            t          |                    }d ddg dddgt          d	d
d          t          j        t          |                    |dk             ddg	}g d}|dk    r|d d         }|d d         } fd}fd}n`|dk    rZt           	                    dd          j
                  t          	                    dd          j
                  fd}fd}|D ]}	 ||||	           |D ]a}	t          j        t          |	                                        t                                        t                    }
 ||||
           bd S )N*   r   r         )r    rT   )r   rT      rT   rS   r    r   333333?)r   皙?)	111111111111111000100010001000100001000010010001000001001000000000000100000101010000011100011101101101101101111001010011011101r%   c                ^                         t          j        | |d|                     d S Nr   r   r   
add_artistr   r'   )r   r   r   r   s      r   add_testz test_markevery.<locals>.add_test  s@    a3)DDDF F F F Fr   c                ^                         t          j        | |d|                     d S r   r  )r   r   r   r   s      r   add_refztest_markevery.<locals>.add_ref  s@    a3)DDDF F F F Fr   r   r   c                T    t                                        | |d|           d S Nz-gDr   r   rX   )r   r   r   axs_tests      r   r  z test_markevery.<locals>.add_test&  s,    NN1eyAAAAAr   c                T    t                                        | |d|           d S r  r  )r   r   r   axs_refs      r   r  ztest_markevery.<locals>.add_ref)  s,    MMq!Ui@@@@@r   r   )r   r"   r?   r!   randr   slicer   iterr>   r   r   listastypeintbool)r   r   r   r   r   
cases_test	cases_refr  r  casemer  r	  s   ``         @@r   test_markeveryr    s%    INN2
Aq"A
	s1vvA6:::b'5B??)CFF##AG,z#JG G GI _
crcN		F 	F 	F 	F 	F	F 	F 	F 	F 	F 	F 
6		))!Q//455w''1--233	B 	B 	B 	B 	B	A 	A 	A 	A 	A  ' 'A&&&&& $ $Xd4jj!!((--44T::1#####$ $r   c                      t          j                    } |                     t          j        ddgddgdd                     t          j        t                    5  | j        	                                 d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   )
r$   r%   r  r   r'   rG   rH   rd   r+   r,   )r/   s    r   .test_markevery_figure_line_unsupported_relsizer  4  s    
*,,CNN6=!Q!QrJJJKKK	z	"	"  
                 s   BB
Bc                  .   t          j                    \  } }|                    g dt          d                    \  }| j                                         |                                dk    sJ |                    d           | j                                         |                    t          d                     | j                                         t          j	        ddgddgdd	gg          }|                    g d
t          |          d          \  }|                    g d|d          \  }t          |                                j        |j                   t          |                                j        |j                   d S )N)r    r   r   D)r   sr   r   r   r   r    r      )r   ms)r   r    r   )r$   r>   rX   r   r+   r,   
get_marker
set_markerr   _create_closedr   r   )r/   r0   rM   	triangle1line2line3s         r   test_marker_as_markerstyler%  ;  sb   lnnGCGGIIIk#&6&6G77EDJOO??#### 	OOCJOOOOK$$%%%JOO#b"X2wA$?@@IWWYYY{9'='="WEEFEWWYYYyRW88FEu''))2I4FGGGu''))2I4FGGGGGr   zstriped_line.png)rP   r   c            	      Z   t           j                            d          } t          j                    \  }}|                    |                     d          ddddd	           |                    |                     d          d
ddddd           |                    d           d S )Ni!N,   r   orangebluerk   rT    )r]   gapcolorrV   rW   r   r   black)r   )r    rT   r   r    r   )r]   r+  rV   rW   r   alpha)handlelength)r   r"   default_rngr$   r>   rX   uniformlegend)rng_r0   s      r   test_striped_linesr4  O  s    
)


)
)CLNNEArGGCKKRK  6q  - - -GGCKKRK  'AS  E E EII1Ir   c                     |                                                      ddgg d           |                                                     ddgg d           d S )Nr   r    r   )dashes)r   r    r   r   r    r   )r   rX   r   s     r   test_odd_dashesr7  Z  se    Ayyy9991v.@.@.@AAAAAr   c                     t          j                    \  } }t          | j        j        dz  | j        j        dz  dz             }|                    ddgddgd          \  }|                    |          \  }}|rJ |                    ddgddgdd	          \  }|                    |          \  }}|sJ t          |d
         dg           |                    ddgddgd          \  }|                    |          \  }}|rJ |	                    d           |                    |          \  }}|sJ t          |d
         dg           d S )Nr       )r   r   r   r   T)pickerr9   )r:  
pickradiusind)
r$   r>   r   bboxwidthheightrX   containsr   set_pickradius)r/   r0   mouse_eventl0foundindicesl1l2s           r   test_pickingrH  `  sp   lnnGC!CHNa$7$'HOq$82$=? ? ?K ''1a&1a&'
.
.CB[[--NE7 ''1a&1a&"'
=
=CB[[--NE7LLLwu~s+++ ''1a&1a&'
.
.CB[[--NE7b[[--NE7LLLwu~s+++++r   c                 8   t          j        ddd          }|                                                     ||d          \  }t	          d          |d d <   |                    d           |                                                    g dg ddd           d S )	Nr   ry   r    z.-r   r|   )r   r    r   r~   )r   r   r   rX   rY   r   )r   r   r   r1   s       r   test_input_copyrJ  z  s     		!QA						$	$Q4	0	0BA88AaaaDOOGyyy)))TWMMMMMr   r   c                 R   dddg dddgt          ddd	          d
ddddg}t          j        d         } |t          j        ddt          |                              }t          j        dd          }d|dz  z  }|                                }t          |          D ]'\  }}	|                    ||z
  d|	||                    (t          ||          t          j        d<   |                                 }
t          |          D ]\  }}|
                    ||z
  d           dS )z*Test that we can set markevery prop_cycle.N   )r:   rL  )      r:   r   r   r      r   r   r   g      ?)r   r   )g?r   jet皙?皙?r   rT   r    zo-)r   r]   r   )r  mpl	colormapsr   r!   r   r   r   rX   r   r   r   )r   r   casescmapr   r   r   r   r   r   r0   r3  s               r   test_markevery_prop_cyclerW    sR    1g|||aW3Qc3&E =DT"+c3E

3344F
BA	AqDA




C!%(( D D9Q	CCCC-3e:@.B .B .BJ)* 
				B%    1
At r   c                  X   t          j                    \  } }|                    dd          }|                    dd          }|                    d           |                    d           |                    d           |                    d           |                                dk    sJ |                                dk    sJ |                                dk    sJ |                                dk    sJ t          j
        t          j                  5  |                    d	d
           d d d            n# 1 swxY w Y   t          j
        t          j                  5  |                    dd           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    d	d
           d d d            n# 1 swxY w Y   t          j        t          d          5  |                    d           d d d            d S # 1 swxY w Y   d S )N)r   r   333333?slope)rR  r   )rQ  r   g333333@)r   rQ  )rY  rR  rQ  r   rR  z.Cannot set an 'xy2' value while 'slope' is setrE   z-Cannot set a 'slope' value while 'xy2' is setr   )r$   r>   axlineset_xy1	set_slopeset_xy2get_xy1	get_slopeget_xy2rG   warnsrS  MatplotlibDeprecationWarningrH   rd   )r/   r0   line1r#  s       r   test_axline_settersrf    s   lnnGCIIhcI**EIIh))E 
MM(	OOC	MM(	MM( ==??h&&&&??####==??h&&&&==??h&&&&	c6	7	7  b"              	c6	7	7  b"               
zM
O 
O 
O  b"               
zL
N 
N 
N                   sH   EEE*FFF3GGG<HH#&H#c                     t          j        dd          } |                                                     d          }|                                                     d          }|d         |d         z
  }|dk    sJ |dk     sJ dS )	z@Test that small slopes are not coerced to zero in the transform.)r   r   g+=rZ  )r   r   r   r   g-=N)r$   r\  get_transformtransform_point)rM   p1p2dys       r   test_axline_small_sloperm    s    :fE***D						-	-f	5	5B						-	-f	5	5B	AAB6666::::::r   )@__doc__r   platformr*   typesr   r   numpyr   numpy.testingr   rG   r   rS  r   matplotlib.lineslinesr   matplotlib.markersr   matplotlib.pathr   matplotlib.pyplotpyplotr$   matplotlib.transforms
transformsr   matplotlib.testing.decoratorsr	   r
   r   markflakyr6   rC   rN   rZ   r`   rf   rr   rv   machiner   r   r   r   r   r   r   r   r   r   parametrizer  r  r%  r4  r7  rH  rJ  rW  rf  rm  rp   r   r   <module>r     s          ! ! ! ! ! !           , , , , , ,                ! ! ! ! ! ! * * * * * *                   + + + + + + O O O O O O O OG G G !(0 (0 (0VB B B
 
 
 =/t???4 4 @?4  ! ! !  ' ' ' +,$.h.00G;;ddD D D	) 	)D D	) ))), , *),% % %
3 
3 
3 DX8++7 7 7B B7 7B +,$???  @?>- - - >")444M M 54M% % % J J J
 Hf#566))))$ )$ *) 76)$X  H H H( %&DHHH  IH B B B
, , ,4 N N N (((  )(0  >    r   