
    rbi^                        d dl Z 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 dlmZmZ ej                            d          gZd]dZ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 edgd
          d             Z edgd
          d             Zd Zd Z edgd
          d             Z edgd
          d             Z edgd
 ej                     dk    rd n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% ed*gd
          d+             Z& ed,gd
          d-             Z' ed.gd
          d/             Z( ed0gd
          d1             Z)d2 Z*d3 Z+d4 Z,d5 Z-d6 Z.d7 Z/ ed8gd9d
:          d;             Z0d< Z1d= Z2 ed>gd
          d?             Z3 ed@gd
          dA             Z4dB Z5 edCgd9d
dDdEiF          dG             Z6 edHgd9d
dD ej7        dId gdJdKgg          iF          dL             Z8dM Z9dN Z:dO Z;dP Z<dQ Z=dR Z>dS Z?dT Z@ej        A                    dUdVdWi d9fdXdid9fg          dY             ZBdZ ZCd[ ZDd\ ZEdS )_    N)image_comparison)gridspectickertext_placeholders   Fc                 F   |                      ddg           |                     d           |sG|                     d|           |                     d|           |                     d|           d S |                     g            |                     g            d S )	N         nbinsx-labelfontsizey-labelTitle)plotlocator_params
set_xlabel
set_ylabel	set_titleset_xticklabelsset_yticklabels)axr   nodecs      w/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/matplotlib/tests/test_constrainedlayout.pyexample_plotr      s    GGQFOOOA 
i(333
i(333
Wx00000
2
2    c           	         d\  }}t           j        t          dd|z   |          t          dd|z   |          f         \  }}d|dz  z
  |dz  z   |dz  z   t          j        |dz   |dz  z
            z  }|                     |||d dd df         d	d
dd          }|                     d|           |                     d|           |                     d|           |S )N)333333?r    r   r	          @   r
   RdBu_rg            ?T)cmapvminvmax
rasterizedr   r   r   r   )npmgridsliceexp
pcolormeshr   r   r   )r   r   dxdyyxzpcms           r   example_pcolorr6      s    FB8E"a"fb))"a"fb))* +DAq	
QVa1f	qAv	%a!q&0@)A)AAA
--1aSbSks#'  ) )CMM)hM///MM)hM///LL8L,,,Jr   zconstrained_layout1.pngmpl20)stylec                  z    t          j        d          } |                                 }t          |d           dS )z,Test constrained_layout for a single subplotconstrainedlayout   r   N)pltfigureadd_subplotr   figr   s     r   test_constrained_layout1rC   ,   s>     *M
*
*
*C			Bb!!!!!!r   zconstrained_layout2.pngc                  p    t          j        ddd          \  } }|j        D ]}t          |d           dS )z(Test constrained_layout for 2x2 subplotsr
   r:   r;   r=   r   N)r>   subplotsflatr   rB   axsr   s      r   test_constrained_layout2rI   4   sO     |Aq777HCh & &R"%%%%%& &r   zconstrained_layout3.pngc                      t          j        ddd          \  } }t          |j                  D ]9\  }}t	          |d          }|dk    rd}nd}|                     |||	           :d
S )z3Test constrained_layout for colorbars with subplotsr
   r:   r;   r=   r   r   g{Gz?{Gz?)r   padN)r>   rE   	enumeraterF   r6   colorbar)rB   rH   nnr   r5   rL   s         r   test_constrained_layout3rP   <   s     |Aq777HCCH%% * *BR"---77CCCSRS))))* *r   zconstrained_layout4.pngc                      t          j        ddd          \  } }|j        D ]}t          |d          }|                     ||dd           d	S )
z;Test constrained_layout for a single colorbar with subplotsr
   r:   r;   r=   r   {Gz?r    r   rL   shrinkNr>   rE   rF   r6   rN   rB   rH   r   r5   s       r   test_constrained_layout4rW   J   sc     |Aq777HCh . .R"---LL$sL33333r   zconstrained_layout5.pngc                      t          j        ddd          \  } }|j        D ]}t          |d          }|                     ||dddd	
           dS )zZ
    Test constrained_layout for a single colorbar with subplots,
    colorbar bottom
    r
   r:   r;   r=   r   FrR   r    bottom)r   use_gridspecrL   rT   locationNrU   rV   s       r   test_constrained_layout5r\   T   sv     |Aq777HCh . .R"---LL#c"  $ $ $ $ $r   zconstrained_layout6.pngc            
      "   t          j        d          } |                     dd|           }|d                             dd          }|d                             dd          }g }|D ].}|                     |          }||gz  }t          |d           /|                    d	           g }|D ].}|                     |          }||gz  }t          |d          }/|                     ||d
ddt          j
        d                     dS )z,Test constrained_layout for nested gridspecsr:   r;   r	   r
   r?   r   r   r   zx-label
MultiLinerR   gGz?rY   r#   r   )r   rL   rT   r[   ticksN)r>   r?   add_gridspecsubgridspecr@   r   r   r6   rN   r   MaxNLocator)rB   gsgslgsraxslr   axsrr5   s           r   test_constrained_layout6rh   c   s@    *M
*
*
*C			!Qs		+	+B
Q%

Aq
!
!C
Q%

Aq
!
!CD & &__R  R"%%%%%MM&'''D . .__R  R"---LL$)222  4 4 4 4 4r   c                      t          j        d          } |                     dd          }|d                             dd          }|d                             dd          }g }g }t	          d          D ]@}||                     ||                   gz  }||                     ||                   gz  }A|                                  |d                                         j        |d                                         j	        k    sJ d S )NTconstrained_layoutr
   r	   r   r   )
r>   r?   r`   ra   ranger@   draw_without_renderingget_positiony0y1)rB   GSGSAGSBaxaaxbis          r   test_identical_subgridspecrw   {   s   
*
-
-
-C			!Q		B
Q%

Aq
!
!C
Q%

Aq
!
!C
C
C1XX ) )A''((A''((   q6  #c!f&9&9&;&;&>>>>>>>r   c                     t          j        t          d          5  t          j        d          } t          j        dd          }t          j        dd|d                   }t          j        dd|d                   }|D ]}|                     |           | 	                                 ddd           dS # 1 swxY w Y   dS )	z2Test for proper warning if fig not set in GridSpeczhThere are no gridspecs with layoutgrids. Possibly did not call parent GridSpec with the "figure" keywordmatchr:   r;   r	   r
   r   N)
pytestwarnsUserWarningr>   r?   r   GridSpecGridSpecFromSubplotSpecr@   rm   )rB   rc   rd   re   s       r   test_constrained_layout7r      s   	 3
5 
5 
5 % % j...q!$$.q!RU;;.q!RU;; 	  	 BOOB""$$$% % % % % % % % % % % % % % % % % %s   BB::B>B>zconstrained_layout8.pngc                  0   t          j        dd          } t          j        dd|           }g }dD ]}|dk    rd	g}ndd
g}|D ]}|                     |||f                   }||gz  }t          |d           |dk    r|                    d           |d	k     r|                    d           |                    d           |                     |dddf                   }||gz  }t          |d          }| 	                    ||dd           dS )z/Test for gridspecs that are not completely full)
   r#   r:   figsizer<   r   r#   r^   r   r	   r   r	      	   r    r
   NrR   r    rS   )
r>   r?   r   r~   r@   r6   r   r   r   rN   )rB   rc   rH   jilistrv   r   r5   s           r   test_constrained_layout8r      sP    *W]
;
;
;C		1a	,	,	,B
C  66CEEFE 	 	AAqD**BB4KC2****1uub!!!1uub!!!LL	 
AqqqD	"	"BB4KC
a
(
(
(CLL$sL33333r   zconstrained_layout9.pngc                  R   t          j        ddddd          \  } }|j        D ]=}t          |d          }|                    d           |                    d           >|                    d           |                     ||d	d
           |                     dd           dS )z4Test for handling suptitle and for sharex and shareyr
   r:   Fr<   sharexshareyr=   r   r   r"   rR   r    rS   zTest Suptitle   N)	r>   rE   rF   r6   r   r   
set_aspectrN   suptitlerV   s       r   test_constrained_layout9r      s     |Aq#(8 8 8HCh  R"---
b
bMM"LL$sL333LL2L.....r   zconstrained_layout10.pngx86_64gMb?)r8   tolc                      t          j        ddd          \  } }|j        D ]+}|                    t	          j        d          d           ,|                    dd	           d
S )z%Test for handling legend outside axisr
   r:   r;   r   zThis is a label)labelzcenter left)g?      ?)locbbox_to_anchorN)r>   rE   rF   r   r+   arangelegendrG   s      r   test_constrained_layout10r      sm     |Aq777HCh 8 8
	"%67777II-
I;;;;;r   zconstrained_layout11.pngc                     t          j        dd          } t          j        dd|           }t          j        dd|d                   }t          j        dd|d                   }|                     |d                   }t          |d	           g }|D ].}|                     |          }||gz  }t          |d	          }/|                     ||d
d           |                     |d                   }t          |d	           dS )z"Test for multiple nested gridspecsr:   )   r   r<   r   r	   r
   r^   r   r   r   r         Q@r   rT   aspectN	r>   r?   r   r~   r   r@   r   r6   rN   rB   gs0rd   gsl0r   rH   rc   r5   s           r   test_constrained_layout11r      s    *M7
;
;
;C

Aq
-
-
-C

*1aQ
8
8C+Aq#a&99D	Q	 	 Ba    
C - -__R  tR!,,,LLSL555	Q	 	 Ba      r   zconstrained_layout11rat.pngc                  &   t          j        dd          } t          j        dd| ddg          }t          j        dd|d                   }t          j        dd|d         ddg	          }|                     |d                   }t          |d
           g }|D ].}|                     |          }||gz  }t          |d
          }/|                     ||dd           |                     |d                   }t          |d
           dS )z4Test for multiple nested gridspecs with width_ratiosr:   )r   r   r   r	   r
      )r?   width_ratiosr   )height_ratiosr   r   r    r   r   Nr   r   s           r   test_constrained_layout11ratr      s"    *M7
;
;
;C

AqAq6
B
B
BC

*1aQ
8
8C+Aq#a&AOOOD	Q	 	 Ba    
C - -__R  tR!,,,LLSL555	Q	 	 Ba      r   zconstrained_layout12.pngc                  j   t          j        dd          } t          j        dd|           }|                     |ddd	f                   }|                     |ddd	f                   }t          |d
           t          |d
           |                     |dddf                   }t          |d           |                     |dddf                   }t          |d           |                     |dddf                   }t          |d           |                    d           dS )z/Test that very unbalanced labeling still works.r:   )r      r   r   r
   r^   Nr   r	      r   r   T)r   r   r   )r>   r?   r   r~   r@   r   r   )rB   r   ax1ax2r   s        r   test_constrained_layout12r      s7    *M6
:
:
:C

Aq
-
-
-C
//#bqb!e*
%
%C
//#abb!e*
%
%Cr""""r""""	QqS!V	%	%B4    	QqS!V	%	%B4    	QRRU	$	$B4    MM)r   zconstrained_layout13.pngc                     t          j        ddd          \  } }|j        D ]-}t          |d          }|                     ||ddd	           .t          j        t                    5  |                                 	                    d
d           ddd           n# 1 swxY w Y   |                                 	                    dd           dS )Test that padding works.r
   r:   r;   r   r   r          4@rK   r   rT   r   rL   r	   )wpadhpadNUUUUUU?w_padh_pad)
r>   rE   rF   r6   rN   r{   raises	TypeErrorget_layout_enginesetrV   s       r   test_constrained_layout13r     s    |Aq777HCh C CR"---SRCTBBBB	y	!	! 4 4###3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4gW=====s   )*BB#&B#zconstrained_layout14.pngc                      t          j        ddd          \  } }|j        D ]-}t          |d          }|                     ||ddd	           .|                                                     d
d
dd           dS )r   r
   r:   r;   r   r   r    r   rK   r   gUUUUUU?皙?r   r   hspacewspaceN)r>   rE   rF   r6   rN   r   r   rV   s       r   test_constrained_layout14r     s     |Aq777HCh C CR"---SRCTBBBBs   $ $ $ $ $r   zconstrained_layout15.pngc                      dt           j        d<   t          j        dd          \  } }|j        D ]}t          |d           dS )zTest that rcparams work.Tzfigure.constrained_layout.user
   r   r   N)mplrcParamsr>   rE   rF   r   rG   s      r   test_constrained_layout15r   *  sW     59CL01|Aq!!HCh & &R"%%%%%& &r   zconstrained_layout16.pngc                      t          j        d          \  } }t          |d           |                     g d          }dS )zTest ax.set_position.r:   r;   r   r   )r   r   皙?r   N)r>   rE   r   add_axesrB   r   r   s      r   test_constrained_layout16r   3  sI     l-000GCb!!!!
,,+++
,
,CCCr   zconstrained_layout17.pngc                     t          j        d          } t          j        dd|           }|                     |d                   }|                     |dddf                   }|                     |dddd	f                   }|                     |ddd
f                   }t          |           t          |           t          |           t          |           dS )zTest uneven gridspecsr:   r;   r   r^   r   r   r   r	   Nr
   r$   )r>   r?   r   r~   r@   r   )rB   rc   r   r   ax3ax4s         r   test_constrained_layout17r   ;  s     *M
*
*
*C		1a	,	,	,B
//"T(
#
#C
//"QU)
$
$C
//"QRR1W+
&
&C
//"QRRV*
%
%Cr   c                  L   t          j        d          \  } }|                                }t          |           t          |d           |                                  t          |                                j        |                                j        k              sJ dS )z
Test twinxr:   r;   r=   r   N)r>   rE   twinxr   rm   allrn   extentsr   s      r   test_constrained_layout18r   L  s    l-000GC
((**Cr""""   r  (C,<,<,>,>,FFGGGGGGGr   c                     t          j        d          \  } }|                                }t          |           t          |d           |                    d           |                    d           |                                  t          |                                j        |                                j        k              sJ dS )z
Test twinyr:   r;   r=   r   r   N)	r>   rE   twinyr   r   rm   r   rn   r   r   s      r   test_constrained_layout19r   V  s    l-000GC
((**Cr""""MM"LL   r  (C,<,<,>,>,FFGGGGGGGr   c                  4   t          j        ddd          } t          j        | | dddf                   }t          j                    }|                    g d          }|                    | | |ddddf                   }|                    |           dS )z)Smoke test cl does not mess up added Axesr#   r   N)r   r   r	   r	   r$   )r+   linspacehypotr>   r?   r   r/   rN   )gximgrB   r   meshs        r   test_constrained_layout20r   b  s    	RA		B
(2r!!!T'{
#
#C
*,,C	lll	#	#B==RSbS#2#X//DLLr   c                     t          j        d          \  } }|                     d           |                                  t	          j        |                                j                  }|                     d           |                                  t	          j        |                                j                  }t          j        	                    ||           dS )z>#11035: repeated calls to suptitle should not alter the layoutr:   r;   	Suptitle0	Suptitle1N)
r>   rE   r   rm   r+   copyrn   r   testingassert_allcloserB   r   extents0extents1s       r   test_constrained_layout21r   m  s    l-000GCLL   wr((011HLL   wr((011HJx22222r   c                     t          j        d          \  } }|                                  t          j        |                                j                  }|                     dd           |                                  t          j        |                                j                  }t          j        	                    ||           dS )zC#11035: suptitle should not be include in CL if manually positionedr:   r;   Suptitler   r2   N)
r>   rE   rm   r+   r   rn   r   r   r   r   r   s       r   test_constrained_layout22r   |  s    l-000GC   wr((011HLLsL###   wr((011HJx22222r   c                      t          d          D ]c} t          j        ddd          }|                    dd          }|d                             dd          }|                    d|             dd	S )
zu
    Comment in #11035: suptitle used to cause an exception when
    reusing a figure w/ CL with ``clear=True``.
    r
   r:   T123)r<   clearnumr	   r   r   N)rl   r>   r?   r`   ra   r   )rv   rB   rc   subs       r   test_constrained_layout23r     s     1XX % %jTuEEEa##e1%%^^^$$$$	% %r   ztest_colorbar_location.pngT)remove_textr8   c                  z   dt           j        d<   t          j        ddd          \  } }|j        D ];}t	          |          }|                    d           |                    d           <|                     ||ddd	f         d
           |                     ||dddf         dd           |                     ||dddf         ddd           |                     ||dddf         dd           |                     ||d         dd           |                     ||d	ddf         dd           dS )zY
    Test that colorbar handling is as expected for various complicated
    cases...
    Fzpcolormesh.snapr   r#   r:   r;   r   Nr	   r   )r   rT   r$   r
   r   rY   )r   rT   r[   r   g?)r   rT   r[   rL   r   topr   leftright)r>   r   rE   rF   r6   r   r   rN   rV   s       r   test_colorbar_locationr    sR    ',CL"#|Aq777HCh  R  
b
bLLQQQT3L///LLR!VS8LDDDLLQUC(LMMMLLRVS5LAAALLT3L@@@LLQqS!VS7LCCCCCr   c                  B   t          j        ddd          \  } }|d                             d           |                                  t	          j        |d                                         j                  }t          j        	                    |g dd	           d S )
Nr
   r:   r;   r   Fr   )g/ע?g<Q?gd:tzލ?g`?h㈵>)rtol)
r>   rE   set_visiblerm   r+   r   rn   r   r   r   )rB   rH   r   s      r   test_hidden_axesr    s     |Aq777HCI%      ws4y--//788HJ:::  G G G G Gr   c            	         dD ]} t          j        ddd          \  }}g }t          |j                  D ]\  }}|                    d           t          |          }|                    ||| dd	          }||gz  }|j                            d           |d
k    rh|j        j        	                    g            |j        j
        	                    g            |                    g            |                    g            |                                                    dddd           |                                 | dv rt           j                            |d         j                                        j        |d         j                                        j                   t           j                            |d
         j                                        j        |d         j                                        j                   t           j                            |d         j                                        j        |d
         j                                        j                   t           j                            |d         j                                        j        |d         j                                        j                   d S )N)r   r   r   rY   r
   r:   r;   in)	directionr    g{Gz?)r   r[   rT   rL   r	   gqq?g?r   )r   r   r   r   )r>   rE   rM   rF   tick_paramsr6   rN   r   xaxis	set_ticksyaxisr   r   r   r   rm   r+   r   r   rn   x0ro   )r[   rB   rH   cbsrO   r   pccbs           r   test_colorbar_alignr    s   6 D D<1];;;S)) 	' 	'FBNNTN***##BbR(3"&  ( (BB4KCE---Qww%%b)))%%b)))""2&&&""2&&&##&+.s 	$ 	< 	< 	< 	""$$$(((J&&s1vy'='='?'?'B'*1vy'='='?'?'BD D DJ&&s1vy'='='?'?'B'*1vy'='='?'?'BD D D D J&&s1vy'='='?'?'B'*1vy'='='?'?'BD D DJ&&s1vy'='='?'?'B'*1vy'='='?'?'BD D D D7D Dr   ztest_colorbars_no_overlapV.pngc                     t          j        dd          } |                     dddd          }|D ]w}|j                            t          j                               |                    dd	
           |                    ddgddgg          }| 	                    ||d           x| 
                    d           d S )N)r
   r   r:   r   r
   r	   Tr   r   bothr  axisr	  r   r   verticalr   orientationfoo)r>   r?   rE   r  set_major_formatterr   NullFormatterr
  imshowrN   r   rB   rH   r   ims       r   test_colorbars_no_overlapVr!    s    
*VM
:
:
:C
,,q!D,
6
6C 8 8
$$V%9%;%;<<<
Fd333YYAA'((RBJ7777LLr   ztest_colorbars_no_overlapH.pngc                     t          j        dd          } |                     d           |                     dddd          }|D ]w}|j                            t          j                               |                    d	d
           |	                    ddgddgg          }| 
                    ||d           xd S )N)r   r
   r:   r   r  r	   r
   Tr  r  r  r  r   r   
horizontalr  )r>   r?   r   rE   r  r  r   r  r
  r  rN   r  s       r   test_colorbars_no_overlapHr$    s    
*VM
:
:
:CLL
,,q!D,
6
6C : :
$$V%9%;%;<<<
Fd333YYAA'((RBL9999	: :r   c                     t          j        ddd          \  } }|d                             g d           |                                  |d                                         }t
          j                            |ddgddgg           t          j        ddd          \  } }|d                             g d           |d                             t
          j	        
                    d	d	                    }|                     ||d         
           |                                  |d                                         }t
          j                            |ddgddgg           d S )Nr	   r
   r:   r;   r   r   r   333333?r'  r   r      r   g)\(?)r>   rE   set_positionrm   rn   r+   r   r   r/   randomrandrN   )rB   rH   ppr  s       r   test_manually_set_positionr.    sS   |Aq777HCF,,,---   	Q				BJrS#Jc
#;<<<|Aq777HCF,,,---	Q		29>>"b11	2	2BLLAL   	Q				BJrS#Js#<=====r   ztest_bboxtight.pngbbox_inchestight)r   r8   savefig_kwargc                  `    t          j        d          \  } }|                    d           d S Nr:   r;   r&   r>   rE   r   rA   s     r   test_bboxtightr5    s2     l-000GCMM"r   ztest_bbox.pngr   g      @r
   c                  `    t          j        d          \  } }|                    d           d S r3  r4  rA   s     r   	test_bboxr7    s2    
 l-000GCMM"r   c                  
   t          j        ddddddi          \  } \  }}}|                    dd           |                    d	           |                    d
d           |                    d	           |                    dd           |                    d	           |                     |||f           |                                  |j        j                                        |j        j                                        |j        j                                        g}t          j
                            |d         j        |d         j        g|d         j        dd           |d         j        dk    sJ dS )z
    Tests for a bug in which constrained layout and align_ylabels on
    three unevenly sized subplots, one of whose y tick labels include
    negative numbers, drives the non-negative subplots' y labels off
    the edge of the plot
    r   r	   r:   )g@r   r   )r	   r	   gffffff?)r<   r   gridspec_kwr   Labelg      g      ?)rH   r
   r  )r  atolN)r>   rE   set_ylimr   align_ylabelsrm   r  r   get_window_extentr+   r   r   r  )rB   r   r   r   after_aligns        r   test_align_labelsr@    s    <1]085D GL 5MN N NC#sC
 LLANN7LLsNN7LLANN73S/***   9?44669?44669?44668K JA 1;q>3DE*1~0qu  F F F q>!!!!!!r   c                     t          j        d          \  } }|                                  |                    | j                                                  }|                     d           |                     d           |                                  |                    | j                                                  }|j        |j        dz   k    sJ |j	        |j	        dz   k    sJ t          j        d          \  } }|                                  |                    | j                                                  }|                     dd           |                     dd           |                                  |                    | j                                                  }|j        |j        dz   k    sJ |j	        |j	        dz   k    sJ d S )	Nr:   r;   BooBooyg      $@r   )r3   r   )
r>   rE   rm   get_tightbboxcanvasget_renderer	supxlabel	supylabelro   r  )rB   r   pos0poss       r   test_suplabelsrK  6  s   l-000GC   CJ335566DMM%MM&   


3:2244
5
5C6DGdN""""6DGdN""""l-000GC   CJ335566DMM%3MMM%3M   


3:2244
5
5C6DGdN""""6DGdN""""""r   c                      t          j                    } |                     dd          }|                     |dd dd f                   }|                                  d S )Nr   r   r	   )r>   r?   r`   r@   rm   )rB   rc   sps      r   test_gridspec_addressingrN  M  s[    
*,,C			!Q		B	ABBF	$	$B     r   c                  .   t          j        d          \  } }|                                  t          j        t
          d          5  t          j                    \  } }|                     d           |                                  d d d            n# 1 swxY w Y   t          j        t
          d          5  t          j                    \  } }|                     ddd           |                                  d d d            d S # 1 swxY w Y   d S )NTrj   zwill be deprecatedry   rK   r   )r>   rE   rm   r{   r|   PendingDeprecationWarningset_constrained_layoutrA   s     r   test_discouraged_apirR  T  s   ld333GC   	/0
2 
2 
2 % %,..R""4(((""$$$	% % % % % % % % % % % % % % % 
/0
2 
2 
2 % %,..R""TD#A#ABBB""$$$	% % % % % % % % % % % % % % % % % %s&   A BBB:AD

DDc                  b    t          j        ddi          \  } }|                                  d S )Nr   rK   rj   )r>   rE   rm   rA   s     r   test_kwargsrT  e  s4    lwo>>>GC     r   c                  J   t          j        d          \  } }|                                                     g d           |                                  |                                }|j        dk     sJ |j        dk     sJ t          j        d          \  } }|                                                     g d           |                                  |                                }|j        dk     sJ |j        dk     sJ |j        dk    sJ |j	        dk    sJ d S )Nr:   r;   )r   r   r   r   )rectr   r&  r   )
r>   rE   r   r   rm   rn   x1rp   r  ro   )rB   r   pposs      r   	test_rectrY  j  s"   l-000GC%5%5%5666   ??D7S====7S====l-000GC%9%9%9:::   ??D7S====7S====7S====7S======r   c                     t          j        ddddd          \  } }|j        D ]5}|                    t          j                            dd                    }6|                     ||           |                                  |d         	                                }t          j
                            |j        d	d
           |d         	                                }t          j
                            |j        dd           t          j        dddddd          \  } }|j        D ]5}|                    t          j                            dd                    }6|                     ||           |                                  |d         	                                }t          j
                            |j        dd           t          j
                            |j        dd
           |d         	                                }t          j
                            |j        dd           t          j
                            |j        dd
           d S )Nr   r
   
compressedTr   r(  r)  r   gz?rR   r;  r   gz?MbP?)r#   r   )r<   r   r   r   gZ|
?g+ݓ?)r	   r
   g\C?gMSt$?)r>   rE   rF   r  r+   r+  randnrN   rm   rn   r   r   r  rW  rp   ro   )rB   rH   r   r  rJ  s        r   test_compressed1r_  |  s   |Aq#'6 6 6HCh 0 0YYryr2..//LLL   
d)
 
 
"
"CJsvvD999
d)
 
 
"
"CJsvvD999 |Aq#'fF F FHCh 0 0YYryr2..//LLL   
d)
 
 
"
"CJsvwT:::JsvvD999
d)
 
 
"
"CJsvvD999JsvvD99999r   c                     t          j        dddddd          \  } \  }}|                    d           |                    d	           |                    d           |                    d
           |                     d          }|                                  |                                d
         t          j        dd          k    sJ |                     dd          }|                                  |                                d
         dk    sJ |                     dd          }|                                  |                                d
         dk    sJ d S )Nr
   )r   r   r[  )g      ?g      ?r   )r   r   )nrowsr   r<   r9  equalr   r	   r   g-?r]  )absg\(\?r   F)	in_layout)	r>   rE   r  set_box_aspectr   rm   rn   r{   approx)rB   ax0r   titles       r   test_compressed_suptitleri    so   l&4BBD D DOC#s HHWsHHWqLL!!E   "fmF&E&E&EEEEELLDL))E   "d****LLEL22E   "d******r   z
arg, state)TT)FFrV  c                 f    t          j        |           \  }}|                                |u sJ d S )Nrj   )r>   rE   get_constrained_layout)argstaterB   r   s       r   test_set_constrained_layoutrn    s=     lc222GC%%''5000000r   c                     t          j                    \  } }t          j        t                    5  |                     d           |                                 sJ |                     d           |                                 rJ |                     d           |                                 sJ 	 d d d            d S # 1 swxY w Y   d S )NTF)r>   rE   r{   r|   rP  rQ  rk  rA   s     r   test_constrained_togglerp    s   lnnGC	/	0	0 , ,""4((())+++++""5)))--/////""4((())++++++, , , , , , , , , , , , , , , , , ,s   BC  CCc                  *   t          j        dd          } |                                  |                                  t          j        d           ~ t          j                     t          d t          j                    D                       rJ d S )NT)r   r   )rk   r   r   c              3   T   K   | ]#}t          |t          j        j                  V  $d S )N)
isinstancer   _layoutgrid
LayoutGrid).0objs     r   	<genexpr>z#test_layout_leak.<locals>.<genexpr>  sE       0 0 c3?#=>> 0 0 0 0 0 0r   )	r>   r?   r@   rm   closegccollectanyget_objects)rB   s    r   test_layout_leakr~    s     *h
?
?
?COO   IeJLLL 0 0 n..0 0 0 0 0 0 0 0 0 0r   c                     t          j        dd          } |                     dd          }g }|                                D ]}|                    dd          }t          d          D ]=}||                    ||df                   gz  }|d                                          >|                    |d	d	df                                                    |                                  |dd	         D ][}t          j
        |                                j        d         |d                                         j        d         d
          sJ \d	S )z
    Test that the submerged margin logic does not get called multiple times
    on same axes if it is already in a subfigure
    )r   r#   r:   r   r   r	   r
   r   r$   Ngư>r\  )r>   r?   
subfiguresflattenr`   rl   r@   r   rm   r+   allclosern   bounds)rB   figuresrH   frc   rv   r   s          r   test_submerged_subfigr    si   
 *VM
:
:
:CnnQ""G
C__ ' '^^Aq!!q 	 	AAMM"QT(++,,CGLLNNNN	bAh$$&&&&   !""g H H{2??,,3B7q6..007;$H H H 	H 	H 	H 	HH Hr   )r   F)r   )Frz  platformnumpyr+   r{   
matplotlibr   matplotlib.testing.decoratorsr   matplotlib.pyplotpyplotr>   matplotlib.transforms
transformsmtransformsr   r   markusefixtures
pytestmarkr   r6   rC   rI   rP   rW   r\   rh   rw   r   r   r   machiner   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r!  r$  r.  r5  Bboxr7  r@  rK  rN  rR  rT  rY  r_  ri  parametrizern  rp  r~  r   r   r   <module>r     s$   				           : : : : : :       + + + + + + ' ' ' ' ' ' ' ' K/00

	 	 	 	
 
 
 
 ,-W===" " >=" ,-W===& & >=& ,-W===
* 
* >=
* ,-W===4 4 >=4 ,-W===$ $ >=$ ,-W===4 4 >=4.? ? ?(% % %  ,-W===4 4 >=46 ,-W===/ / >=/ -.g+8+--99aauF F F< <F F< -.g>>>! ! ?>!& 01AAA! ! BA!& -.g>>>  ?>* -.g>>>> > ?>> -.g>>>$ $ ?>$ -.g>>>& & ?>& -.g>>>- - ?>- -.g>>>  ?> H H H	H 	H 	H  3 3 33 3 3
% 
% 
% /0"'3 3 3D D3 3D*
G 
G 
GD D D@ 34GDDD  ED 34GDDD: : ED:> > >  '("'!. 8: : : : :
 ?#"'!.!1!1C8c1X2F!G!G!IJ J J 	J J
" " "D# # #.! ! !% % %"! ! !
  $: : :>+ + +0 Jd^T	(  1 1 1
, , ,
0 
0 
0H H H H Hr   