HOME


sh-3ll 1.0
DIR:/usr/local/lib/python3.6/site-packages/xarray/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/xarray/test/__pycache__/test_plot.cpython-36.pyc
3

���h#��
@s�ddlZddlZddlZddlmZddljZ	ddl
mZddlm
Z
mZmZddlmZmZmZy ddlZejd�ddljZWnek
r�YnXdd	�Zd
d�Zdd
�Zd*dd�ZeGdd�de��ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"eGdd�de��Z#eGdd�de��Z$Gdd�d�Z%Gdd�de%e�Z&Gd d!�d!e%e�Z'Gd"d#�d#e%e�Z(Gd$d%�d%e%e�Z)Gd&d'�d'e�Z*Gd(d)�d)e�Z+dS)+�N)�	DataArray)�_infer_interval_breaks)�_determine_cmap_params�_build_discrete_cmap�_color_palette�)�TestCase�requires_matplotlib�incompatible_2_6ZAggcCs$dd�tj�jtjj�D�}t|�S)z2
    Return the set of all text in the figure
    cSsg|]}|j��qS�)�get_text)�.0�trr�5/tmp/pip-build-5_djhm0z/xray/xarray/test/test_plot.py�
<listcomp>sztext_in_fig.<locals>.<listcomp>)�plt�gcf�findobj�mpl�text�Text�set)�alltxtrrr�text_in_figsrcCstj�jtjj�S)N)rrrr�collections�QuadMeshrrrr�find_possible_colorbars#srcCs:tdd�|jtjj�D��}x|D]}||kr"dSq"WdS)zA
    Return True if a substring is found anywhere in an axes
    cSsg|]}|j��qSr)r)r
rrrrr,sz%substring_in_axes.<locals>.<listcomp>TF)rrrrr)Z	substring�axr�txtrrr�substring_in_axes(s

rcCs tj||tj|�d�}|j|�S)z^
    Make an array with desired shape using np.linspace

    shape is a tuple like (2, 3)
    )�num)�np�linspace�prodZreshape)�shape�start�stop�arrr�
easy_array3sr(c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�PlotTestCasecCstjd�dS)N�all)r�close)�selfrrr�tearDown@szPlotTestCase.tearDowncCs4tjdd�\}}||dd�|j|dj��dS)N�)Zncolsr)r)rZsubplots�
assertTrue�has_data)r,�
plotmethod�fig�axesrrr�pass_in_axisDszPlotTestCase.pass_in_axiscCs$|�tj�jtjj�}t|�dkS)Nr)r�gcarr�image�	AxesImage�len)r,r1Zimagesrrr�
imshow_calledIszPlotTestCase.imshow_calledcCs$|�tj�jtjj�}t|�dkS)Nr)rr5rrrZPathCollectionr8)r,r1�pathsrrr�contourf_calledNszPlotTestCase.contourf_calledN)�__name__�
__module__�__qualname__r-r4r9r;rrrrr)=sr)c@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�ZdS)�TestPlotcCsttd��|_dS)Nr.��)r.r@rA)rr(�darray)r,rrr�setUpVszTestPlot.setUpcCs|jdd�ddfj�dS)Nr)rB�plot)r,rrr�test1dYszTestPlot.test1dcCsttd��}|j�dS)Nr�)rrF)rr(rD)r,r'rrr�test_2d_before_squeeze\szTestPlot.test_2d_before_squeezecCs,|j|j|jdd�dd�dfjj��dS)Nr)r/r9rBrD�imshow)r,rrr�test2d_uniform_calls_imshow`sz$TestPlot.test2d_uniform_calls_imshowcCs@|jdd�dd�df}dddg|jd<|j|j|jj��dS)Nrr.r�YZdim_1)rB�coordsr/r;rD�contourf)r,r'rrr� test2d_nonuniform_calls_contourfcsz)TestPlot.test2d_nonuniform_calls_contourfcCs|jj�dS)N)rBrD)r,rrr�test3dhszTestPlot.test3dcCs|j|jj�dS)N)r4rBrD)r,rrr�test_can_pass_in_axiskszTestPlot.test_can_pass_in_axiscCsp|jdddgtddg��|jdddddgtdddd	g��|jtjd
dd�tjd
d�ttjd
dd���dS)Ng�?g�?rrg@g#@g%@�	�
Z20000101rA)�periods��hr@g�g�)�assertArrayEqualr�pd�
date_ranger!Ztimedelta64)r,rrr�test__infer_interval_breaksns
z$TestPlot.test__infer_interval_breakscCs\d}d}tjd|d�}tt||f�d|fdt|�fgd�}|j�tj�}|j|j	��dS)Nr@rAz
2000-01-01)rR�time�y)rK)
rVrWrr(�rangerDrr5r/r0)r,ZnrowZncolrYr'rrrr�test_datetime_dimensionusz TestPlot.test_datetime_dimensioncCs�td�}t|dddgd�}td�|jd<|jdddd	d
d�}|j|jjd	d	g�x|jjD]}|j	|j
��qZW|jtd��|jdddt
j�d
�WdQRX|jtd�� |djdddt
j�d
�WdQRXdS)NrQ�rArZ�x�z)�dims�abcdr.�cool)r^rZ�col�col_wrap�cmapz[Ff]acet)r^rZrcrr)rQr]rA)r(r�listrKrDrUr3r$�flatr/r0�assertRaisesRegexp�
ValueErrorrr5)r,r'�d�grrrr�test_convenient_facetgrid�s z"TestPlot.test_convenient_facetgridc	Csjtd�}t|dddgd�}td�|jd<|jdddd	d
tdd�d
�}x |jjD]}|j|j	�d�qNWdS)NrQr]rArZr^r_)r`rar.rb�r)Zaxisbg)r^rZrcrdreZsubplot_kws)rQr]rA)
r(rrfrKrD�dictr3rg�assertEqualZget_axis_bgcolor)r,r'rjrkrrrr�test_subplot_kws�szTestPlot.test_subplot_kwsc
Cs�td
�}t|ddddgd	�}|jddddd
�}|j|jjddg�x|jjD]}|j|j��qLW|j	t
d��|jdddtj�d�WdQRXdS)NrQr]r.r@rZr^�columns�rows)r`)r^rZrc�rowz[Ff]acet)r^rZrcr)rQr]r.r@)
r(rrDrUr3r$rgr/r0rhrirr5)r,r'rjrkrrrr�test_convenient_facetgrid_4d�sz%TestPlot.test_convenient_facetgrid_4dN)r<r=r>rCrErGrIrMrNrOrXr
r\rlrprtrrrrr?Ts	r?c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�
TestPlot1DcCs*ddddg}t|dtt|��id�|_dS)Nrg�������?r.�period)rK)rr[r8rB)r,rjrrrrC�szTestPlot1D.setUpcCs"|jj�|jdtj�j��dS)Nrv)rBrDrorr5�
get_xlabel)r,rrr�test_xlabel_is_index_name�s
z$TestPlot1D.test_xlabel_is_index_namecCs"|jj�|jdtj�j��dS)N�)rBrDrorr5�
get_ylabel)r,rrr�test_no_label_name_on_y_axis�s
z'TestPlot1D.test_no_label_name_on_y_axiscCs.d|j_|jj�|j|jjtj�j��dS)NZtemperature)rB�namerDrorr5rz)r,rrr�test_ylabel_is_data_name�s
z#TestPlot1D.test_ylabel_is_data_namec	Cs0ttd��}|jt��|jj�WdQRXdS)Nr.rF)r.rF)rr(�assertRaisesrirD�line)r,Ztwodimsrrr�!test_wrong_dims_raises_valueerror�sz,TestPlot1D.test_wrong_dims_raises_valueerrorcCs|jjjd�dS)N�ro)rBrDr)r,rrr�test_format_string�szTestPlot1D.test_format_stringcCs|j|jjj�dS)N)r4rBrDr)r,rrrrO�sz TestPlot1D.test_can_pass_in_axisc	Cs@tdddgddddgi�}|jtd��|jj�WdQRXdS)	Nrr.r@�letterr'�b�cz[Pp]lot)rrh�	TypeErrorrDr)r,r'rrr�&test_nonnumeric_index_raises_typeerror�sz1TestPlot1D.test_nonnumeric_index_raises_typeerrorcCs(|jjj�}|jt|dtjj��dS)Nr)rBrDrr/�
isinstancer�linesZLine2D)r,�prrr�test_primitive_returned�sz"TestPlot1D.test_primitive_returnedcCstj|jd<|jjj�dS)Nr)r!�nanrBrDr)r,rrr�test_plot_nans�szTestPlot1D.test_plot_nanscCsTtjdd�}ttjt|��d|i�}|jj�tj	�j
�dj�}|j|dk�dS)Nz
2000-01-01z
2000-01-10rr)
rVrWrr!�aranger8rDrrr5Zget_xticklabelsZget_rotation�assertFalse)r,rYr'Zrotationrrr�!test_x_ticks_are_rotated_for_time�s

z,TestPlot1D.test_x_ticks_are_rotated_for_timecCs4d|jjd<|jjj�tj�j�}|jd|�dS)NrQrjzd = 10)rBrKrDrrr5�	get_titlero)r,�titlerrr�test_slice_in_title�szTestPlot1D.test_slice_in_titleN)r<r=r>rCrxr{r}r�r�rOr�r�r�r�r�rrrrru�sruc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestPlotHistogramcCsttd��|_dS)Nr.r@rA)r.r@rA)rr(rB)r,rrrrC�szTestPlotHistogram.setUpcCs|jjj�dS)N)rBrD�hist)r,rrr�
test_3d_array�szTestPlotHistogram.test_3d_arraycCs$|jjj�|jdtj�j��dS)Nry)rBrDr�rorr5r�)r,rrr�test_title_no_name�sz$TestPlotHistogram.test_title_no_namecCs0d|j_|jjj�|j|jjtj�j��dS)NZ
testpoints)rBr|rDr��assertInrr5r�)r,rrr�test_title_uses_name�sz&TestPlotHistogram.test_title_uses_namecCs$|jjj�|jdtj�j��dS)NZCount)rBrDr�rorr5rz)r,rrr�test_ylabel_is_count�sz&TestPlotHistogram.test_ylabel_is_countcCs.d}|jjj|d�|j|ttj�j��dS)NrF)Zbins)rBrDr�ror8rr5�patches)r,Znbinsrrr�test_can_pass_in_kwargs�sz)TestPlotHistogram.test_can_pass_in_kwargscCs|j|jjj�dS)N)r4rBrDr�)r,rrrrO�sz'TestPlotHistogram.test_can_pass_in_axiscCs,|jjj�}|jt|ddtjj��dS)Nrr���)rBrDr�r/r�rr�Z	Rectangle)r,rTrrrr��sz)TestPlotHistogram.test_primitive_returnedcCstj|jd<|jjj�dS)Nr)rrr)r!r�rBrDr�)r,rrrr�sz TestPlotHistogram.test_plot_nansN)r<r=r>rCr�r�r�r�r�rOr�r�rrrrr��sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestDetermineCmapParamscCstjdddd�|_dS)Nrr�d)r )r!r"�data)r,rrrrCszTestDetermineCmapParams.setUpcCs�t|jdd�}|j|dtj|jd��|j|dtj|jd��|j|djd�|j|d	d
�|j|d�|j|d�dS)
NT)�robust�vminr.�vmax�bre�viridis�extend�both�levels�norm)rr�ror!Z
percentiler|�assertIsNone)r,�cmap_paramsrrr�test_robustsz#TestDetermineCmapParams.test_robustcCsjt|jdd�}|j|ddd|d�|j|dd�|j|dd�|j|d	�|j|d
�dS)Ng�?)�centerr�r�re�RdBu_rr��neitherr�r�)rr�ror�)r,r�rrr�test_centersz#TestDetermineCmapParams.test_centercCs�|jd}t|ddddd�}|j|d|dd�|j|d|dd�|j|d	jd�|j|d
d�|j|d	jd�|j|djd
�t|dddd�}|j|d	jd�|j|d
d�dS)NrrFr�Blues)r�r�r�rer�r�r�rer�r�r��g�?g�?)r�r�r�r��maxr�)r�rror|�N)r,r�r�rrr�test_integer_levelss


z+TestDetermineCmapParams.test_integer_levelscCs�|jd}ddddddg}t||ddd�}|j|dd�|j|d	d�|j|d
jd�|j|djd�x8ttjtjt	gD]$}t|||�d
�}|j
|d|�q�WdS)Nrrr.r@rArF)r�r�r�r�r�rer�r�)r�r�)r�rror�rfr!�arrayrV�IndexrrU)r,r�Zorig_levelsr�Zwrap_levelsrrr�test_list_levels,s

z(TestDetermineCmapParams.test_list_levelscCs.|jd}|j}t|�}|j|dd�|j|dd�|j|djd�t|�}|j|dd�|j|dd�|j|dd	�t|dd
d�}|j|dd�|j|dd�|j|djd�t|dd
d
�}|j|dd�|j|dd�|j|djd�t|d
d�}|j|dd�|j|dd�|j|djd�t|dd�}|j|dd�|j|dd�|j|dd	�t|dd�}|j|dd�|j|dd�|j|dd	�t|dd�}|j|dd�|j|dd�|j|dd	�t|ddd
�}|j|dd�|j|dd�|j|dd	�t|dd�}|j|dd �|j|dd�|j|dd	�t|dd�}|j|dd�|j|dd�|j|djd�t|dd�}|j|dd�|j|dd�|j|djd�t|d!dd�}|j|dd"�|j|dd�|j|djd�dS)#Ng�������?r�rr�rrer�g�������?r�F)r�r�g�?)r�r�)r�)r�)r�g333333�?g�������?g�������?)r�r�g�������g��������g��������g��������g��������g�������g��������g��������g�g������ٿg��������g��������g������ɿg������ɿ)r�rror|)r,�neg�posr�rrr�test_divergentcontrol=sl
z-TestDetermineCmapParams.test_divergentcontrolN)	r<r=r>rCr�r�r�r�r�rrrrr�s	r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TestDiscreteColorMapcCsttjdddd�}tjdddd�}tjtj||��}tjj|dd�}t|ttd
||f���|_	|j
�|_|j�|_
dS)NrrQr.)r%r&�steprP�r@)ZaxisrZr^i�������)rZr^)r!r�Zdstack�meshgridZlinalgr�rrf�ziprB�min�data_minr��data_max)r,r^rZZxyZdistancerrrrC�s
zTestDiscreteColorMap.setUpcCs2tdd�}|jt|�tjk�|jt|�d�dS)N�jetrA)rr/�typer!Zndarrayror8)r,Zpalrrr�'test_recover_from_seaborn_jet_exception�s
z<TestDiscreteColorMap.test_recover_from_seaborn_jet_exceptioncCs�x�dddgddfdddgdd	fgD]�\}}}}t||||�\}}|j|jt|�d�|jt|j�t|�d�|j|jt|��|j|j|�|jt|�|j�|jt	|�|j
�|r�|j|j|�q"|j|jd
�q"WdS)Nr�rrr�FZhotrAr�Tr����)rror�r8�colorsrU�
boundariesr�r�r�r��colorbar_extend)r,rer�r�ZfilledZncmapZcnormrrr�test_build_discrete_cmap�sz-TestDiscreteColorMap.test_build_discrete_cmapcCs�x�ddddddgfddddd	gfd
ddddgfd
ddddgfgD]�\}}x�dD]�}t|jj|�|d�}|j||jj�|jt|�|jj�|jt	|�|jj
�|dkr�|j||jj�n|jd
|jj�|jt
|�dt
|jj��qNWq@WdS)Nr�rr.rA�rQr�rF�r�rr]r�rH�
pcolormeshrL�contour)r�r�)rHr�rLr�)�getattrrBrDrUr�r�ror�r�r�r�rer�r8r�)r,r�r��kind�	primitiverrr�%test_discrete_colormap_list_of_levels�s
z:TestDiscreteColorMap.test_discrete_colormap_list_of_levelscCs��x�dD]�\}}}}x�dD]�}t|jj|�|||d�}|j|t|jj�d�|dkrj|j|jj|j�n|j|jj|�|dkr�|j	|jj
|j�n|j	|jj
|�|d
kr�|j||j
j�n|jd|j
j�|j|t|j
j��qWqWdS)Nr�r��r�rAr�r�rQr]rHr�rLr�)r�r�r�r�r�r�NN�r�r�Nr��r�r�rAr��r�rQrAr])r�r�r�r�)rHr�rLr�)r�rBrD�assertGreaterEqualr8r�r�r�r��assertLessEqualr�r�rorer�r�)r,r�r�r�r�r�r�rrr�!test_discrete_colormap_int_levels�s(
z6TestDiscreteColorMap.test_discrete_colormap_int_levelscCsJddddg}|jj|ddd�}|j|jjt|��|j|jjt|��dS)	NrrFrQr]r@r�)r�r�r�r�)rBrDror�r�r�r�r�)r,r�r�rrr�3test_discrete_colormap_list_levels_and_vmin_or_vmax�szHTestDiscreteColorMap.test_discrete_colormap_list_levels_and_vmin_or_vmaxN)	r<r=r>rCr�r�r�r�r�rrrrr��s	r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zed.d/��Zd0d1�Zd2d3�Zd4d5�Zd6S)7�
Common2dMixinz�
    Common tests for 2d plotting go here.

    These tests assume that a staticmethod for `self.plotfunc` exists.
    Should have the same name as the method.
    cCs�ttddd�ddgd�}|jdd	�}tj|jj|jj�\}}t|ddgd�|d
<t|ddgd�|d<|jd
dgdd
�|j	|_
t|j
j|j
j�|_dS)NrQr]r)r%rZr^)r`�testvar)r|�x2d�y2dT)Zinplace)rQr]r�)rr(�
to_datasetr!r�r^�valuesrZZ
set_coordsr�rBr�rD�plotfuncr<r1)r,�daZdsr^rZrrrrC�szCommon2dMixin.setUpcCs4|j�|jdtj�j��|jdtj�j��dS)Nr^rZ)r1rorr5rwrz)r,rrr�test_label_names�szCommon2dMixin.test_label_namescCs4|jtd��|j|jddd�f�WdQRXdS)NzDataArray must be 2dr)rhrir�rB)r,rrr�test_1d_raises_valueerror�sz'Common2dMixin.test_1d_raises_valueerrorc	Cs2ttd��}|jtd��|j|�WdQRXdS)Nr.r@rAzDataArray must be 2d)r.r@rA)rr(rhrir�)r,r'rrr�test_3d_raises_valueerror�sz'Common2dMixin.test_3d_raises_valueerrorc	CsDttd
�dddgddggd�}|jtd	��|j|�WdQRXdS)Nr@r.r'r�r�rj�e)rKz[Pp]lot)r@r.)rr(rhr�r�)r,r'rrrr��sz4Common2dMixin.test_nonnumeric_index_raises_typeerrorcCs|j|j�dS)N)r4r1)r,rrrrO�sz#Common2dMixin.test_can_pass_in_axiscCsn|jddd�tj�j�}tj�j�}|dd|dd|dd|ddf}|jtdd�|D���dS)	NF)�	xincrease�	yincreaser�rrPcss|]}t|�dkVqdS)rN)�abs)r
r^rrr�	<genexpr>szCCommon2dMixin.test_xyincrease_false_changes_axes.<locals>.<genexpr>)r1rr5�get_xlim�get_ylimr/r*)r,�xlim�ylim�diffsrrr�"test_xyincrease_false_changes_axess
,z0Common2dMixin.test_xyincrease_false_changes_axescCsn|jddd�tj�j�}tj�j�}|dd|dd|dd|ddf}|jtdd�|D���dS)	NT)r�r�rrr�rPcss|]}t|�dkVqdS)rN)r�)r
r^rrrr�szBCommon2dMixin.test_xyincrease_true_changes_axes.<locals>.<genexpr>)r1rr5r�r�r/r*)r,r�r�r�rrr�!test_xyincrease_true_changes_axes	s
,z/Common2dMixin.test_xyincrease_true_changes_axescCsR|jdd�}|jj�}tj|dd�<|j|�j�}|j|�j�}|j||�dS)NrF)rB�copyr!r�r��get_climro)r,Zx1Zx2Zclim1Zclim2rrrr�s
zCommon2dMixin.test_plot_nanscCs"|jdd�j�j}|jd|�dS)Nr�)re)r1�get_cmapr|ro)r,�	cmap_namerrr�test_viridis_cmapszCommon2dMixin.test_viridis_cmapcCs@|j�j�j}|jd|�|jt|j��j�j}|jd|�dS)Nr�r�)r1r�r|ror�r�rB)r,r�rrr�test_default_cmapszCommon2dMixin.test_default_cmapcCsFy,ddl}|jddd�j�j}|jd|�Wntk
r@YnXdS)Nrr.�husl)r�re)�seabornr1r�r|ro�ImportError)r,r�r�rrr�test_seaborn_palette_as_cmap$sz*Common2dMixin.test_seaborn_palette_as_cmapcCs"|jdd�j�j}|jd|�dS)Nr�)re)r1r�r|ro)r,r�rrr�test_can_change_default_cmap-sz*Common2dMixin.test_can_change_default_cmapcCs&|j�}|j�\}}|j||�dS)N)r1r�ZassertAlmostEqual)r,�artistr�r�rrr�test_diverging_color_limits1sz)Common2dMixin.test_diverging_color_limitscCs8|jdd�tj�}|jd|j��|jd|j��dS)NrZr^)r1rr5rorwrz)r,rrrr�test_xy_strings6szCommon2dMixin.test_xy_stringscCsJ|jtd��|jd�WdQRX|jtd��|jdd�WdQRXdS)Nzcannot supply only onerZr^)rZ)rhrir1)r,rrr�test_positional_coord_string<sz*Common2dMixin.test_positional_coord_stringcCsV|jtd��|jdd�WdQRXd|jjd<|jtd��|jd�WdQRXdS)Nzx and y must be coordinateZnot_a_real_dimrZr�r_zcannot supply only one)rhrir1rBrK)r,rrr�test_bad_x_string_exceptionBs
z)Common2dMixin.test_bad_x_string_exceptioncCs2|jd|jj�|jd|jj�|jddd�dS)Nr^rZ)rZr^)r�rBrKr1)r,rrr�test_coord_stringsIsz Common2dMixin.test_coord_stringscCsXttd�dddgd�}d|jd	<|j|jd
d��tj�j�}|jd|kpPd
|k�dS)NrAr@r.r'r�r�)r`�foorjr)r�zc = 1, d = foozd = foo, c = 1)rAr@r.)	rr(rKr��iselrr5r�r/)r,r'r�rrr�test_default_titleOs

z Common2dMixin.test_default_titlecCs&d|j_|j�|j|jjt��dS)Nr�)rBr|r1r�r)r,rrr�test_colorbar_labelVsz!Common2dMixin.test_colorbar_labelcCs8d|j_|jdd�t�}xdD]}|j||�q WdS)Nr�F)Z
add_labelsr^rZ)r^rZr�)rBr|r1r�assertNotIn)r,r�stringrrr�test_no_labels[s

zCommon2dMixin.test_no_labelscCs\td	�}t|dddgd�}tj|dd�}|j|jdd�x|jjD]}|j|j	��qBWdS)
NrQr]r@rZr^r_)r`)rc)rQr]r@)
r(r�xplt�	FacetGrid�
map_dataarrayr�r3rgr/r0)r,r'rjrkrrrr�test_verbose_facetgridbsz$Common2dMixin.test_verbose_facetgridcCs8tj|j|j�}tj|j�}|d=|d=|j||�dS)NZ_PlotMethods_objrB)�inspectZgetcallargsr�rBr1ro)r,Zfunc_sigZ
method_sigrrr�*test_2d_function_and_method_signature_samejs
z8Common2dMixin.test_2d_function_and_method_signature_samecCsntd�}t|dddgd�}|j|ddddd	�}|j|jjddg�x~tj|j�D]n\\}}}|j|j	��|d
kr�|j
d|j��n|j
d|j��|dkr�|j
d|j��qP|j
d|j��qPW|j|ddd
�}|j|jjddg�x�tj|j�D]r\\}}}|j|j	��|d
k�r*|j
d|j��n|j
d|j��|dk�rV|j
d|j��q�|j
d|j��q�WdS)NrQr]rArZr^r_)r`r.)r^rZrcrdrryr)rcrd)rQr]rA)
r(rr�rUr3r$r!Zndenumerater/r0rorzrw)r,r'rjrkrZr^rrrrrlrs,

z'Common2dMixin.test_convenient_facetgridcCshtd�}t|ddddgd	�}|j|ddddd
�}|j|jjddg�x|jjD]}|j|j��qNWdS)NrQr]r.r@rZr^rqrr)r`)r^rZrcrs)rQr]r.r@)	r(rr�rUr3r$rgr/r0)r,r'rjrkrrrrrt�sz*Common2dMixin.test_convenient_facetgrid_4dcCs�tjjdd�tjddd�}t|dddgd	�}|jjdd
�}|jttdd�|j	D���d
k�|jttdd�|j	D���d
k�dS)Nr��rS)�sizer@r^rZrY)r`)rccss|]}|j�VqdS)N)r�)r
�mrrrr��sz4Common2dMixin.test_facetgrid_cmap.<locals>.<genexpr>rcss|]}|j�jVqdS)N)r�r|)r
rrrrr��s)r�rrSr�)
r!�randomr"rrDr�r/r8rZ
_mappables)r,r�rjZfgrrr�test_facetgrid_cmap�s
"z!Common2dMixin.test_facetgrid_cmapN)r<r=r>�__doc__rCr�r�r�r�rOr�r�r�r�r�r�rrrrrrr	r
r
rr
rrlrtrrrrrr��s6
			r�c@s>eZdZeej�Zdd�Zdd�Zdd�Z	dd�Z
d	d
�ZdS)�TestContourfcCs0|j|j|jjj��|j|j|jjj��dS)N)r�r;rBrDrHr/rL)r,rrr�test_contourf_called�sz!TestContourf.test_contourf_calledcCs |j�}|jt|tjj��dS)N)r1r/r�rr�ZQuadContourSet)r,rrrr�test_primitive_artist_returned�sz+TestContourf.test_primitive_artist_returnedcCs�|j�}|j|jd�d|jd
<d|jd<|jdd�}|j|jd�d|jd<d|jd<|jddd	�}|j|jd
�|jddd	�}|j|jd�dS)Nr�r�rrT)r�r�rQ)r�r�r�r�i����)rrr�r�)r�r�)rrr�r�)r�r�ri����)r1ror�rB)r,rrrr�test_extend�s



zTestContourf.test_extendcCs:|jddd�tj�}|jd|j��|jd|j��dS)Nr�r�)r^rZ)r1rr5rorwrz)r,rrrr�test_2d_coord_names�sz TestContourf.test_2d_coord_namescCs>|jdd	dgd�}|j|jd�|jdd�}|j|jd�dS)
Ng�?g�������?g�������?)r�r�r@r�g�g������ٿ)r1ror�)r,rrrr�test_levels�szTestContourf.test_levelsN)r<r=r>�staticmethodrrLr�rrrrrrrrrr�s
rc@s6eZdZeej�Zdd�Zdd�Zdd�Z	dd�Z
d	S)
�TestContourcCsXdd�}|jdd�}|j||jjd�d
�|jddgd�}|j||jjd�d�dS)NcSst|dd��S)Nr@)�tuple)r�rrr�_color_as_tuple�sz0TestContour.test_colors.<locals>._color_as_tuple�k)r�r�r�r��?)r%r%r%)r%r%r&)r1rorer�)r,r#rrrr�test_colors�szTestContour.test_colorscCs(|jt��|jddd�WdQRXdS)Nr$ZRdBu)r�re)r~rir1)r,rrr�test_cmap_and_color_both�sz$TestContour.test_cmap_and_color_bothc
Cs*|jt��|jddgd�WdQRXdS)Nr$r�)re)r~�	Exceptionr1)r,rrr�!list_of_colors_in_cmap_deprecated�sz-TestContour.list_of_colors_in_cmap_deprecatedcCs:|jddd�tj�}|jd|j��|jd|j��dS)Nr�r�)r^rZ)r1rr5rorwrz)r,rrrrr�szTestContour.test_2d_coord_namesN)r<r=r>r rr�r�r'r(r*rrrrrr!�s

r!c@s.eZdZeej�Zdd�Zdd�Zdd�Z	dS)�TestPcolormeshcCs |j�}|jt|tjj��dS)N)r1r/r�rrr)r,rrrrr�sz-TestPcolormesh.test_primitive_artist_returnedcCs"|j�}|j|j�j|jj�dS)N)r1roZ	get_arrayrrB)r,rrrr�test_everything_plotted�sz&TestPcolormesh.test_everything_plottedcCs:|jddd�tj�}|jd|j��|jd|j��dS)Nr�r�)r^rZ)r1rr5rorwrz)r,rrrrrsz"TestPcolormesh.test_2d_coord_namesN)
r<r=r>r rr�r�rr,rrrrrr+�s
r+c@sNeZdZeej�Zdd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dS)�
TestImshowcCs0|j|j|jjj��|j|j|jjj��dS)N)r�r9rBrDrLr/rH)r,rrr�test_imshow_called
szTestImshow.test_imshow_calledcCsP|jjjdd�|jtjddgtj�j���|jtjddgtj�j	���dS)NF)r�g�?g-@g#@g�g�)
rBrDrHr/r!�allcloserr5r�r�)r,rrr�test_xy_pixel_centeredsz!TestImshow.test_xy_pixel_centeredcCs$|jjj�|jdtj�j��dS)N�auto)rBrDrHrorr5�
get_aspect)r,rrr�test_default_aspect_is_autosz&TestImshow.test_default_aspect_is_autocCs(|jjjdd�|jdtj�j��dS)N�equal)�aspect)rBrDrHrorr5r2)r,rrr�test_can_change_aspectsz!TestImshow.test_can_change_aspectcCs |j�}|jt|tjj��dS)N)r1r/r�rr6r7)r,rrrrrsz)TestImshow.test_primitive_artist_returnedcCsHy.ddl}|jt��|jdd�WdQRXWntk
rBYnXdS)Nrr�)re)r�r~rir1r�)r,r�rrr�!test_seaborn_palette_needs_levels#sz,TestImshow.test_seaborn_palette_needs_levelscCs*|jtd��|jddd�WdQRXdS)Nzrequires 1D coordinatesr�r�)r^rZ)rhrir1)r,rrrr+szTestImshow.test_2d_coord_namesN)r<r=r>r rrHr�r.r0r3r6rr7rrrrrr-	s
r-c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�
TestFacetGridcCs>td�}t|dddgdddd	gid
�|_tj|jdd�|_dS)
NrQr]r@rZr^r_r'r�r�)r`rK)rc)rQr]r@)r(rrBrrrk)r,rjrrrrC1szTestFacetGrid.setUpcCs`|jjtjdd�t�}|jd|�x6|jjjD](}|j|j	��|j
j�}|j|d�q0WdS)Nr^rZ�NonerS)
rkrrrLrrr3rgr/r0r��get_sizer�)r,rrZfontsizerrr�test_no_args7s
zTestFacetGrid.test_no_argscCs�d|j_|jjtjdd�x2td|jjj�D]\}}|j	dj
|�|j��q,Wt�}|j
|jj|�xdD]}|j
||�qjWdS)Nr�r^rZ�abczz = {0})r^rZ)rBr|rkrrrLr�r3rgro�formatr�rr�)r,r$rr�labelrrr�test_names_appear_somewhereEs
z)TestFacetGrid.test_names_appear_somewherecCs|dd�dD�|jjd<tj|jdd�}|jtjdd�t�}tdd	�|D��}|j|d
�|j	d
j
�}|j|jd��dS)NcSsg|]}d|�qS)r�r)r
r�rrrrQsz:TestFacetGrid.test_text_not_super_long.<locals>.<listcomp>r<r_)rcr^rZcss|]}t|�VqdS)N)r8)r
rrrrr�Usz9TestFacetGrid.test_text_not_super_long.<locals>.<genexpr>�2rz...)rr)
rBrKrrrr�rr��
assertLessr3r�r/�endswith)r,rkr�maxlen�t0rrr�test_text_not_super_longPsz&TestFacetGrid.test_text_not_super_longcCs�|jjj�}|jjj�}tj||f�}|jjtj	dd�x:t
j�jt
jj�D]$}tj|j��}|jtj||��qLW|jdtt���dS)Nr^rZr)rBr�r�r�r!r�rkrrrHrrrrr6r7r�r/r/ror8r)r,r�r��expectedr6�climrrr�
test_colorbar[szTestFacetGrid.test_colorbarcCsLtj|jddd�}|jtjdd�|jd	}|j|j��|j|j��dS)
Nr_r.)rcrdr^rZrr�r�)r�r�)	rrrBrrHr3r�r0Zget_visible)r,rkZbottomrightrrr�test_empty_cellhs

zTestFacetGrid.test_empty_cellc	Cs(|jtd��tj|j�WdQRXdS)Nz[Rr]ow)rhrirrrB)r,rrr�test_norow_nocol_errorpsz$TestFacetGrid.test_norow_nocol_errorcCsH|jjtjdd�|jjd}|jj|}|jjdd�}|j||�dS)Nr^rZr)r_)rr)	rkrrrHZ
name_dictsrB�locrZassertDataArrayEqual)r,Zupperleft_dictZupperleft_arrayZz0rrr�test_groupsts
zTestFacetGrid.test_groupscCs6dddg|jjd<tj|jdd�}|jtjdd�dS)Ng�������?g�������?g�������?r_)rcr^rZ)rBrKrrrrH)r,rkrrr�test_float_index|szTestFacetGrid.test_float_indexcCs>dddg|jjd<|jtd��tj|jdd�WdQRXdS)Ng�������?g�������?r_z	[Uu]nique)rc)rBrKrhrirr)r,rrr�test_nonunique_index_error�sz(TestFacetGrid.test_nonunique_index_errorcCs�tjd�}t|dddgd�}d|dd�dd�df<d|d<d|d<tj|dd�}|jtjdddd
�t�}t�}x4|D],}y|j	t
|��Wqvtk
r�YqvXqvWtdd�|D��}|j
|d�dS)Nr�r.rZr^r_)r`ri�rr@)rcT)r�css|]}t|�VqdS)N)r�)r
r^rrrr��sz,TestFacetGrid.test_robust.<locals>.<genexpr>�)r�r�r.i���)r.rr)r@rr)r!�zerosrrrrrHrr�add�floatrir�rA)r,r_rBrkZnumbersrr�largestrrrr��s 


zTestFacetGrid.test_robustcCsnd\}}tj||f�}|jjtjdd||d�x:tj�jt	j
j�D]$}tj|j��}|j
tj||��qBWdS)N�I@�@�@r^rZ)r�r�)rTrU)r!r�rkrrrHrrrrr6r7r�r/r/)r,r�r�rFr6rGrrr�test_can_set_vmin_vmax�sz$TestFacetGrid.test_can_set_vmin_vmaxcCs�|j|jjj�d�tj|jddd�}|j|jj�d�|jjjddd�}|j|jj�d
�tj|jdddd	�}|j|jj�d�dS)NrQr@r_r�)rcr�rAg�?)rcrr5r�)rQr@)rWr�)rWr�)r�rA)	rUrkr2Zget_size_inchesrrrBrDrH)r,rkrrr�test_figure_size�szTestFacetGrid.test_figure_sizecCs�d}|d}|jjtjdd�|jj||d�xb|jjjD]T}t|j��}t|j	��}|j
||�|j
||�|j||d�|j||d�q:WdS)Nr�rr^rZ)Z
max_xticksZ
max_yticksg@)rkrrrHZ	set_ticksr3rgr8Z
get_xticksZ
get_yticksr�r�)r,ZnticksZmaxticksrZxticksZyticksrrr�test_num_ticks�szTestFacetGrid.test_num_tickscCs(|jjtjddt�|jjdd��dS)Nr^rZcSsdS)Nrrrrr�<lambda>�sz(TestFacetGrid.test_map.<locals>.<lambda>)rk�maprrL�Ellipsis)r,rrr�test_map�szTestFacetGrid.test_mapcCs�tj|jjdd�dd�}|jtjddd�t�}xdD]}|j||�q6W|j	d|�|j	d|�|j
dtt���|j
d	d
�|jd	t��|j
dtt���dS)
Nr)r|r_)rcr^rZr9rzcolors!)r>r)r^rZ)rrrBr�r[rrLrr�rror8r�add_colorbar)r,rkrr>rrr�test_map_dataset�s
zTestFacetGrid.test_map_datasetcCsB|jjtjdd�}|jdd�t�}xdD]}|j||�q*WdS)Nr^rZ�	longitude�latitude)r`ra)rkrrrLZset_axis_labelsrr�)r,rkrr>rrr�test_set_axis_labels�s

z"TestFacetGrid.test_set_axis_labelscCs�td�}t|dddgdd�}|jjdddd	�|jd
tt���|jjddddd�|jd
tt���|jjdddd
d�|jdtt���dS)NrQr]rArZr^r_r)r`r|)r^rZrcrT)r^rZrcr^Fr)rQr]rA)r(rrDrHror8r)r,r'rjrrr�test_facetgrid_colorbar�sz%TestFacetGrid.test_facetgrid_colorbarN)r<r=r>rCr;r?rErHrIrJrLrMrNr�rVrXrYr]r_rbrcrrrrr8/s$
	
r8c@seZdZdd�Zdd�ZdS)�TestFacetGrid4dcCsjtd
�}t|ddddgd	�}tjd
d�|jdjD��|jd<tjdd�|jdjD��|jd<||_dS)NrQr]r@r.rZr^rcrs)r`cSsg|]}dt|��qS)rc)�str)r
r^rrrr�sz)TestFacetGrid4d.setUp.<locals>.<listcomp>cSsg|]}dt|��qS)rs)re)r
r^rrrr�s)rQr]r@r.)r(rr!r�rKr�rB)r,r'rBrrrrC�s

zTestFacetGrid4d.setUpcCs�tj|jddd�}|jd
|jj�|jtjdd�x>t|jj	dj
|jdd�df�D]\}}|jt||��qVWx>t|jj	dj
|jd	dd�f�D]\}}|jt||��q�WdS)Nrcrs)rcrsr.r@r^rZrr)r.r@r�)
rrrBror3r$rrHr�rKr�r/r)r,rkr>rrrr�test_default_labels�s,,z#TestFacetGrid4d.test_default_labelsN)r<r=r>rCrfrrrrrd�s
rd)rr),rZnumpyr!ZpandasrVZxarrayrZxarray.plotrDrZxarray.plot.plotrZxarray.plot.utilsrrrryrr	r
Z
matplotlibrZuseZmatplotlib.pyplotZpyplotrr�rrrr(r)r?rur�r�r�r�rr!r+r-r8rdrrrr�<module>sH

	

R9&OP-#&<