
    Pi/                     4   d Z ddlZddlZddlZddlmZmZmZm	Z	m
Z
 ddlmZ ddlmZmZmZmZmZmZmZmZmZmZ  ej        d          Z ej        d          ZddlmZ ej        d             Z G d	 d
          Z  G d d          Z! G d d          Z"dS )zTest cases for .hist method    N)	DataFrameIndexSeries
date_rangeto_datetime)
_check_ax_scales_check_axes_shape_check_colors_check_legend_labels_check_patches_all_filled_check_plot_works_check_text_labels_check_ticks_props
get_x_axis
get_y_axis
matplotlibzmatplotlib.pyplot)_grouped_histc                      t          t          j        dt          j                  t	          ddd          d          S )N   dtypez
2020-01-01B)periodsfreqtsindexname)r   nparangefloat64r        z/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/pandas/tests/plotting/test_hist_method.pyr   r   #   sB    
	"BJ'''r<<<   r#   c                   *   e Zd Zej                            di ddiddig          d             Zej                            di ddig          d	             Zd
 Zd Z	d Z
d Zd Zd Zd Zej        j        ej                            dg dg dg dg dg dg dg dg          d                         Zd Zd Zd Zd Zej                            dg d          d              Zej                            d!d"d#g          d$             Zej                            d%d&d'g          d(             Zd) Zd* Zd+ Zej                            d,-          d.             Zd/ Zd0 Zej                            d,-          d1             Zd2 Z d3 Z!d&S )4TestSeriesPlotskwargsgridFfigsize   
   c                 *    t          |j        fi | d S N)r   histselfr   r'   s      r$   test_hist_legacy_kwargsz'TestSeriesPlots.test_hist_legacy_kwargs-   s     "',,V,,,,,r#   bins   c                     t          j        t          d          5  t          |j        fd|j        j        i| d d d            d S # 1 swxY w Y   d S )NFcheck_stacklevelby)tmassert_produces_warningUserWarningr   r/   r   monthr0   s      r$   test_hist_legacy_kwargs_warningz/TestSeriesPlots.test_hist_legacy_kwargs_warning1   s     'eLLL 	D 	DbgCC"(.CFCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds   AAAc                 z    t           j                            dd          \  }}t          |j        |d           d S )N   T)axdefault_axesmplpyplotsubplotsr   r/   r1   r   figr@   s       r$   test_hist_legacy_axz#TestSeriesPlots.test_hist_legacy_ax7   s:    *%%a++R"'bt<<<<<<r#   c                 |    t           j                            dd          \  }}t          |j        ||d           d S )Nr?   T)r@   figurerA   rB   rF   s       r$   test_hist_legacy_ax_and_figz+TestSeriesPlots.test_hist_legacy_ax_and_fig;   s<    *%%a++R"'b4HHHHHHr#   c                 z    t           j                            dd          \  }}t          |j        |d           d S )Nr?   T)rJ   rA   rB   )r1   r   rG   _s       r$   test_hist_legacy_figz$TestSeriesPlots.test_hist_legacy_fig?   s:    $$Q**Q"'#DAAAAAAr#   c                     t           j                            dd          \  }\  }}t          |j        ||d           t          |j        ||d           d S )Nr?      T)rJ   r@   rA   rB   )r1   r   rG   ax1ax2s        r$   test_hist_legacy_multi_axz)TestSeriesPlots.test_hist_legacy_multi_axC   sY    *--a33Zc3"'##DIIII"'##DIIIIIIr#   c                     t           j                            dd          \  }}d}t          j        t
          |          5  |                    |j        |           d d d            d S # 1 swxY w Y   d S )Nr?   z`Cannot pass 'figure' when using the 'by' argument, since a new 'Figure' instance will be createdmatch)r8   rJ   )rC   rD   rE   pytestraises
ValueErrorr/   r   )r1   r   rG   rM   msgs        r$   test_hist_legacy_by_fig_errorz-TestSeriesPlots.test_hist_legacy_by_fig_errorH   s    $$Q**Q' 	 ]:S111 	- 	-GGrxG,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-s   A++A/2A/c                     t          t          j                            d                              d                    }|                    d          d         d         }t          |j                  dk    sJ d S )NrP   r,   rP   )r3   r   )r   r   randomdefault_rngstandard_normalr/   lenpatches)r1   dfr@   s      r$   test_hist_bins_legacyz%TestSeriesPlots.test_hist_bins_legacyQ   sg    ry,,Q//??HHIIWW!W__Q"2:!######r#   c                 L   |}d}t          j        t          |          5  |j                            d           d d d            n# 1 swxY w Y   t          j        t          |          5  |j                            ddg           d d d            d S # 1 swxY w Y   d S )Nz7The 'layout' keyword is not supported when 'by' is NonerU   r?   r?   layoutr?   )rW   rX   rY   heightr/   )r1   hist_dfrc   rZ   s       r$   test_hist_layoutz TestSeriesPlots.test_hist_layoutV   s!   G]:S111 	* 	*INN&N)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* ]:S111 	* 	*INN1a&N)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s#   AAA.BB Bz by, layout, axes_num, res_layout)genderrP   r?   rP   rm   )rl      rP   )ro   r?   )category   r?   rs   rr   )rq   rP   rp   rs   rP   rP   )rq   rn   rs   )ro   rP   )rq   rp   rs   rs   r?   rs   )	classroomru   ro   ru   c                     |}t          j        t          d          5  t          |j        j        t          ||          |          }d d d            n# 1 swxY w Y   t          |||           d S )NFr6   r8   rh   axes_numrh   )r9   r:   r;   r   ri   r/   getattrr	   )r1   rj   r8   rh   r|   
res_layoutrc   axess           r$   test_hist_layout_with_byz(TestSeriesPlots.test_hist_layout_with_by_   s     
 'eLLL 	X 	X$RY^BPVWWWD	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X 	X$*EEEEEEs   +AAAc                 t    |}|j                             |j        dd          }t          |ddd           d S )Nrs   rP   )      )r8   rh   r)   rs   r|   rh   r)   )ri   r/   rq   r	   r1   rj   rc   r   s       r$   test_hist_layout_with_by_shapez.TestSeriesPlots.test_hist_layout_with_by_shapev   s?    y~~VW~MM$67KKKKKKr#   c                 $   t          t          j                            d                              d                    }t          t          j                            d                              d                    }t
                              d           |                                 t
                              d           |                                 t
                                          }|j	        }t          |          dk    sJ d S )NrP   y   z   )r   r   r^   r_   r`   pltsubplotr/   gcfr   ra   )r1   xyrG   r   s        r$   test_hist_no_overlapz$TestSeriesPlots.test_hist_no_overlap|   s    29((++;;A>>??29((++;;A>>??C	C	ggiix4yyA~~~~~~r#   c                     |}|j                             |j                   t          t          j                                                  dk    sJ d S )Nr8   r?   )ri   r/   rl   ra   rC   rD   get_fignums)r1   rj   rc   s      r$   test_hist_by_no_extra_plotsz+TestSeriesPlots.test_hist_by_no_extra_plots   sL    
	")$$$3:))++,,111111r#   c                 2   t                               d          }t                               d          }|                    d          }d}t          j        t
          |          5  |                    ||           d d d            d S # 1 swxY w Y   d S )Nr?   rP   o   z&passed axis not bound to passed figurerU   )r@   rJ   )r   rJ   add_subplotrW   rX   AssertionErrorr/   )r1   r   fig1fig2rQ   rZ   s         r$   +test_plot_fails_when_ax_differs_from_figurez;TestSeriesPlots.test_plot_fails_when_ax_differs_from_figure   s    zz!}}zz!}}s##6]>555 	) 	)GGs4G(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)s   'BBBhisttype, expected)barT)
barstackedT)stepF)
stepfilledTc                     t          t          j                            d                              dd                    }|                    |          }t          ||           d S )NrP   r?   r,   histtypefilled)r   r   r^   r_   integersr/   r   )r1   r   expectedserr@   s        r$   test_histtype_argumentz&TestSeriesPlots.test_histtype_argument   s]     RY**1--66q"==>>XXxX((!"X666666r#   z&by, expected_axes_num, expected_layout)Nr?   rf   )brP   )r?   rP   c                 0   ddgz  ddgz  z   }t          t          j                            d                              d          |d          }d|j        _        t          |j        d	d	|
          }t          |||           t          |d           d S )Nr4   12rP   r,   ar   r   T)rA   legendr8   r{   )r   r   r^   r_   r`   r   r   r   r/   r	   r   )r1   r8   expected_axes_numexpected_layoutr   sr   s          r$   test_hist_with_legendz%TestSeriesPlots.test_hist_with_legend   s    
 SE	AI%29((++;;B??uSVWWW !d4BOOO$):?SSSST3'''''r#   r8   Nr   c                 T   ddgz  ddgz  z   }t          t          j                            d                              d          |d          }d|j        _        t          j        t          d	
          5  |
                    d|d           d d d            d S # 1 swxY w Y   d S )Nr4   r   r   rP   r,   r   r   r    Cannot use both legend and labelrU   Tc)r   r8   label)r   r   r^   r_   r`   r   r   rW   rX   rY   r/   )r1   r8   r   r   s       r$   test_hist_with_legend_raisesz,TestSeriesPlots.test_hist_with_legend_raises   s     SE	AI%29((++;;B??uSVWWW]:-OPPP 	2 	2FF$2SF111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   7BB!$B!c                    t           j                                        \  }}|j                            d|          }t          |j                  dk    sJ t          |j        	                                d           d S )Nr4   r3   r@   	Frequency)
rC   rD   rE   plotr/   ra   rb   r   yaxis	get_labelr1   r   rM   r@   s       r$   test_hist_kwargsz TestSeriesPlots.test_hist_kwargs   sm    
##%%2W\\qR\((2:!####28--//=====r#   c                    t           j                                        \  }}|j                            d|          }|j                            d|          }t          |j                                        d           d S )Nr4   r   
horizontal)orientationr@   r   )rC   rD   rE   r   r/   r   xaxisr   r   s       r$   test_hist_kwargs_horizontalz+TestSeriesPlots.test_hist_kwargs_horizontal   sk    
##%%2W\\qR\((W\\lr\::28--//=====r#   c                     t           j                                        \  }}|j                            d|          }|j                            dd|          }d S )Nr4   r   leftT)alignstackedr@   )rC   rD   rE   r   r/   r   s       r$   test_hist_kwargs_alignz&TestSeriesPlots.test_hist_kwargs_align   sM    
##%%2W\\qR\((W\\\<<r#   zApi changed in 3.6.0)reasonc                    t          j        d           t          j                                        \  }}|j                            d|          }t          |d           |                                }t          |dgt          |          z             |                                }t          |dgt          |          z             d S NscipyT)logyr@   logr    )rW   importorskiprC   rD   rE   r   r/   r   get_xticklabelsr   ra   get_yticklabelsr1   r   rM   r@   xlabelsylabelss         r$   test_hist_kdezTestSeriesPlots.test_hist_kde   s    G$$$
##%%2W\\t\++5))))$$&&7RD3w<<$7888$$&&7RD3w<<$788888r#   c                 `    t          j        d           t          |j        j                   d S Nr   )rW   r   r   r   kder1   r   s     r$   test_hist_kde_plot_worksz(TestSeriesPlots.test_hist_kde_plot_works   s+    G$$$"'+&&&&&r#   c                 `    t          j        d           t          |j        j                   d S r   )rW   r   r   r   densityr   s     r$   test_hist_kde_density_worksz+TestSeriesPlots.test_hist_kde_density_works   s+    G$$$"'/*****r#   c                    t          j        d           t          j                                        \  }}|j                            d|          }t          |d           |                                }t          |dgt          |          z             |                                }t          |dgt          |          z             d S r   )rW   r   rC   rD   rE   r   r   r   r   r   ra   r   r   s         r$   test_hist_kde_logyz"TestSeriesPlots.test_hist_kde_logy   s    G$$$
##%%2W[[dr[**5))))$$&&7RD3w<<$7888$$&&7RD3w<<$788888r#   c                 6   t          j        d           t          j                                        \  }}|j                            ddd|          }t          |d           t          |j	                  dk    sJ t          |j	        dgdz             d S )	Nr   Tr,   r   )r   r3   colorr@   r   r   )
facecolors)rW   r   rC   rD   rE   r   r/   r   ra   rb   r
   r   s       r$   test_hist_kde_color_binsz(TestSeriesPlots.test_hist_kde_color_bins   s    G$$$
##%%2W\\t"CB\??5))))2:"$$$$bjcURZ888888r#   c                 @   t          j        d           t          j                                        \  }}|j                            dd|          }t          |d           |                                }t          |          dk    sJ t          |dg           d S )Nr   Tr)r   r   r@   r   r   r?   )rW   r   rC   rD   rE   r   r   r   	get_linesra   r
   )r1   r   rM   r@   liness        r$   test_hist_kde_colorz#TestSeriesPlots.test_hist_kde_color   s    G$$$
##%%2W[[d#"[555))))5zzQecU#####r#   )"__name__
__module____qualname__rW   markparametrizer2   r=   rH   rK   rN   rS   r[   rd   rk   slowr   r   r   r   r   r   r   r   r   r   r   xfailr   r   r   r   r   r   r"   r#   r$   r&   r&   ,   s?       [XVUOi=Q'RSS- - TS- [XVQK'899D D :9D
= = =I I IB B BJ J J
- - -$ $ $
* * * [[*)))***+++,,,,,,,,,,,,	
 F F  FL L L	 	 	2 2 2
) ) ) [	
 	
 	
 7 7 7 [03DFV2W 	( 	( 	( [TD#;//2 2 0/2> > >> > >= = =
 [455	9 	9 65	9' ' '+ + + [4559 9 6599 9 9$ $ $ $ $r#   r&   c                      e Zd Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Z	ej        j        ej        
                    dddddd	id
dig          d                         Zej        j        d             Zej        j        d             Zej        j        d             Zej        j        d             Zd Zej        
                    ddddddddddddddddddddddddddddf	          d             Zd Zd Zd  Zej        
                    d!dg d"fg d#g d#fg          d$             Zej        
                    d%g d&          d'             Zej        
                    d(dd)g          ej        
                    d*dd+g          d,                         Zej        
                    d(dd)g          ej        
                    d*dd+g          d-                         Zd. Zd/ Zd0 Zd1 Zd2 Zd3 Zd4 ZdS )5TestDataFramePlotsc                     t          j        t          d          5  t          |j                   d d d            d S # 1 swxY w Y   d S )NFr6   )r9   r:   r;   r   r/   )r1   rj   s     r$   test_hist_df_legacyz&TestDataFramePlots.test_hist_df_legacy   s    'eLLL 	, 	,gl+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   >AAc                 H   t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   t          j	        t          d          5  t          |j        d	          }d d d            n# 1 swxY w Y   t          |d
d           |d                                         rJ t          |dg         j                   d S )NrP   r]        j+2Z     ReZr,   sizer   Fr6   )r(   ro   ru   r{   rf   )r   r   r^   r_   r`   r   r   int64r9   r:   r;   r   r/   r	   get_visibler1   rc   r   s      r$   test_hist_df_legacy_layoutz-TestDataFramePlots.test_hist_df_legacy_layout  sF    ry,,Q//??HHIII!!!$$--""h	 .  
 
1 'eLLL 	: 	:$RW5999D	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:$6:::::))+++++"aS','''''   +CCCc                     t          t          j                            d                              d                    }t          |j                   d S )NrP   r,   r?   )r   r   r^   r_   r`   r   r/   r1   rc   s     r$   test_hist_df_legacy_layout2z.TestDataFramePlots.test_hist_df_legacy_layout2  sC    ry,,Q//??HHII"'"""""r#   c                    t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   t          j	        t          d	          5  t          |j        d
          }d d d            n# 1 swxY w Y   t          |dd
           d S )NrP   r,   r4   r   r   r,   r   r4   Fr6   r   rg      r{   )r   r   r^   r_   r`   r   r   r   r9   r:   r;   r   r/   r	   r   s      r$   test_hist_df_legacy_layout3z.TestDataFramePlots.test_hist_df_legacy_layout3  s    ry,,Q//??HHIII!!!$$--""h	 .  
 
1 'eLLL 	= 	=$RWV<<<D	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=$6::::::r  r'   T)sharexshareyr)   r*   r3   r4   c                    t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   t          j	        t          d	          5  t          |j        fi | d d d            d S # 1 swxY w Y   d S )
NrP   r  r   r   r,   r   r4   Fr6   )r   r   r^   r_   r`   r   r   r   r9   r:   r;   r   r/   )r1   r'   rc   s      r$   !test_hist_df_legacy_layout_kwargsz4TestDataFramePlots.test_hist_df_legacy_layout_kwargs+  s   
 ry,,Q//??HHIII!!!$$--""h	 .  
 
1 'eLLL 	1 	1bg00000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   +CCCc                      |t          d                    }d\  }}d\  }}|                    ||||          }t          |||||           d S )Nr,         r   (   
xlabelsizexrot
ylabelsizeyrot)ranger/   r   )r1   frame_or_seriesobjxfyfr  r  r   s           r$   (test_hist_df_legacy_layout_labelsize_rotz;TestDataFramePlots.test_hist_df_legacy_layout_labelsize_rot?  sc     oeBii((B
dxx2DRdxKK4BTbtTTTTTTr#   c                    t          t          d                    }|                    ddd          }d |                                D             }t	          j        |d                                         d           d S )Nr,   Trs   )
cumulativer3   r   c                 P    g | ]#}t          |t          j        j                  !|$S r"   
isinstancerC   rb   	Rectangle.0r   s     r$   
<listcomp>zETestDataFramePlots.test_hist_df_legacy_rectangles.<locals>.<listcomp>M  s,    VVVqAs{?T1U1UVVVVr#   rp         ?)r   r  r/   get_childrenr9   assert_almost_equal
get_height)r1   r   r@   rectss       r$   test_hist_df_legacy_rectanglesz1TestDataFramePlots.test_hist_df_legacy_rectanglesH  sr    U2YYXXAtX<<VVBOO--VVV
uRy3355s;;;;;r#   c                     t          t          d                    }|                    d          }t          |d           d S )Nr,   T)r   r   r   )r   r  r/   r   )r1   r   r@   s      r$   test_hist_df_legacy_scalez,TestDataFramePlots.test_hist_df_legacy_scaleP  sA    U2YYXX$X5))))))r#   c                     t          t          d                    }t          j        t                    5  |                    d           d d d            d S # 1 swxY w Y   d S )Nr,   r   )foo)r   r  r9   external_error_raisedAttributeErrorr/   )r1   r   s     r$   "test_hist_df_legacy_external_errorz5TestDataFramePlots.test_hist_df_legacy_external_errorW  s    U2YY%n55 	  	 HHH	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   AA!Ac                    t          t          j                            d                              d          t          j                            d                              ddd          t          t          j                            d                              dddt          j                            t          t          j                            d                              dddt          j                  d          d	          }|                    t                    }d
}t          j
        t          |          5  |                                 d d d            d S # 1 swxY w Y   d S )NrP   r,   r   l     p/ l    @spc/ r   T)utc)r   r   r   dzDhist method requires numerical or datetime columns, nothing to plot.rU   )r   r   r^   r_   r   r   r   astypeobjectrW   rX   rY   r/   )r1   rc   df_orZ   s       r$   *test_hist_non_numerical_or_datetime_raisesz=TestDataFramePlots.test_hist_non_numerical_or_datetime_raises^  s   Y**1--44R88Y**1--66q"bAA I))!,,55+-@"BH 6   
 !I))!,,55+-@"BH 6   	   
 
" yy  T]:S111 	 	IIKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   E((E,/E,layout_testNru   )rh   expected_sizerr   rw   )ro   ro   rv   )rs   rp   )rp   rP   rt   c                    t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   |                    |d                   }|d	         }t          |d
|           d S )NrP   r]   r   r   r,   r   rh   rg   r>  ro   r{   )
r   r   r^   r_   r`   r   r   r   r/   r	   )r1   r=  rc   r   r   s        r$   rk   z#TestDataFramePlots.test_hist_layoutw  s     ry,,Q//??HHIII!!!$$--""h	 .  
 
1 wwk(3w44/$8<<<<<<r#   c                    t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   d}t          j	        t          |          5  |                    d	
           d d d            n# 1 swxY w Y   t          j        d          }t          j	        t          |          5  |                    d
           d d d            n# 1 swxY w Y   d}t          j	        t          |          5  |                    d
           d d d            d S # 1 swxY w Y   d S )NrP   r]   r   r   r,   r   z1Layout of 1x1 must be larger than required size 3rU   rf   rg   z)Layout must be a tuple of (rows, columns))r?   1At least one dimension of layout must be positiverp   rp   )r   r   r^   r_   r`   r   r   r   rW   rX   rY   r/   reescape)r1   rc   rZ   s      r$   test_hist_layout_errorz)TestDataFramePlots.test_hist_layout_error  s   ry,,Q//??HHIII!!!$$--""h	 .  
 
1 B]:S111 	# 	#GG6G"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# iCDD]:S111 	! 	!GG4G   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!A]:S111 	% 	%GG8G$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s6   -CCC
D--D14D1E99E= E=c                    t          t          j                            d                              d                    }t          t          j                            d                              dddt          j                            |d<   t          |j	        d           t          j                                         d S )	NrP   r]   r   r   r,   r   T)rA   )r   r   r^   r_   r`   r   r   r   r   r/   rC   rD   tight_layoutr  s     r$   test_tight_layoutz$TestDataFramePlots.test_tight_layout  s    ry,,Q//??HHIII!!!$$--""h	 .  
 
1 	"'5555
!!!!!r#   c                     t          g dg dd          }t          |j        ddddd	          }t          |d
           d S )Ng      ?      ?g333333??ro   )pigrabbitrM  rM  rN  )lengthanimalTrO  rP  r4   r   )rA   columnr8   r3   r  r  )r   r   r/   r   r   s      r$   test_hist_subplot_xrotz)TestDataFramePlots.test_hist_subplot_xrot  sr    111CCC 
 
 !G
 
 
 	4a((((((r#   zcolumn, expectedwidthrO  ri   )rO  rU  ri   c                     t          g dg dg ddg d          }t          |j        d|d	          fd
t          d          D             }||k    sJ d S )N)ffffff?皙?g333333?rX  g?rJ  )ro   rK  g333333@rP   r?   rT  )rM  rN  duckchickenhorse)r   Tr?   ro   )rA   rQ  rh   c                 H    g | ]}d |f                                          S )r   )	get_title)r'  ir   s     r$   r(  zGTestDataFramePlots.test_hist_column_order_unchanged.<locals>.<listcomp>  s-    ;;;Q$q!t*&&((;;;r#   ro   )r   r   r/   r  )r1   rQ  r   rc   resultr   s        @r$    test_hist_column_order_unchangedz3TestDataFramePlots.test_hist_column_order_unchanged  s     333111--- 
 @??
 
 
 !G	
 
 
 <;;;%((;;;!!!!!!r#   r   r   c                     t          t          j                            d                              ddd          ddg          }|                    |	          }t          ||
           d S )NrP   r?   r,   r]   r   r   r   columnsr   r   r   r   r^   r_   r   r/   r   r1   r   r   rc   r@   s        r$   r   z)TestDataFramePlots.test_histtype_argument  su     I!!!$$--a'-BBSRUJ
 
 
 WWhW''!"X666666r#   r8   r   rQ  r   c                    ||dnd}d|f}|pddg}||gdz  }t          ddgz  ddgz  z   d	          }t          t          j                            d                              d
          |ddg          }t          |j        dd||          }t          |||           |
||d         }t          ||d          D ]\  }	}
t          |
|	           d S )Nr?   rP   r   r   r4   r   r   r   r   r]   r   re  T)rA   r   r8   rQ  r{   r   strict)r   r   r   r^   r_   r`   r   r/   r	   zipr   )r1   r8   rQ  r   r   expected_labelsr   rc   r   expected_labelr@   s              r$   r   z(TestDataFramePlots.test_hist_with_legend  s5    "$0BAA/0 .S#J>./!3Oa3%i!se)+#666I!!!$$44W==#J
 
 
 !G
 
 
 	$):?SSSS:&.7D"%otD"I"I"I 	5 	5NB ^4444	5 	5r#   c                 `   t          ddgz  ddgz  z   d          }t          t          j                            d                              d          |dd	g
          }t          j        t          d          5  |	                    d||d           d d d            d S # 1 swxY w Y   d S )Nr4   r   r   r   ri  rP   r]   r   r   rj  r   rU   Tr8  )r   r8   rQ  r   )
r   r   r   r^   r_   r`   rW   rX   rY   r/   )r1   r8   rQ  r   rc   s        r$   r   z/TestDataFramePlots.test_hist_with_legend_raises  s    a3%i!se)+#666I!!!$$44W==#J
 
 
 ]:-OPPP 	B 	BGG4BvSGAAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   <B##B'*B'c                 2   t          t          j                            d                              d                    }t
          j                                        \  }}|j        	                    d|          }t          |j                  dk    sJ d S )NrP   r]   r4   r   r,   r   r   r^   r_   r`   rC   rD   rE   r   r/   ra   rb   r1   rc   rM   r@   s       r$   test_hist_df_kwargsz&TestDataFramePlots.test_hist_df_kwargs(  sz    ry,,Q//??HHII
##%%2W\\qR\((2:"$$$$$$r#   c                 N   t          t          j                            d                              d          g d          }ddgdz  |d<   t
          j                                        \  }}|j        	                    d|	          }t          |j                  d
k    sJ d S )NrP   r,   rs   Ar   CDrd  r   r   r4   Er   r  rr  rs  s       r$   test_hist_df_with_nonnumericsz0TestDataFramePlots.test_hist_df_with_nonnumerics.  s    I!!!$$44W==(((
 
 
 *q.3
##%%2W\\qR\((2:"$$$$$$r#   c                 L   t          t          j                            d                              d          g d          }ddgdz  |d<   t
          j                                        \  }}|j        	                    |	          }t          |j                  d
k    sJ d S )NrP   rv  rw  rd  r   r   r4   r{  )r@   r  rr  rs  s       r$   %test_hist_df_with_nonnumerics_no_binsz8TestDataFramePlots.test_hist_df_with_nonnumerics_no_bins9  s    I!!!$$44W==(((
 
 
 *q.3
##%%2W\\R\  2:"$$$$$$r#   c                 >   t          t          j                            d                              d          t          d                    }t          j                                        \  }}|d         j	        
                    d|          }|d         j	        
                    |dd	           t          |dd
g           |                                                                sJ |j                                                                        sJ d S )NrP   rv  abcdrd  r   T)r   r@   r   r@   r   secondary_y	b (right)labels)r   r   r^   r_   r`   listrC   rD   rE   r   r/   r   	get_yaxisr   right_axrs  s       r$   test_hist_secondary_legendz-TestDataFramePlots.test_hist_secondary_legendD  s    I!!!$$44W==tF||
 
 

 
##%%2W\dr22
3R$??? 	Rk(:;;;;||~~))+++++{$$&&224444444r#   c                 J   t          t          j                            d                              d          t          d                    }t          j                                        \  }}|d         j	        
                    dd|          }|d         j	        
                    |dd	           t          |j        d
dg           |j                                                                        rJ |                                                                sJ d S )NrP   rv  r  rd  r   Tr   r  r@   r   r  	a (right)r  r  r   r   r^   r_   r`   r  rC   rD   rE   r   r/   r   left_axr  r   rs  s       r$   test_hist_secondary_secondaryz0TestDataFramePlots.test_hist_secondary_secondaryT  s   I!!!$$44W==tF||
 
 
 
##%%2W\dDD
3R$??? 	RZk0JKKKK:''))5577777||~~))+++++++r#   c                 H   t          t          j                            d                              d          t          d                    }t          j                                        \  }}|d         j	        
                    dd|          }|d         j	        
                    |d	           t          |j        d
dg           |j                                                                        sJ |                                                                sJ d S )NrP   rv  r  rd  r   Tr  r   )r@   r   r  r  r  rs  s       r$   test_hist_secondary_primaryz.TestDataFramePlots.test_hist_secondary_primaryc  s    I!!!$$44W==tF||
 
 
 
##%%2W\dDD
3R--- 	RZc0BCCCCz##%%1133333||~~))+++++++r#   c                 H   t          t          j        ddgdt          j        t          j        gg dgt          d                    }t          j        g d          }t          g dg dgt          d                    }t          j        g d	g d
g          }t
          j                                        \  }}|j        	                    ||           d |
                                D             }d |D             }t
          j                                        \  }}	|j        	                    |	|           d |	
                                D             }
d |
D             }t          d t          ||d          D                       sJ t          j        ddgddgg          }d}t
          j                                        \  }}t          j        t          |          5  |j        	                    ||           d d d            d S # 1 swxY w Y   d S )NrX  333333?皙?)rW  g?rL  abcrd  )      ?r  ?)r  rX  r  )r  r  r  )r  r  r  )r@   weightsc                 P    g | ]#}t          |t          j        j                  !|$S r"   r#  r&  s     r$   r(  zFTestDataFramePlots.test_hist_with_nans_and_weights.<locals>.<listcomp>  s,    WWWq*Q@U2V2VWWWWr#   c                 6    g | ]}|                                 S r"   r,  r'  rects     r$   r(  zFTestDataFramePlots.test_hist_with_nans_and_weights.<locals>.<listcomp>  s"    7774??$$777r#   c                 P    g | ]#}t          |t          j        j                  !|$S r"   r#  r&  s     r$   r(  zFTestDataFramePlots.test_hist_with_nans_and_weights.<locals>.<listcomp>  s<     
 
 
Z3;;P-Q-Q

 
 
r#   c                 6    g | ]}|                                 S r"   r  r  s     r$   r(  zFTestDataFramePlots.test_hist_with_nans_and_weights.<locals>.<listcomp>  s"    EEE$//++EEEr#   c              3   (   K   | ]\  }}||k    V  d S r.   r"   )r'  h0h1s      r$   	<genexpr>zETestDataFramePlots.test_hist_with_nans_and_weights.<locals>.<genexpr>  s*      TTB28TTTTTTr#   Trk  r  r  z?weights must have the same shape as data, or be a single columnrU   )r   r   nanr  arrayrC   rD   rE   r   r/   r*  allrm  rW   rX   rY   )r1   rc   r  	no_nan_dfno_nan_weightsrM   ax0r-  heightsrQ   no_nan_rectsno_nan_heightsidxerror_weightsrZ   rR   s                  r$   test_hist_with_nans_and_weightsz2TestDataFramePlots.test_hist_with_nans_and_weightss  s   fc3#rvrv!6HKK
 
 
 (,,,--@$u++VVV	#4#4#46H6H6H"IJJ$$&&3
W---WWC,,..WWW77777$$&&3sN;;;
 
''))
 
 
 FEEEETT#g~d*S*S*STTTTTTTT8c4[4,$?@@O$$&&3]:S111 	B 	BN30@AAA	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bs   -HHH) r   r   r   rW   r   r   r   r  r  r
  r   r  r  r.  r0  r5  r<  rk   rE  rH  rS  ra  r   r   r   rt  r|  r~  r  r  r  r  r"   r#   r$   r   r      s       [, , , [( ( ($ [# # # [; ; ; [[dd33i5IFTU;W 1 1  1  [U U U [< < < [* * * [       2 [f557777777788888888
	
 = = =% % %0" " ") ) )& [0001***,I,I,IJ	
 " " ", [	
 	
 	
 7 7 7 [TD#;//[Xc{335 5 43 0/5< [TD#;//[Xc{33
B 
B 43 0/
B% % %	% 	% 	%	% 	% 	%5 5 5 , , ,, , , B B B B Br#   r   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
ej        j        ej                            d	g d
g dg dg          d                         Zej        j        d             Zej        j        ej                            dg dg dg dg          d                         Zej        j        ej                            di dddg          d                         Zej        j        ej                            ddddddgdg did dgg          d!                         Zd" Zd# Zd$ Zd% Zd& Zd' Zej                            d(g d)          d*             Zd+S ),TestDataFrameGroupByPlotsc                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d<   |                    d	d
d          |d<   dgdz  |d<   t          |j	        |j
                  }t          |d
d           d S Nr,   r  rx  rd  r   r   r   r   r   rs   ry  Xrz  r   ru   r{   )r   r^   r_   r   r`   r   r   r   r   rx  ry  r	   r1   rsrc   r   s       r$   test_grouped_hist_legacyz2TestDataFrameGroupByPlots.test_grouped_hist_legacy  s    Y""2&&r))'22SEBBBKK""h	   
 
3 ++aB''3%"*3RTbd+++$6::::::r#   c                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d<   |                    d	d
d          |d<   dgdz  |d<   |                    |j	                  }t          |d
d           d S r  )r   r^   r_   r   r`   r   r   r   r/   ry  r	   r  s       r$   *test_grouped_hist_legacy_axes_shape_no_colzDTestDataFrameGroupByPlots.test_grouped_hist_legacy_axes_shape_no_col  s    Y""2&&r))'22SEBBBKK""h	   
 
3 ++aB''3%"*3ww"$w$6::::::r#   c                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d	<   |                    d
dd          |d<   dgdz  |d<   |                    dd          }t          |dd           t          |d           d S )NrP   r  rx  rd  r   r   r,   r   r   r   rs   ry  r  rz  r   )r8   rotr?   rf   r{   rR  )r   r^   r_   r   r`   r   r   r   r/   r	   r   r  s       r$   #test_grouped_hist_legacy_single_keyz=TestDataFrameGroupByPlots.test_grouped_hist_legacy_single_key  s    Y""1%%r))'22SEBBBKK""h	   
 
3 ++aB''3%"*3ww#2w&&$6::::4b))))))r#   c                 p   t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d	<   |                    d
dd          |d<   d\  }}d\  }}t          |j	        |j
        dd||||d	  	        }|                                D ]O}d |                                D             }	|	d                                         }
t          j        |
d           Pt!          |||||           d S )NrP   r  rx  rd  r   r   r,   r   r   r   rs   ry  r  r  T)r8   r!  r3   r  r  r  r  r   c                 P    g | ]#}t          |t          j        j                  !|$S r"   r#  r&  s     r$   r(  zZTestDataFrameGroupByPlots.test_grouped_hist_legacy_grouped_hist_kwargs.<locals>.<listcomp>  s<       
1ck>S0T0T  r#   rp   r)  r  )r   r^   r_   r   r`   r   r   r   r   rx  ry  ravelr*  r,  r9   r+  r   )r1   r  rc   r  r  r  r  r   r@   r-  ri   s              r$   ,test_grouped_hist_legacy_grouped_hist_kwargszFTestDataFrameGroupByPlots.test_grouped_hist_legacy_grouped_hist_kwargs  s]   Y""1%%r))'22SEBBBKK""h	   
 
3 ++aB''3B
dDt

 

 

 **,, 	0 	0B ??,,  E 2Y))++F"63////4BTbtTTTTTTr#   c                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d	<   |                    d
dd          |d<   dgdz  |d<   t          |j	        |j
        d          }t          |d           d S )NrP   r  rx  rd  r   r   r,   r   r   r   rs   ry  r  rz  T)r8   r   r   r   )r   r^   r_   r   r`   r   r   r   r   rx  ry  r   r  s       r$   %test_grouped_hist_legacy_grouped_histz?TestDataFrameGroupByPlots.test_grouped_hist_legacy_grouped_hist  s    Y""1%%r))'22SEBBBKK""h	   
 
3 ++aB''3%"*3RTbd555U++++++r#   c                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d	<   |                    d
dd          |d<   dgdz  |d<   t          j	        t                    5  t          |j        |j        d           d d d            d S # 1 swxY w Y   d S )NrP   r  rx  rd  r   r   r,   r   r   r   rs   ry  r  rz  r   )r8   r2  )r   r^   r_   r   r`   r   r   r   r9   r3  r4  r   rx  ry  )r1   r  rc   s      r$   %test_grouped_hist_legacy_external_errz?TestDataFrameGroupByPlots.test_grouped_hist_legacy_external_err  s(   Y""1%%r))'22SEBBBKK""h	   
 
3 ++aB''3%"*3%n55 	4 	4"$24U3333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4s   4CC"%C"c                    t           j                            d          }t          |                    d          dg          }t          |                    dddt           j                            |d	<   |                    d
dd          |d<   dgdz  |d<   d}t          j	        t          |          5  |                    dd           d d d            d S # 1 swxY w Y   d S )NrP   r  rx  rd  r   r   r,   r   r   r   rs   ry  r  rz  z$Specify figure size by tuple insteadrU   default)r8   r)   )r   r^   r_   r   r`   r   r   r   rW   rX   rY   r/   )r1   r  rc   rZ   s       r$   $test_grouped_hist_legacy_figsize_errz>TestDataFrameGroupByPlots.test_grouped_hist_legacy_figsize_err  s.   Y""1%%r))'22SEBBBKK""h	   
 
3 ++aB''3%"*34]:S111 	/ 	/GGsIG...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/s   8CC!$C!c                    d}t          t          j                            d                              dd|                    }t          t          j                            d                              dd|                    }t          j                            d                              ddg|          }t          |||d	          }|                    d
          }|                                }t          |          dk    sJ t          t          j                                                  dk    sJ d S )Nr,   rP      r  rc  <   r   r?   )ri   weightrl   rl   )r   r   r^   r_   normalchoicer   groupbyr/   ra   rC   rD   r   )r1   nr  ri   
gender_intdf_intgbr   s           r$   test_grouped_hist_legacy2z3TestDataFrameGroupByPlots.test_grouped_hist_legacy2  s   	--a0077Ra7HHII	--a0077BQ7GGHHY**1--44aV!4DD
f*UUVV^^H%%wwyy4yyA~~~~3:))++,,111111r#   zmsg, plot_col, by_col, layout)z1Layout of 1x1 must be larger than required size 2r  rl   rf   )z1Layout of 1x3 must be larger than required size 4ri   rq   r\  )rA  ri   rq   rB  c                     |}t          j        t          |          5  |                    |t	          ||          |           d d d            d S # 1 swxY w Y   d S )NrU   rQ  r8   rh   )rW   rX   rY   r/   r}   )r1   rj   rZ   plot_colby_colrh   rc   s          r$   test_grouped_hist_layout_errorz8TestDataFrameGroupByPlots.test_grouped_hist_layout_error'  s    2 ]:S111 	L 	LGG8F(;(;FGKKK	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   'AAAc                     |}t          j        t          d          5  t          |j        d|j        d          }d d d            n# 1 swxY w Y   t          |dd           d S )NFr6   ri   rm   r  rP   r{   )r9   r:   r;   r   r/   rl   r	   r   s       r$    test_grouped_hist_layout_warningz:TestDataFrameGroupByPlots.test_grouped_hist_layout_warningD  s    'eLLL 	 	$RYv  D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	$6::::::s   AAAzlayout, check_layout, figsize)rr   rr   N))rp   r?   rr   N)r   r   )r   r+   c                 l    |}|                     d|j        ||          }t          |d||           d S )Nri   )rQ  r8   rh   r)   rs   r   )r/   rq   r	   )r1   rj   rh   check_layoutr)   rc   r   s          r$    test_grouped_hist_layout_figsizez:TestDataFrameGroupByPlots.test_grouped_hist_layout_figsizeM  sA     wwh2;vwwWW$<QQQQQQr#   r'   ri   ru   )rQ  rh   c                     |}t          j        t          d          5  t          |j        fddi|}d d d            n# 1 swxY w Y   t          |dd           d S )NFr6   r8   rx   ro   ru   r{   )r9   r:   r;   r   r/   r	   )r1   rj   r'   rc   r   s        r$   #test_grouped_hist_layout_by_warningz=TestDataFrameGroupByPlots.test_grouped_hist_layout_by_warningW  s     'eLLL 	H 	H$RWGGGGGD	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H$6::::::s   ?AAzkwargs, axes_num, layoutrl   )ro   r4   rz   rP   rQ  ri   r  rq   ro   c                 H    |} |j         di |}t          |||           d S )Nr{   r"   )r/   r	   )r1   rj   r'   r|   rh   rc   r   s          r$   test_grouped_hist_layout_axesz7TestDataFrameGroupByPlots.test_grouped_hist_layout_axes`  s;     rw    $&AAAAAAr#   c                 
   |}t           j                            dd          \  }}|                    g d|d                   }t	          |dd           t          j        ||d                    |d         j        |u sJ d S )NrP   ro   r  r   rQ  r@   r\  r{   rC   rD   rE   r/   r	   r9   assert_numpy_array_equalrJ   r1   rj   rc   rG   r   returneds         r$   test_grouped_hist_multiple_axesz9TestDataFrameGroupByPlots.test_grouped_hist_multiple_axesm  s    J''1--	T77"B"B"BtAw7OO(Qv>>>>
#Hd1g666{!S((((((r#   c                    |}t           j                            dd          \  }}|                    d|d                   }t	          |dd           t          j        ||d                    |d         j        |u sJ d S )	NrP   ro   rx   r?   )r8   r@   r\  r{   r   r  r  s         r$   'test_grouped_hist_multiple_axes_no_colszATestDataFrameGroupByPlots.test_grouped_hist_multiple_axes_no_colsw  s    J''1--	T77kd1g766(Qv>>>>
#Hd1g666{!S((((((r#   c                     |}t           j                            dd          \  }}d}t          j        t
          |          5  |                    d|          }d d d            d S # 1 swxY w Y   d S )NrP   ro   z@The number of passed axes must be 1, the same as the output plotrU   ri   r  )rC   rD   rE   rW   rX   rY   r/   )r1   rj   rc   rG   r   rZ   s         r$   %test_grouped_hist_multiple_axes_errorz?TestDataFrameGroupByPlots.test_grouped_hist_multiple_axes_error  s    J''1--	TP]:S111 	5 	577(t744D	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   A((A,/A,c                 r   |}|                     d|j        d          \  }}t          |                              ||          sJ t          |                              ||          sJ t	          |                              ||          rJ t	          |                              ||          rJ d S )Nri   T)rQ  r8   r  r/   rl   r   joinedr   r1   rj   rc   rQ   rR   s        r$   test_axis_share_xz+TestDataFrameGroupByPlots.test_axis_share_x  s    77(ry7FFS #%%c3/////#%%c3///// c??))#s33333c??))#s3333333r#   c                 r   |}|                     d|j        d          \  }}t          |                              ||          sJ t          |                              ||          sJ t	          |                              ||          rJ t	          |                              ||          rJ d S )Nri   T)rQ  r8   r  )r/   rl   r   r  r   r  s        r$   test_axis_share_yz+TestDataFrameGroupByPlots.test_axis_share_y  s    77(ry7FFS #%%c3/////#%%c3///// c??))#s33333c??))#s3333333r#   c                 t   |}|                     d|j        dd          \  }}t          |                              ||          sJ t          |                              ||          sJ t	          |                              ||          sJ t	          |                              ||          sJ d S )Nri   T)rQ  r8   r  r  r  r  s        r$   test_axis_share_xyz,TestDataFrameGroupByPlots.test_axis_share_xy  s    77(ryd7SSS #%%c3/////#%%c3/////#%%c3/////#%%c3///////r#   r   r   c                     t          t          j                            d                              ddd          ddg          }|                    d|	          }t          ||
           d S )NrP   r?   r,   r]   rc  r   r   rd  )r8   r   r   rf  rg  s        r$   r   z0TestDataFrameGroupByPlots.test_histtype_argument  sw     I!!!$$--a'-BBSRUJ
 
 
 WWhW//!"X666666r#   N)r   r   r   r  r  r  r  r  r  r  r  rW   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r   r"   r#   r$   r  r    s       ; ; ;"; ; ; * * *$"U "U "UH, , ,"4 4 4"/ / /"	2 	2 	2 [['      	
 .L L/  0L
 [; ; ; [['			!8!8!8:S:S:ST R R	  
R
 [[Xx6,R,R'STT; ; UT ; [["//F;88891fE	
 B B  B
) ) )) ) )5 5 54 4 4
4 
4 
4	0 	0 	0 [	
 	
 	
 7 7 7 7 7r#   r  )#__doc__rC  numpyr   rW   pandasr   r   r   r   r   pandas._testing_testingr9   pandas.tests.plotting.commonr   r	   r
   r   r   r   r   r   r   r   r   rC   r    pandas.plotting._matplotlib.histr   fixturer   r&   r   r  r"   r#   r$   <module>r     s   ! ! 				                                                f,''f-.. : : : : : :   N$ N$ N$ N$ N$ N$ N$ N$bQB QB QB QB QB QB QB QBhl7 l7 l7 l7 l7 l7 l7 l7 l7 l7r#   