
    eB                     v    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mZ  G d	 d
e          ZdS )    N)	Dimension)Cycle)HoloMapLabels)rgb2hex   )TestMPLPlotmpl_rendererc                   n    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )TestLabelsPlotc                    t          ddg          }t          j        |          }|j        d         }t	          j        ddg          t	          j        ddg          ddgd}t          |          D ]\  }}|                     |j        |d	         |                    |                     |j	        |d
         |                    |                     |
                                |d         |                    d S )Nr   r	   Ar	   r   Bartistr   r	   r   r   xyLabelr   r   r   )r   r   get_plothandlesnparray	enumerateassertEqual_x_yget_textselflabelsplotr   expecteditexts          Olib/python3.11/site-packages/holoviews/tests/plotting/matplotlib/test_labels.pytest_labels_simplez!TestLabelsPlot.test_labels_simple   s    k233$V,,h'1a&))!Q0@0@!3Z) ) (( 	D 	DGAtTWhsmA&6777TWhsmA&6777T]]__hw.?.BCCCC	D 	D    c                     t          g           }t          j        |          }|j        d         }|                     |g            d S )Nr   )r   r   r   r   r   r"   r#   r$   r   s       r(   test_labels_emptyz TestLabelsPlot.test_labels_empty   sE    $V,,h'$$$$$r*   c                     t          dd           }t          ddg|          }t          j        |          }|j        d         }t          j        dd	g          t          j        d	dg          d
dgd}t          |          D ]\  }}|                     |j	        |d         |                    |                     |j
        |d         |                    |                     |                                |d         |                    d S )Nr'   c                 
    | dS )Nz.1f )r   s    r(   <lambda>z6TestLabelsPlot.test_labels_formatter.<locals>.<lambda>    s
    1

 r*   )value_formatr   r	   g1ZGU?r	   r   g1ZGU?vdimsr   r   r	   z0.3z0.7)r   r   r'   r   r   )r   r   r   r   r   r   r   r   r   r   r   r    )r"   vdimr#   r$   r   r%   r&   r'   s           r(   test_labels_formatterz$TestLabelsPlot.test_labels_formatter   s   .B.BCCC/:$GGG$V,,h'1a&))!Q0@0@"EN, , (( 	C 	CGAtTWhsmA&6777TWhsmA&6777T]]__hv.>q.ABBBB	C 	Cr*   c                     t          ddg                              d          }t          j        |          }|j        d         }t          j        ddg          t          j        ddg          dd	gd
}t          |          D ]\  }}|                     |j	        |d         |                    |                     |j
        |d         |                    |                     |                                |d         |                    d S )Nr   r   T)invert_axesr   r   r	   r   r   r   r   r   r   )r   optsr   r   r   r   r   r   r   r   r   r    r!   s          r(   test_labels_invertedz#TestLabelsPlot.test_labels_inverted+   s   k23388T8JJ$V,,h'1a&))!Q0@0@CQT:VV (( 	D 	DGAtTWhsmA&6777TWhsmA&6777T]]__hw.?.BCCCC	D 	Dr*   c                    t          ddg                              d          }t          j        |          }|j        d         }t          j        ddg          t          j        ddg          dd	gd
}ddg}t          |          D ]\  }}|                     |j	        |d         |                    |                     |j
        |d         |                    |                     |                                |d         |                    |                     |                                ||                    d S )Nr3   r4      )color_indexr   r   r	   z0.33333z0.66666r   )g?gp?g?      ?)g?g?g?r@   r   r   r   )r   r;   r   r   r   r   r   r   r   r   r   r    	get_color)r"   r#   r$   r   r%   colorsr&   r'   s           r(   test_labels_color_mappedz'TestLabelsPlot.test_labels_color_mapped5   s:   /:;;@@Q@OO$V,,h'1a&))!Q0@0@'35 5XVX (( 	: 	:GAtTWhsmA&6777TWhsmA&6777T]]__hw.?.BCCCT^^--vay9999		: 	:r*   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     d |D             g d           d S )N)r   r   #000000)r   r	   #FF0000)r   r>   #00FF00colorr5   rI   r   c                 6    g | ]}|                                 S r0   rA   .0as     r(   
<listcomp>z6TestLabelsPlot.test_label_color_op.<locals>.<listcomp>L        888A!++--888r*   rF   rG   rH   r   r;   r   r   r   r   r,   s       r(   test_label_color_opz"TestLabelsPlot.test_label_color_opG   s    QQQ%' ' ''+t't':': 	$V,,h'88888:::	< 	< 	< 	< 	<r*   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     d |D             g d	           |                    d
           |j        d         }|                     d |D             g d           d S )NrE   rI   r5   ))r   r   rG   )r   r	   rH   )r   r>   #0000FFr   r	   rJ   r   c                 6    g | ]}|                                 S r0   rL   rM   s     r(   rP   z=TestLabelsPlot.test_label_color_op_update.<locals>.<listcomp>W   rQ   r*   rR   r	   c                 6    g | ]}|                                 S r0   rL   rM   s     r(   rP   z=TestLabelsPlot.test_label_color_op_update.<locals>.<listcomp>[   rQ   r*   )rG   rH   rV   r   r   r;   r   r   r   r   updater,   s       r(   test_label_color_op_updatez)TestLabelsPlot.test_label_color_op_updateO   s   OOO#% % %OOO#% % %& & ' ' (,t't':':	 	
 $V,,h'88888:::	< 	< 	<Dh'88888:::	< 	< 	< 	< 	<r*   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     d |D             g d           d S )N)r   r   r   r   r	   r	   )r   r>   r>   rI   r5   rJ   r   c                 P    g | ]#}t          |                                          $S r0   r   rA   rM   s     r(   rP   z=TestLabelsPlot.test_label_linear_color_op.<locals>.<listcomp>c   (    AAAQ'!++--00AAAr*   )z#440154z#20908cz#fde724rS   r,   s       r(   test_label_linear_color_opz)TestLabelsPlot.test_label_linear_color_op^   s    999%' ' ''+t't':': 	$V,,h'AA&AAA:::	< 	< 	< 	< 	<r*   c                     t          g dd                              dd          }t          j        |          }|j        d         }|                     d |D             g d           d S )	N))r   r   r   )r   r	   r   )r   r>   r   rI   r5   tab10)rI   cmapr   c                 P    g | ]#}t          |                                          $S r0   rb   rM   s     r(   rP   zBTestLabelsPlot.test_label_categorical_color_op.<locals>.<listcomp>k   rc   r*   )#1f77b4z#ff7f0eri   rS   r,   s       r(   test_label_categorical_color_opz.TestLabelsPlot.test_label_categorical_color_opf   s    ???%' ' ''+t't'H'H 	$V,,h'AA&AAA:::	< 	< 	< 	< 	<r*   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     d |D             g d           d S )N)r   r      )r   r	      )r   r>      sizer5   rp   r   c                 6    g | ]}|                                 S r0   get_fontsizerM   s     r(   rP   z5TestLabelsPlot.test_label_size_op.<locals>.<listcomp>s   "    ;;;q!..**;;;r*   )rm   rn   ro   rS   r,   s       r(   test_label_size_opz!TestLabelsPlot.test_label_size_opn   s    :::$& & &&*dd&7&7 	$V,,h';;F;;;ZZZHHHHHr*   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     d |D             g d	           |                    d
           |j        d         }|                     d |D             g d           d S )N)rl   )r   r	   ro   )r   r>   rn   rp   r5   ))r   r   	   )r   r	      )r   r>      rW   rq   r   c                 6    g | ]}|                                 S r0   rs   rM   s     r(   rP   z<TestLabelsPlot.test_label_size_op_update.<locals>.<listcomp>}   ru   r*   )rm   ro   rn   rY   c                 6    g | ]}|                                 S r0   rs   rM   s     r(   rP   z<TestLabelsPlot.test_label_size_op_update.<locals>.<listcomp>   ru   r*   )rx   ry   rz   r[   r,   s       r(   test_label_size_op_updatez(TestLabelsPlot.test_label_size_op_updateu   s    888"$ $ $777"$ $ $% % & & '+dd&7&7	 	
 $V,,h';;F;;;ZZZHHHDh';;F;;;YYYGGGGGr*   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     d |D             g d           d S )N)r_   )r   r	   皙?)r   r>   ffffff?alphar5   r   r   c                 6    g | ]}|                                 S r0   	get_alpharM   s     r(   rP   z6TestLabelsPlot.test_label_alpha_op.<locals>.<listcomp>   rQ   r*   )r   r   r   rS   r,   s       r(   test_label_alpha_opz"TestLabelsPlot.test_label_alpha_op   s    ===%' ' ''+t't':': 	$V,,h'88888&	( 	( 	( 	( 	(r*   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     d |D             g d	           |                    d
           |j        d         }|                     d |D             g d           d S )N))r   r   333333?r`   )r   r>   333333?r   r5   ))r   r   r   )r   r	   皙?)r   r>   r	   rW   r   r   c                 6    g | ]}|                                 S r0   r   rM   s     r(   rP   z=TestLabelsPlot.test_label_alpha_op_update.<locals>.<listcomp>   rQ   r*   )r   r	   r   rY   c                 6    g | ]}|                                 S r0   r   rM   s     r(   rP   z=TestLabelsPlot.test_label_alpha_op_update.<locals>.<listcomp>   rQ   r*   )r   r   r	   r[   r,   s       r(   test_label_alpha_op_updatez)TestLabelsPlot.test_label_alpha_op_update   s   ;;;#% % %;;;#% % %& & ' ' (,t't':':	 	
 $V,,h'88888&	( 	( 	(Dh'88888&	( 	( 	( 	( 	(r*   c                     t          g dd                              d          }t          j        |          }|j        d         }|                     d |D             g d           d S )N))r   r   Z   r   r	      )r   r>     rotationr5   r   r   c                 6    g | ]}|                                 S r0   get_rotationrM   s     r(   rP   z9TestLabelsPlot.test_label_rotation_op.<locals>.<listcomp>   ru   r*   )r   r   r   rS   r,   s       r(   test_label_rotation_opz%TestLabelsPlot.test_label_rotation_op   s    >>>(* * **.$
$*C*C 	$V,,h';;F;;;'	) 	) 	) 	) 	)r*   c                    t          t          g dd          t          g dd          d                              d          }t          j        |          }|j        d         }|                     d |D             g d	           |                    d
           |j        d         }|                     d |D             g d           d S )N))r   r   -   r   )r   r>   r   r   r5   ))r   r      )r   r	   x   )r   r>   <   rW   r   r   c                 6    g | ]}|                                 S r0   r   rM   s     r(   rP   z@TestLabelsPlot.test_label_rotation_op_update.<locals>.<listcomp>   ru   r*   )r   r   r   rY   c                 6    g | ]}|                                 S r0   r   rM   s     r(   rP   z@TestLabelsPlot.test_label_rotation_op_update.<locals>.<listcomp>   ru   r*   )r   r   r   r[   r,   s       r(   test_label_rotation_op_updatez,TestLabelsPlot.test_label_rotation_op_update   s   ;;;&( ( (;;;&( ( () ) * * +/$
$*C*C	 	
 $V,,h';;F;;;&	( 	( 	(Dh';;F;;;&	( 	( 	( 	( 	(r*   c                     t          d t          d          D                                                       }t          |d         j        d         t
                    sJ d S )Nc           	      J    i | ] }|t          d d |z   dfdd|z   dfg          !S )r   zLabel 1r	   zLabel 2r   )rN   r&   s     r(   
<dictcomp>z?TestLabelsPlot.test_labels_text_color_cycle.<locals>.<dictcomp>   sW     " " "  AE9%AE9%   " " "r*   rz   r   rI   )r   rangeoverlay
isinstancer;   r   )r"   hms     r(   test_labels_text_color_cyclez+TestLabelsPlot.test_labels_text_color_cycle   sl    " " a" " "
 

 ')) 	 "Q%*W-u5555555r*   N)__name__
__module____qualname__r)   r-   r8   r<   rC   rT   r]   rd   rj   rv   r}   r   r   r   r   r   r0   r*   r(   r   r      s       	D 	D 	D% % %
C 
C 
CD D D: : :$< < << < << < << < <I I IH H H( ( (( ( () ) )( ( (6 6 6 6 6r*   r   )numpyr   holoviews.core.dimensionr   holoviews.core.optionsr   holoviews.core.spacesr   holoviews.elementr   holoviews.plotting.utilr   	test_plotr
   r   r   r0   r*   r(   <module>r      s        . . . . . . ( ( ( ( ( ( ) ) ) ) ) ) $ $ $ $ $ $ + + + + + + 0 0 0 0 0 0 0 0k6 k6 k6 k6 k6[ k6 k6 k6 k6 k6r*   