
VW                 @   s-  d  d l  m Z m Z m Z m Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 Z
 d  d l j Z d  d l m Z m Z d  d l m Z d d   Z d	 d
   Z d d   Z d d   Z e d d g d d  d d    Z e d d    Z e d k r)d  d l Z e j d d d g d d  d S)    )absolute_importdivisionprint_functionunicode_literalsN)six)xrange)image_comparisoncleanup)assert_raisesc       	      C   s   d d g } | d j  | d j g } d d   } x t t |   D] } x t | d t |   D] } x~ t t |   D]j } | | j | | | |  |  | | | f k s~ t d | | | |  | | | f  | | f   q~ Wqe WqE Wd S)	z
    results is a 4 x 4 x 2 matrix of boolean values where
        if [i, j, 0] == True, X axis for subplots i and j should be shared
        if [i, j, 1] == False, Y axis for subplots i and j should not be shared
    xyr   c             S   s   |  r
 d Sd S)Nznot   )rr   r   Y/s/python-3.5.2/amd64_ubu14/lib/python3.5/site-packages/matplotlib/tests/test_subplots.py<lambda>   s    zcheck_shared.<locals>.<lambda>   z,axes %i and %i incorrectly %ssharing %s axisN)Z_shared_x_axesZ_shared_y_axesr   lenZjoinedAssertionError)	resultsfaxsZ
shared_strsharedtostri1i2Zi3r   r   r   check_shared   s     r   c             C   s   d d   } x t  | |  d |  d  D] \ } } } x< | j   D]. } | j   | k sC t d | |    qC Wx< | j   D]. } | j   | k s t d | |    q Wq' Wd  S)Nc             S   s   |  r
 d Sd S)NZ	invisiblevisibler   )vr   r   r   r   &   s    zcheck_visible.<locals>.<lambda>r   r   zX axis was incorrectly %szY axis was incorrectly %s)zipZget_xticklabelsZget_visibler   Zget_yticklabels)resultr   r   r   axvxvylr   r   r   check_visible%   s    *r%   c              C   s!  d }  d t  j |  d  d  d t d t  j |  d  d  d t d t  j d d d d g d d d d g d d d d g d d d d g g  d	 t  j d d d d g d d d d g d d d d g d d d d g g  i } d
 d d d d d g d	 d d d d g d d g d d d g d d d g d d d d d d g i d d d d d d g d	 d g d d d d d d g d d g d d d g d d d d d d g i i } | d | d <| d | d <t j d d  \ } \ \ } } \ } } | | | | g } t t  j | d | d f  | |  t j	 |  d d d d d d	 g }	 x |	 D] }
 x |	 D] } t j d d d |
 d | \ } \ \ } } \ } } | | | | g } t t  j | |
 | | f  | |  t
 t d
 | d
 |
 d | d |  | |  t j	 |  qdWqWWd  S)N      alldtypenonerowFTcolr   r   sharexsharey)r&   r&   r'   )numpyonesboolzerosarraypltsubplotsr   dstackcloser%   dict)ZrdimZsharer   r   a1a2a3Za4r   ZopsZxoZyor   r   r   test_shared0   sX    		*
6
%
r<   c               C   s   t  t t j d d d d t  t t j d d d d t j   i t j d d d d t t  t t j d d d  t  t t j d d d
  t  t t j d d d  Wd  QRXd  S)Nr'   r-   Zblahr.   ignoremessagez .*sharex\ argument\ to\ subplotscategoryr   r      )r
   
ValueErrorr4   r5   warningscatch_warningsfilterwarningsUserWarningr   r   r   r   test_exceptionsi   s    rG   baseline_imagesZsubplots_offset_textZremove_textFc              C   s   t  j d d d  }  t  j d d d  d } t j d d d d	 d
 d \ } } | d j |  |   | d j |  |   | d j | |   | d j | |   d  S)Nr   g    _Bg    eAd   
   g     @r'   r-   r,   r.   r(   r   )r   r   )r   r   )r   r   )r   r   )r/   aranger4   r5   Zplot)r   r   Zfigaxesr   r   r   test_subplots_offsettextx   s    $rM   c               C   s   t    t   d  S)N)r<   rG   r   r   r   r   test_subplots   s    rN   __main__argvz-sz--with-doctestexit)
__future__r   r   r   r   rC   Zmatplotlib.externalsr   Zmatplotlib.externals.six.movesr   r/   Zmatplotlib.pyplotZpyplotr4   Zmatplotlib.testing.decoratorsr   r	   
nose.toolsr
   r   r%   r<   rG   rM   rN   __name__nose	runmoduler   r   r   r   <module>   s    "9$
