
    P/Phw[                     p   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 d]dZd^dZ edg          d	             Z ed
g          d             Z edg          d             Z edg          d             Z edgd          d             Z edgd          d             Zd Zd Z edg          d             Z edg          d             Z edg ej                    dk    rdnd           d             Z ed g          d!             Z ed"g          d#             Z  ed$g          d%             Z! ed&gd'          d(             Z" ed)g          d*             Z# ed+g          d,             Z$ ed-g          d.             Z% ed/g          d0             Z&d1 Z'd2 Z(d3 Z)d4 Z*d5 Z+d6 Z, ed7gd8d9:          d;             Z-d< Z.d= Z/ ed>gd9?          d@             Z0 edAgd9?          dB             Z1dC Z2 edDgd8d9dEdFiG          dH             Z3 edIgd8d9dE ej4        dJd gdKdLgg          iG          dM             Z5dN Z6dO Z7dP Z8dQ Z9dR Z:dS Z;dT Z<dU Z=ej>        ?                    dVdWdXi d8fdYdid8fg          dZ             Z@d[ ZAd\ ZBdS )_    N)image_comparison)gridspecticker   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      g/var/www/html/test/jupyter/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_pcolorr5      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.pngc                  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_layout1r@   '   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	   r7   r8   r:   r   N)r;   subplotsflatr   r?   axsr   s      r   test_constrained_layout2rF   /   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	   r7   r8   r:   r   r
   g{Gz?{Gz?)r   padN)r;   rB   	enumeraterC   r5   colorbar)r?   rE   nnr   r4   rI   s         r   test_constrained_layout3rM   7   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	   r7   r8   r:   r   {Gz?r   r   rI   shrinkNr;   rB   rC   r5   rK   r?   rE   r   r4   s       r   test_constrained_layout4rT   E   sc     |Aq777HCh . .R"---LL$sL33333r   zconstrained_layout5.pnggMb`?)tolc                      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	   r7   r8   r:   r   FrO   r   bottom)r   use_gridspecrI   rQ   locationNrR   rS   s       r   test_constrained_layout5rZ   O   sv     |Aq777HCh . .R"---LL#c"  $ $ $ $ $r   zconstrained_layout6.pngc            
      @   dt           j        d<   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 gridspecsFpcolormesh.snapr7   r8   r   r	   r<   r   r   r   zx-label
MultiLinerO   gGz?rW   r"   r   )r   rI   rQ   rY   ticksN)r;   rcParamsr<   add_gridspecsubgridspecr=   r   r   r5   rK   r   MaxNLocator)r?   gsgslgsraxslr   axsrr4   s           r   test_constrained_layout6rh   ^   sM    ',CL"#
*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)r?   GSGSAGSBaxaaxbis          r   test_identical_subgridspecrw   y   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matchr7   r8   r   r	   r   N)
pytestwarnsUserWarningr;   r<   r   GridSpecGridSpecFromSubplotSpecr=   rm   )r?   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"   r7   figsizer9   r
   r"   r]   r   r   r   r      	   r    r	   NrO   r   rP   )
r;   r<   r   r~   r=   r5   r   r   r   rK   )r?   rc   rE   jilistrv   r   r4   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	   r7   Fr9   sharexshareyr:   r   r   r!   rO   r   rP   zTest Suptitle   N)	r;   rB   rC   r5   r   r   
set_aspectrK   suptitlerS   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arm64gMb?c                      t          j        ddd          \  } }|j        D ]+}|                    t	          j        d          d           ,|                    dd	           d
S )z%Test for handling legend outside axisr	   r7   r8   r   zThis is a label)labelzcenter left)g?      ?)locbbox_to_anchorN)r;   rB   rC   r   r*   arangelegendrD   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 gridspecsr7   )   r
   r9   r   r   r	   r]   r   r   r   r        Q@r   rQ   aspectN	r;   r<   r   r~   r   r=   r   r5   rK   r?   gs0rd   gsl0r   rE   rc   r4   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_ratiosr7   )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.r7   )r      r   r   r	   r]   Nr
   r      r   r   T)r   r   r   )r;   r<   r   r~   r=   r   r   )r?   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.pngrH   c                     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	   r7   r8   r   r   r         4@rH   r   rQ   r   rI   r   )wpadhpadNUUUUUU?w_padh_pad)
r;   rB   rC   r5   rK   r{   raises	TypeErrorget_layout_enginesetrS   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	   r7   r8   r   r   r   r   rH   r   gUUUUUU?皙?r   r   hspacewspaceN)r;   rB   rC   r5   rK   r   r   rS   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)mplr_   r;   rB   rC   r   rD   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.r7   r8   r   r   )r   r   皙?r   N)r;   rB   r   add_axesr?   r   r   s      r   test_constrained_layout16r   1  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 gridspecsr7   r8   r
   r]   r   r   r   r   Nr	   r#   )r;   r<   r   r~   r=   r   )r?   rc   r   r   ax3ax4s         r   test_constrained_layout17r   9  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 twinxr7   r8   r:   r   N)r;   rB   twinxr   rm   allrn   extentsr   s      r   test_constrained_layout18r   J  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 twinyr7   r8   r:   r   r   N)	r;   rB   twinyr   r   rm   r   rn   r   r   s      r   test_constrained_layout19r   T  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.   rK   )gximgr?   r   meshs        r   test_constrained_layout20r   `  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 layoutr7   r8   	Suptitle0	Suptitle1N)
r;   rB   r   rm   r*   copyrn   r   testingassert_allcloser?   r   extents0extents1s       r   test_constrained_layout21r   k  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 positionedr7   r8   Suptitler   r1   N)
r;   rB   rm   r*   r   rn   r   r   r   r   r   s       r   test_constrained_layout22r   z  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	   r7   T123)r9   clearnumr   r   r   N)rl   r;   r<   r`   ra   r   )rv   r?   rc   subs       r   test_constrained_layout23r     s     1XX % %jTuEEEa##e1%%^^^$$$$	% %r   ztest_colorbar_location.pngTmpl20)remove_textstylec                  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...
    Fr\   r   r"   r7   r8   r   Nr   r   )r   rQ   r#   r	   r   rW   )r   rQ   rY   r   g?)r   rQ   rY   rI   r
   topr   leftright)r;   r_   rB   rC   r5   r   r   rK   rS   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	   r7   r8   r   Fr   )g|R?g\	b?g&:?g9?q?h㈵>)rtol)
r;   rB   set_visiblerm   r*   r   rn   r   r   r   )r?   rE   r   s      r   test_hidden_axesr    s     |Aq777HCI%      ws4y--//788HJ999  F F F F F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   rW   r	   r7   r8   in)	directionr   g{Gz?)r   rY   rQ   rI   r   gqq?g?r   )r   r   r   r
   )r;   rB   rJ   rC   tick_paramsr5   rK   r   xaxis	set_ticksyaxisr   r   r   r   rm   r*   r   r   rn   x0ro   )rY   r?   rE   cbsrL   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.png)r   c                     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   r7   r   r	   r   Tr   r   bothr  axisr	  r
   r   verticalr   orientationfoo)r;   r<   rB   r  set_major_formatterr   NullFormatterr
  imshowrK   r   r?   rE   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	   r7   r   r  r   r	   Tr  r  r  r  r
   r   
horizontalr  )r;   r<   r   rB   r  r  r   r  r
  r  rK   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	   r7   r8   r   r   r   333333?r'  r   r      r   g)\(?)r;   rB   set_positionrm   rn   r*   r   r   r.   randomrandrK   )r?   rE   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   r   savefig_kwargc                  `    t          j        d          \  } }|                    d           d S Nr7   r8   r%   r;   rB   r   r>   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  r>   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   r7   )g@r   r   )r   r   gffffff?)r9   r   gridspec_kwr   Labelg      g      ?)rE   r	   r  )r  atolN)r;   rB   set_ylimr   align_ylabelsrm   r  r   get_window_extentr*   r   r   r  )r?   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 )	Nr7   r8   BooBooyg      $@r   )r2   r   )
r;   rB   rm   get_tightbboxcanvasget_renderer	supxlabel	supylabelro   r  )r?   r   pos0poss       r   test_suplabelsrK  4  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   )r?   rc   sps      r   test_gridspec_addressingrN  K  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   rH   r   )r;   rB   rm   r{   r|   PendingDeprecationWarningset_constrained_layoutr>   s     r   test_discouraged_apirR  R  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   rH   rj   )r;   rB   rm   r>   s     r   test_kwargsrT  c  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 )Nr7   r8   )r   r   r   r   )rectr   r&  r   )
r;   rB   r   r   rm   rn   x1rp   r  ro   )r?   r   pposs      r   	test_rectrY  h  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   gX ?MbP?)r;  r   gz?)r"   r   )r9   r   r   r   gGr鷯?gQ?)r   r	   gk+ݓ?goT?)r;   rB   rC   r  r*   r+  randnrK   rm   rn   r   r   r  rW  rp   ro   )r?   rE   r   r  rJ  s        r   test_compressed1r^  z  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   r9   r9  equalr   r   r   g??r\  )absg\(\?r   F)	in_layout)	r;   rB   r  set_box_aspectr   rm   rn   r{   approx)r?   ax0r   titles       r   test_compressed_suptitlerh    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;   rB   get_constrained_layout)argstater?   r   s       r   test_set_constrained_layoutrm    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;   rB   r{   r|   rP  rQ  rj  r>   s     r   test_constrained_togglero    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)r?   s    r   test_layout_leakr}    s     *h
?
?
?COO   IeJLLL 0 0 n..0 0 0 0 0 0 0 0 0 0r   )r   F)r   )Cry  platformnumpyr*   r{   
matplotlibr   matplotlib.testing.decoratorsr   matplotlib.pyplotpyplotr;   matplotlib.transforms
transformsmtransformsr   r   r   r5   r@   rF   rM   rT   rZ   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^  rh  markparametrizerm  ro  r}   r   r   <module>r     s   				           : : : : : :       + + + + + + ' ' ' ' ' ' ' '	 	 	 	
 
 
 
 ,-.." " /." ,-..& & /.& ,-..
* 
* /.
* ,-..4 4 /.4 ,-5999$ $ :9$ ,-59994 4 :944? ? ?(% % %  ,-..4 4 /.46 ,-../ / /./ -./x/11W<<ee!E E E< <E E< -.//! ! 0/!& 0122! ! 32!& -.//  0/* -.E:::> > ;:> -.//$ $ 0/$ -.//& & 0/& -.//- - 0/- -.//  0/ H H H	H 	H 	H  3 3 33 3 3
% 
% 
% /0"'3 3 3D D3 3D*
F 
F 
F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 
0 
0r   