o
    j                     @   s  d dl Z d dlZd dlmZmZmZm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mZmZmZ d dlmZ d dlmZmZ d dlmZ G dd	 d	ZG d
d dZ dd Z!dd Z"edgdddddd Z#dd Z$dd Z%dd Z&dd Z'dd  Z(d!d" Z)d#d$ Z*G d%d& d&ej+Z,G d'd( d(Z-G d)d* d*Z.d+d, Z/d-d. Z0d/d0 Z1d1d2 Z2d3d4 Z3d5d6 Z4d7d8 Z5d9d: Z6d;d< Z7d=d> Z8d?d@ Z9dAdB Z:ej;<dCg dDdEdF Z=dGdH Z>edIgdJdKdL Z?dMdN Z@dOdP ZAdQdR ZBdSdT ZCdUdV ZDdWdX ZEdS )Y    N)assert_allcloseassert_almost_equalassert_array_equalassert_array_almost_equal)scale)Affine2DBboxTransformedBbox_ScaledRotation)Path)image_comparisoncheck_figures_equal)	MagicMockc                   @   s   e Zd ZddgZddgddgddggZeZdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(S ))TestAffine2D      ?               @      @      @c                 C   sb   t g dg dg dg t tg dg dg dgt t tg dg dg dgt d S )N         )         )      	   )r   nparrayintfloatself r%   a/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/matplotlib/tests/test_transforms.py	test_init   s   "&zTestAffine2D.test_initc                 C   s0   t jd t jd}ttj|  | d S )N!N,r   )r   randomseedr   r   from_valuesZ	to_valuesr$   valuesr%   r%   r&   test_values   s   zTestAffine2D.test_valuesc                 C   s:   t  }| }d|d< t| g dg dg dg d S )N*   r   r   )r/   r   r   r   r   r   r   r   r   )r   
get_matrixr   )r$   transZmtxr%   r%   r&   test_modify_inplace!   s   $z TestAffine2D.test_modify_inplacec                 C   sB   t tjddd }|  t| g dg dg dg d S )Nr   r   )r   r   r   r1   r2   )r   r   r)   randclearr   r3   )r$   ar%   r%   r&   
test_clear(   s   $zTestAffine2D.test_clearc                 C   sn  t  tjd }t  d}t| |  t|| j	ddg t|| j
ddgddgdd	gg t  tj}t  d
}t| |  t|| j	ddg t|| j
ddgddgddgg t  dtj d }t  d}t| |  t|| j	ddg t|| j
ddgddgddgg t||  |  t||  |  d S )Nr   Z   r   r   r   r        )r   rotater   pi
rotate_degr   r3   r   	transformsingle_pointmultiple_pointsr$   Zr_pi_2Zr90Zr_piZr180Zr_pi_3_2Zr270r%   r%   r&   test_rotate-   s.   zTestAffine2D.test_rotatec                 C   s  t  jg | jtjd R  }t  jg | jdR  }t| |  t|	| j
ddg t|	| jddgddgddgg t  jg | jtjR  }t  jg | jdR  }t| |  t|	| j
ddg t|	| jddgddgd	dgg t  jg | jdtj d R  }t  jg | jd
R  }t| |  t|	| j
ddg t|	| jddgddgdd	gg t||  |  t||  |  d S )Nr   r:   r   r   r;   r   r   r>   r<   r@   )r   Zrotate_aroundpivotr   rB   rotate_deg_aroundr   r3   r   rD   rE   rF   rG   r%   r%   r&   test_rotate_aroundF   s.   "zTestAffine2D.test_rotate_aroundc                 C   s~   t  dd}t  dd}t  dd}t||  |  t|| jddg t|| jddgddgddgg d S )	Nr   r   r<   r   r?   r      )r   r   r   r3   rD   rE   rF   )r$   sxsyr4   r%   r%   r&   
test_scale_      zTestAffine2D.test_scalec                 C   s   t  tjd tjd }t  dd}t| |  t  dd}t|| j	ddg t|| j
d	d
gddgdd	gg d S )Nr   rM   g     6@   Ȑ2:@b,@      ?      ?r   r         @g      @r   )r   Zskewr   rB   skew_degr   r3   r   rD   rE   rF   )r$   Z	trans_radZ	trans_degr4   r%   r%   r&   	test_skewh   s   zTestAffine2D.test_skewc                 C   s~   t  dd}t  dd}t  dd}t||  |  t|| jddg t|| jddgddgd	dgg d S )
N   r   r/      +   ,      -      )r   	translater   r3   rD   rE   rF   )r$   Ztxtyr4   r%   r%   r&   test_translater   rQ   zTestAffine2D.test_translatec                 C   s   t  djg | jdR  }t  dt  jg | jdR   }t| |  t|| jddg t|| j	ddgddgdd	gg t  d
dd	}t  dt  
dd	 }t| |  t|| jd
d	g t|| j	ddgddgddgg t  ddd}t  dt  dd }t| |  t|| jddg t|| j	d	dgddgddgg t  ddd}t  dt  dd }t| |  t|| jddg t|| j	ddgddgddgg d S )Nr:   r>   r   r   r   r   r   r;   r<   r=   rL   r   irS   rT   g            ?g      g      @rZ   r/      r\         r_   .   )r   rC   rJ   rI   r   r3   r   rD   rE   rF   r   rX   ra   r$   r4   Ztrans_addedr%   r%   r&   test_rotate_plus_other{   sD   


z#TestAffine2D.test_rotate_plus_otherc                 C   sH  t  jg | jdR  d}t  jg | jdR  t  d }t| |  t|| jddg t|| j	ddgddgddgg t  jg | jdR  
d	d}t  jg | jdR  t  
d	d }t| |  t|| jd	dg t|| j	ddgdd
gddgg t  jg | jdR  dd}t  jg | jdR  t  dd }t| |  t|| jddg t|| j	ddgddgddgg t  jg | jdR  dd}t  jg | jdR  t  dd }t| |  t|| jddg t|| j	ddgddgddgg d S )Nr:   r>   r;   r   r   r=   r<   r?   r   rL   r   rd   rS   rT   rU   rV         ?g      @r   rW   rZ   r/   r[   r\   rf   r_      ri   )r   rJ   rI   rC   r   r3   r   rD   rE   rF   r   rX   ra   rj   r%   r%   r&   test_rotate_around_plus_other   sL   
  z*TestAffine2D.test_rotate_around_plus_otherc                 C   s  t  ddd}t  ddt  d }t| |  t|| jddg t|| jddgddgdd	gg t  ddj	g | j
dR  }t  ddt  j	g | j
dR   }t| |  t|| jddg t|| jddgd
dgdd	gg t  dddd}t  ddt  dd }t| |  t|| jddg t|| jddgddgd	dgg t  dddd}t  ddt  dd }t| |  t|| jddg t|| jddgddgddgg d S )Nr   r<   r:   r   r   r   r   r   rM   r   rS   rT         r?         rZ   r/   r^   (   &       $   #   )r   r   rC   r   r3   rD   rE   r   rF   rJ   rI   rX   ra   rj   r%   r%   r&   test_scale_plus_other   sD    z"TestAffine2D.test_scale_plus_otherc                 C   s  t  ddd}t  ddt  d }t| |  t|| jddg t|| jddgdd	gd
dgg t  ddj	g | j
dR  }t  ddt  j	g | j
dR   }t| |  t|| jddg t|| jddgdd	gddgg t  dddd}t  ddt  dd }t| |  t|| jd	dg t|| jddgddgddgg t  dddd}t  ddt  dd }t| |  t|| jddg t|| jddgddgddgg d S )NrS   rT   r:   ro   rU   r<   r   rp   rW   r;   r   re   r   g      r   g      r?   g      +@g      rM   rZ   r/   g     8@g     E@r[   r]   g     ;@g     F@r`   r\   )r   rX   rC   r   r3   r   rD   rE   rF   rJ   rI   r   ra   rj   r%   r%   r&   test_skew_plus_other   sT   
z!TestAffine2D.test_skew_plus_otherc                 C   s  t  ddd}t  ddt  d }t| |  t|| jddg t|| jddgddgd	d
gg t  ddj	g | j
dR  }t  ddt  j	g | j
dR   }t| |  t|| jddg t|| jd	dgddgdd
gg t  dddd}t  ddt  dd }t| |  t|| jddg t|| jddgddgddgg t  dddd}t  ddt  dd }t| |  t|| jddg t|| jddgddgdd gg d S )!NrZ   r/   r:   ir[   iir^   ir`   iir   r<   H   iE   iN   iQ   irS   rT   g     F@1   r_   g     H@g     @H@g     I@0   g     `H@)r   ra   rC   r   r3   r   rD   rE   rF   rJ   rI   r   rX   rj   r%   r%   r&   test_translate_plus_other   sD    z&TestAffine2D.test_translate_plus_otherc                 C   sX  t  }tt |d W d    n1 sw   Y  tt |dggg W d    n1 s6w   Y  tt |g  W d    n1 sPw   Y  tt |dg W d    n1 skw   Y  tt |dgg W d    n1 sw   Y  tt |g dg W d    d S 1 sw   Y  d S )Nr   r   )mtransformsr   pytestraises
ValueErrorrD   RuntimeError)r$   tr%   r%   r&   test_invalid_transform   s&   "z#TestAffine2D.test_invalid_transformc                 C   s   t  }t  }|| }|  t|}|js|jrJ |dd |jr)|js+J | | k s7J |  t|}|dd |jrKJ t| |  d S Nr   r   r   r   )r   r   r3   copy_invalidra   allr   r$   r8   bss1b1r%   r%   r&   	test_copy4  s   


zTestAffine2D.test_copyc                 C   s   t  }t  }|| }|  t|}|js|jrJ |dd |jr)|jr+J t| t    |  t|}|dd |jrJJ t| |  d S r   )r   r   r3   r   deepcopyr   ra   r   r   r%   r%   r&   test_deepcopyF  s   


zTestAffine2D.test_deepcopyN)__name__
__module____qualname__rE   rF   rI   r'   r.   r5   r9   rH   rK   rP   rY   rc   rk   rn   rv   rw   r~   r   r   r   r%   r%   r%   r&   r      s*    	
	 " # r   c                   @   s   e Zd Zdd ZdS )TestAffineDeltaTransformc                 C   s   t g dg dg dg}t g dg dg dg}tjdddddd	}t|}t| | d	| d
dd f< t| | |  t| | d S )N)r   r   r   )g      @r   r   )r   r   r   )r   r   r   r   r   r   r   r   r   )	r   r    r   r   r+   ZAffineDeltaTransformr   r3   
invalidate)r$   beforeafterbaser   r%   r%   r&   test_invalidateZ  s   


z(TestAffineDeltaTransform.test_invalidateN)r   r   r   r   r%   r%   r%   r&   r   Y  s    r   c                  C   s^   G dd dt j} |  }t }tjtd||j d t  d|_	|j
  t  d S )Nc                       sD   e Zd ZdZd ZZdZ fddZdd ZeZ	dd	 Z
e
Z  ZS )
z<test_non_affine_caching.<locals>.AssertingNonAffineTransformz
        This transform raises an assertion error when called when it
        shouldn't be and ``self.raise_on_transform`` is True.

        r   Fc                    s.   t  j|i | d| _t dd| _d S )NF
   )super__init__raise_on_transformr   r   r   underlying_transform)r$   argskwargs	__class__r%   r&   r   |  s   zEtest_non_affine_caching.<locals>.AssertingNonAffineTransform.__init__c                 S      | j rJ d| j|S Nz3Invalidated affine part of transform unnecessarily.)r   r   transform_pathr$   pathr%   r%   r&   transform_path_non_affine     zVtest_non_affine_caching.<locals>.AssertingNonAffineTransform.transform_path_non_affinec                 S   r   r   )r   r   rD   r   r%   r%   r&   transform_non_affine  r   zQtest_non_affine_caching.<locals>.AssertingNonAffineTransform.transform_non_affine)r   r   r   __doc__
input_dimsoutput_dims	is_affiner   r   r   r   rD   __classcell__r%   r%   r   r&   AssertingNonAffineTransforms  s    r   r   rD   T)r   	Transformpltaxesplotr   arange	transDatadrawr   	transAxesr   )r   Zmy_transaxr%   r%   r&   test_non_affine_cachingr  s   
r   c                  C   sn   G dd d} t  }t jtd| dd\}|dd |dd t| j	
 t d
  d S )Nc                   @   s   e Zd Zdd Zdd ZdS )z-test_external_transform_api.<locals>.ScaledByc                 S   s
   || _ d S N)_scale_factor)r$   Zscale_factorr%   r%   r&   r     s   
z6test_external_transform_api.<locals>.ScaledBy.__init__c                 S   s   t  | j|j S r   )r   r   r   r   r   )r$   r   r%   r%   r&   _as_mpl_transform  s   z?test_external_transform_api.<locals>.ScaledBy._as_mpl_transformN)r   r   r   r   r   r%   r%   r%   r&   ScaledBy  s    r   r   r   r   d   )r   r   r   r   r   Zset_xlimZset_ylimr   Zget_transformZ_ar3   r   r   r   )r   r   liner%   r%   r&   test_external_transform_api  s   r   Zpre_transform_dataTZmpl20g?)Zremove_textstyleZtolc               
   C   s  t  } t d}| jtddd|| j	 d | j
tdddtd	dd
tddd|| j	 d | jtddtdd|| j	 d tddd}tddd}dt| t|d d tjf  }t|t|d d tjf  }| j|||||| j	 t||d |d d d |d d d }}|d d dd d df |d d dd d df }}| j||d |||| j	 d | j|d |d |d |d || j	 d d S )Nr   r}   r   r   r   r   r   r   g      @r   rh   r   r   r   )rD   Z	linewidthr   )r   r   r   r   r   contourfr   r   Zreshaper   
pcolormeshlinspaceZscattersincosZnewaxisZ
streamplothypotZquiverZbarbs)r   Ztimes10xyuvr%   r%   r&   test_pre_transform_plotting  s,   "&"
2.r   c                  C   s   t  } ttdddtddd\}}| j||t|| t 	d| j
 d tddgd	d
gg}t|| j  d S )NrR   rh   (@      )@皙?r   rU   ףp=
?r   rV   )r   r   r   meshgridr   r   logr   r   r   r   r    r   dataLim
get_pointsr   ZxsZysexpectedr%   r%   r&   !test_contour_pre_transform_limits  s   $
r   c                  C      t  } ttdddtddd\}}| j||t|| d dd df t 	d| j
 d tdd	gd
dgg}t|| j  d S NrR   rh   r   r   r;   r   r   rU   r   r   rV   )r   r   r   r   r   Zpcolorr   r   r   r   r   r    r   r   r   r   r%   r%   r&    test_pcolor_pre_transform_limits     $$
r   c                  C   r   r   )r   r   r   r   r   r   r   r   r   r   r   r    r   r   r   r   r%   r%   r&   $test_pcolormesh_pre_transform_limits  r   r   c                  C   s   t jd t ddd} t ddd}t | |\}}t t jj|j d }t	 }|j
dd	d
}|dd |j|||dd |j  d S )Nr(   r   r>   r   r   i  r   o   polarZ
projectione   Zgouraud)Zshading)r   r)   r*   r   r   radiansr6   shaper   ZfigureZadd_subplotZset_rlimr   canvasr   )r-   Zradiizr   r   figr   r%   r%   r&   test_pcolormesh_gouraud_nans  s   r   c                  C   s  t ddgddgddgg} tjdddddd}|| }t ddgddgddgg}t|| tjdddddd}|| }t ddgddgddgg}t|| tjdddddd}|| }t ddgd	dgddgg}t|| tjdddd
dd}|| }t ddgddgddgg}t|| tjdddddd}|| }t ddgddgddgg}t|| tjdddddd}|| }t ddgddgddgg}t|| d S )Nr   r   rh   r;   r   r   r<   r   <   r   P   r   r   )r   r    r   r   r+   rD   r   )pointsr   actualr   r%   r%   r&   test_Affine2D_from_values  s8   











r   c                  C   sX   ddg} t  }t| || |  |dd  t| || |  d S )Nr   )r   r   r   rD   invertedra   r3   )pointr   r%   r%   r&    test_affine_inverted_invalidated*  s
   r   c                  C   sh   t g d} tt tdd}|| }|j|	 ddd}t
| \}}t|| jd d  d S )N))皙?)皙?r   )r   rh   )r   rh   r   clip)r   r   r   r   F)r   simplifyr;   )r   Z_create_closedr   BlendedGenericTransformr   r   LogTransformr   iter_segments
get_affinezipr   codes)r   r4   ZtpathresultZtpointsZtcodesr%   r%   r&   test_clipping_of_log5  s   

r   c                       s<   e Zd ZdZdZdZdZ fddZdd Zdd	 Z	  Z
S )
NonAffineForTestz
    A class which looks like a non affine transform, but does whatever
    the given transform does (even if it is affine). This is very useful
    for testing NonAffine behaviour with a simple Affine transform.

    Fr   c                    s   || _ t j|i | d S r   )
real_transr   r   )r$   r   r   r   r   r%   r&   r   N  s   zNonAffineForTest.__init__c                 C      | j |S r   )r   rD   r,   r%   r%   r&   r   R     z%NonAffineForTest.transform_non_affinec                 C   r  r   )r   r   r   r%   r%   r&   r   U  r  z*NonAffineForTest.transform_path_non_affine)r   r   r   r   r   r   r   r   r   r   r   r%   r%   r   r&   r   C  s    r   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestBasicTransformc                 C   s   t jddtjd | _t jdddd| _t jdddd| _	t
t  ddd	d| _t
t  ddd
d| _t
t  dddd| _| j| j| j  | j	 | _| j| j | j | j	 | _| j| j | j	 | _d S )Nta1)Zshorthand_namer   ta2r   r   ta3r   tn1tn2tn3)r   r   rA   r   rB   r  ra   r  r   r  r   r  r  r	  stack1stack2stack2_subsetr#   r%   r%   r&   setup_methodZ  s   zTestBasicTransform.setup_methodc                 C   s4   | j jdksJ | jjdksJ | jjdksJ d S )Nr   r   )r
  depthr  r  r#   r%   r%   r&   test_transform_depths  s   z'TestBasicTransform.test_transform_depthc                 C   s   | j | j| j| j   | j }|| j| j| j  | j | j| j | j | j| j | jg}dd | D }t|t|ks?J t||D ]
\}}||ksNJ qDd S )Nc                 S   s   g | ]\}}|qS r%   r%   ).0_Zrhr%   r%   r&   
<listcomp>  s    zCTestBasicTransform.test_left_to_right_iteration.<locals>.<listcomp>)r  r  r  r  r  Z_iter_break_from_left_to_rightlenr   )r$   Zstack3Ztarget_transformsrZtarget_stackstackr%   r%   r&   test_left_to_right_iterationx  s   
z/TestBasicTransform.test_left_to_right_iterationc                 C   sN  | j | j | jksJ | j| j | jksJ | j| j | j ks#J | j| j jdks.J tt | j | j  W d    n1 sDw   Y  | j| j	| j
  }| j	| j
 }|| | jksaJ || j	 || j	  ksoJ | j | j
 | j| j| j	  ksJ | j| j
 | j| j | j	 ksJ | j	| j
 | j
 | j
 | j	| j
 ksJ d S )Nr   )r
  r  r  r  r   r  r   r   r   r  r  r  )r$   Zaff1Zaff2r%   r%   r&   test_transform_shortcuts  s    ""
z+TestBasicTransform.test_transform_shortcutsc           	      C   s  | j | j }| j | j }||ksJ || jksJ ||s J || js(J || j r0J || j | j  r;J ||ksAJ | j| jsJJ | j| jsSJ | j| js\J | j| jseJ | j| jrnJ | j| jrwJ | j| j | j sJ | j| j | j sJ | j| j| j  rJ t	| j
| j}|| j\}}| j| }|| j\}}||  u rdu sJ  J ||  u rdu sJ  J d S )NFT)r  r  Zcontains_branchr
  r  r  r  r  r   r   r  Zcontains_branch_seperatelyr	  )	r$   r1r2blendr   r   Zstack_blendrN   rO   r%   r%   r&   test_contains_branch  s0   
 z'TestBasicTransform.test_contains_branchc                 C   s  t jddgddgt jdgddggt jd}| j|}| j|}t jddgd	d
gt jt jgddggt jd}t jddgddgt jt jgddggt jd}t|| t|| t| j|| t| j	 || | j
| j  }| j	  }t|| | j	  }t|| d S )Nr   r   rh   r   r;   )Zdtyper   r   g      3      (@g      &@r   g      "g      8@)r   r    nanZfloat64r
  r   rD   r   transform_affiner   r  r  r3   r   r  )r$   r   Zna_ptsZall_ptsZna_expectedZall_expectedZexpected_resultr   r%   r%   r&   test_affine_simplification  s8    


z-TestBasicTransform.test_affine_simplificationN)	r   r   r   r  r  r  r  r  r  r%   r%   r%   r&   r  Y  s    !r  c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )TestTransformPlotInterfacec                 C   sT   t  }|jg dg d|jd t|j ttj	tj	gtj	 tj	 gg d S )Nr   333333?皙??rl   r#  r   )
r   r   r   r   r   r   r   r   r    infr$   r   r%   r%   r&   test_line_extent_axes_coords  s   
z7TestTransformPlotInterface.test_line_extent_axes_coordsc                 C   sH   t  }|jg dg d|jd t|j tddgddgg d S )Nr!  r$  r   r   rl   r"  r%  )	r   r   r   r   r   r   r   r   r    r'  r%   r%   r&   test_line_extent_data_coords  s
   
z7TestTransformPlotInterface.test_line_extent_data_coordsc                 C   s\   t  }t|j|j}|jg dg d|d t|j	 t
t
jdgt
j dgg d S )Nr!  ru      r   g      g     A@)r   r   r   blended_transform_factoryr   r   r   r   r   r   r   r    r&  r$   r   r4   r%   r%   r&   !test_line_extent_compound_coords1  s   

z<TestTransformPlotInterface.test_line_extent_compound_coords1c                 C   sZ   t  }t d|j }|jg dg d|d t|j	 t
ddgddgg d S )	Nr   r!  r*  r   r         Ir       u@)r   r   r   r   r   r   r   r   r   r   r   r    r.  r%   r%   r&   )test_line_extent_predata_transform_coords   s   
zDTestTransformPlotInterface.test_line_extent_predata_transform_coordsc                 C   sj   t  }t|jt d|j }|jg dg d|d t	|j
 ttjdgtj dgg d S )Nr   r!  r*  r   r0  r1  )r   r   r   r-  r   r   r   r   r   r   r   r   r   r    r&  r.  r%   r%   r&   !test_line_extent_compound_coords2  s   
z<TestTransformPlotInterface.test_line_extent_compound_coords2c                 C   s`   t  }t dd}t jtd||j d t	ddgddggd }t
|j | d S )Nr   r   r         "@r   r   r   r   ra   r   r   r   r   r    r   r   r   r$   r   offsetexpected_data_limr%   r%   r&   test_line_extents_affine  s
   z3TestTransformPlotInterface.test_line_extents_affinec                 C   sx   t  }t dd}tt dd}t jtd|| |j	 d t
ddgddggd }t|j | d S )Nr   r   r   r4  rh   )r   r   r   r   ra   r   r   r   r   r   r    r   r   r   )r$   r   r7  	na_offsetr8  r%   r%   r&   test_line_extents_non_affine  s   z7TestTransformPlotInterface.test_line_extents_non_affinec                 C   s   t  }t dd}tt dd}tddgddgddgddgg}tj||| |j	 d}|
| tddgddggd }t|j | d S )Nr   r   r   r         $@rh   )r   r   r   r   ra   r   r   mpatches	PathPatchr   	add_patchr   r    r   r   r   )r$   r   r7  r:  pthpatchr8  r%   r%   r&   test_pathc_extents_non_affine!  s    
z8TestTransformPlotInterface.test_pathc_extents_non_affinec                 C   s   t  }t dd}tddgddgddgddgg}tj|||j d}|	| t
ddgddggd }t|j | d S )Nr   r   r   r   r<  )r   r   r   r   ra   r   r=  r>  r   r?  r   r    r   r   r   )r$   r   r7  r@  rA  r8  r%   r%   r&   test_pathc_extents_affine,  s    
z4TestTransformPlotInterface.test_pathc_extents_affinec                 C   sh   t jdd}t dd}t jtd||j d t	ddgddggddg }t
|j | d S )Nr   r   r   r   r   r   r4  r5  r6  r%   r%   r&   *test_line_extents_for_non_affine_transData5  s
   zETestTransformPlotInterface.test_line_extents_for_non_affine_transDataN)r   r   r   r(  r)  r/  r2  r3  r9  r;  rB  rC  rD  r%   r%   r%   r&   r     s    
	r   c                 C   s   t | j|j d S r   )r   Zbounds)Zbbox1Zbbox2r%   r%   r&   assert_bbox_eqB  s   rE  c                  C   s0   t jjdddddd} |  }t|j| j d S )Nr   r   )minpos)r   r   from_extentsfrozenr   rF  )ZbboxrH  r%   r%   r&   test_bbox_frozen_copies_minposF  s   rI  c                  C   s   t jj} t jj}| dddd}| dddd}| dddd}| dddd}| dddd}t|||| t|||| dddd t|||| |||d u sQJ t|||| dddd d S )Nr   r   rl   rU   re   g      @r   )r   r   rG  intersectionrE  )Zbbox_from_extinterr  r  Zr3Zr4Zr5r%   r%   r&   test_bbox_intersectionL  s   rL  c                  C   s   t ddgddgg} t| tt| dt ji tt| dti}| D ]\}}t| ||ks2J q%d}tt	| |dti}| D ]\}}tt	t| |||ksUJ qCd S )Nrl   r   re   r   z.1f)
r   r   rE  evalreprstrdictitemsgetattrformat)r   asdictkr   fmtr%   r%   r&   test_bbox_as_stringsb  s   rW  c                   C   s   t tjddjdksJ d S )Nr   r   a  CompositeGenericTransform(
    CompositeGenericTransform(
        CompositeGenericTransform(
            TransformWrapper(
                BlendedAffine2D(
                    IdentityTransform(),
                    IdentityTransform())),
            CompositeAffine2D(
                Affine2D().scale(1.0),
                Affine2D().scale(1.0))),
        PolarTransform(
            PolarAxes(0.125,0.1;0.775x0.8),
            use_rmin=True,
            apply_theta_transforms=False)),
    CompositeGenericTransform(
        CompositeGenericTransform(
            PolarAffine(
                TransformWrapper(
                    BlendedAffine2D(
                        IdentityTransform(),
                        IdentityTransform())),
                LockableBbox(
                    Bbox(x0=0.0, y0=0.0, x1=6.283185307179586, y1=1.0),
                    [[-- --]
                     [-- --]])),
            BboxTransformFrom(
                _WedgeBbox(
                    (0.5, 0.5),
                    TransformedBbox(
                        Bbox(x0=0.0, y0=0.0, x1=6.283185307179586, y1=1.0),
                        CompositeAffine2D(
                            Affine2D().scale(1.0),
                            Affine2D().scale(1.0))),
                    LockableBbox(
                        Bbox(x0=0.0, y0=0.0, x1=6.283185307179586, y1=1.0),
                        [[-- --]
                         [-- --]])))),
        BboxTransformTo(
            TransformedBbox(
                Bbox(x0=0.125, y0=0.09999999999999998, x1=0.9, y1=0.9),
                BboxTransformTo(
                    TransformedBbox(
                        Bbox(x0=0.0, y0=0.0, x1=8.0, y1=6.0),
                        Affine2D().scale(80.0))))))))rO  r   Zsubplotr   r%   r%   r%   r&   test_str_transformn  s   rX  c                  C   s$   t  } | d}|jdksJ d S )Nr   r   )r   )r   r   r  r   )r   r  r%   r%   r&   test_transform_single_point  s   
rZ  c                  C   s&   t  \} }|d |jd d S )Nr   rY  )r   subplots
set_yscaler   rD   )r   r   r%   r%   r&   test_log_transform  s   
r]  c                  C   s@   t ddgddgg} t ddgdtjgg}| |rJ d S )Nr   r   )r   r   r   r  overlaps)r8   r   r%   r%   r&   test_nan_overlap  s   r_  c                  C   s   t  } tg d}tddgddgddgg}| ||}t|| tt | ||ddddf  W d    n1 sBw   Y  tt | ||ddd d f  W d    d S 1 sfw   Y  d S )N)rh   r_   r   r   r   r   )	r   r   r   r    Ztransform_anglesr   r   r   r   )r   Zanglesr   Z
new_anglesr%   r%   r&   test_transform_angles  s   
"r`  c                  C   sF   t ddg} dt jfddg}|D ]}t tj| }t||  qd S )NgMbPgMbP?r   r0   )r   g     )r   r    r  r   Znonsingularr   )Zzero_expansioncasesr   outr%   r%   r&   test_nonsingular  s   rc  c                  C   s   g d} t | dd}t }t||}t| j|  dtd }|	tj
d  t| jd||fdd| f| |fgd	d
 dgd |_t| jd||fdd| f| |fgd	d
 d S )N)r0   r   r   rY  r   r   T)closedr   r   r   r0   r   V瞯<Zatol)r   r   r   ZTransformedPathr   get_fully_transformed_pathverticesr   sqrtrA   rB   r   )r   r   r4   Z
trans_pathr  r%   r%   r&   test_transformed_path  s    


rl  c                  C   sl   t  } tjdddd| d}t |}| j}| d t| j|d  |	d t| j| d S )Nr0   r   r_      r   r   rl   )
r   r   r=  ZWedgeZTransformedPatchPathri  rj  r   r   Z
set_radius)r4   rA  Ztpatchr   r%   r%   r&   test_transformed_patch_path  s   



rn  locked_elementZx0Zy0x1y1c                 C   sv  g d}| |  tj }tj|fi | di}t|| dks"J t|d|  dks-J |D ]}t||t||ks=J q/|| d  t|| dksPJ t|d|  dks[J |D ]}t||t||kskJ q]t|d|  d  t|d|  d u sJ t	
| | ksJ t|d|  d t|| dksJ t|d|  dksJ |D ]}t||t||ksJ qd S )Nrp  r   Zlocked_r   r   )remover   r   unitZLockableBboxrR  Z
set_pointsr   setattrr   r   )ro  Zother_elementsoriglockedelemr%   r%   r&   test_lockable_bbox  s,   

ry  c                  C   sR   t t  } tjtdd | td W d    d S 1 s"w   Y  d S )Nz`The input and output dims of the new child \(1, 1\) do not match those of current child \(2, 2\)matchr   )	r   ZTransformWrapperr   r   r   r   setr   r   )r   r%   r%   r&   test_transformwrapper  s   "r}  Zpng)
extensionsc              	   C   s   t jd t jjdd}t ddd}t| |gddgD ]0\}}| }|j||dd ||t 	|d	  d	 t 
d	t j   |j  |d
 qd S )Nr(   r   )sizer+  r   TF)r   Zdensityr   Zlinear)r   r)   r*   normalr   r   r[  histr   exprk  rB   r   r   r\  )Zfig_testZfig_refZsamplesr   r   Z	log_stater   r%   r%   r&   test_scale_swapping   s   ,
r  c                   C   s~   t jtdd tjd dd W d    n1 sw   Y  t jtdd tjd dd W d    d S 1 s8w   Y  d S )NzZ'fontsize' is not a valid value for units; supported values are 'dots', 'points', 'inches'rz  Zfontsize)Zunitsz3For units of inches or points a fig kwarg is neededZinches)r   r   r   r   Zoffset_copyr%   r%   r%   r&   test_offset_copy_errors.  s   "r  c                  C   s   t t t d} | ddsJ | ddsJ | ddr#J t t t dd} | dd	s7J | dd	r?J | d
d
rGJ d S )N   r#  rl   gٿg333333?r%  g      ?rV   rU   r   )r	   r   rt  r   rC   containsra   Zfully_contains)Zbbr%   r%   r&   test_transformedbbox_contains9  s   r  c                   C   sd   t ddsJ t ddsJ t ddsJ t ddr J t ddr(J t dds0J d S Nre  rl   r   r   r;   r   rd  )r   Zinterval_containsr%   r%   r%   r&   test_interval_containsD     r  c                   C   sd   t ddsJ t ddrJ t ddrJ t ddr J t ddr(J t dds0J d S r  )r   Zinterval_contains_openr%   r%   r%   r&   test_interval_contains_openM  r  r  c                  C   sB   d} t  }t| |}|j| ksJ |j|ksJ |jdu sJ dS )z=Test that the ScaledRotation object is initialized correctly.r   N)r   r
   Z_thetaZ_trans_shiftZ_mtx)thetatrans_shift
scaled_rotr%   r%   r&   "test_scaledrotation_initializationV  s   
r  c                  C   s   t jd } tt| dggdd}t| |}d|_| }|j| dgg t ddgddgg}|dus6J t	|ddddf |d	d
 dS )zCTest get_matrix when the matrix is invalid and needs recalculation.r   r   )return_valuer   Tr;   r   Nrg  rh  )
r   rB   r   r
   r   r3   rD   Zassert_called_once_withr    r   )r  r  r  matrixZexpected_rotationr%   r%   r&   &test_scaledrotation_get_matrix_invalid`  s   


"r  )Fr   numpyr   Znumpy.testingr   r   r   r   r   Z
matplotlibr   Zmatplotlib.pyplotZpyplotr   Zmatplotlib.patchesZpatchesr=  Zmatplotlib.transformsZ
transformsr   r   r   r	   r
   Zmatplotlib.pathr   Zmatplotlib.testing.decoratorsr   r   Zunittest.mockr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   rE  rI  rL  rW  rX  rZ  r]  r_  r`  rc  rl  rn  markZparametrizery  r}  r  r  r  r  r  r  r  r%   r%   r%   r&   <module>   sp      I&

#% ]2	
!

		
