B
    Mô`ï  ã               @   s  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 e jdkZe jdkZdd„ Zdd	„ Ze	d
gddd�dd„ ƒZe	dgdddd�dd„ ƒZe	dgddd�dd„ ƒZe	dgdderÀdnd d�dd„ ƒZe	dgdderâdnd d�dd„ ƒZe	d gddd�d!d"„ ƒZd#d$„ ZdS )%é    N)Úassert_array_almost_equal)Úimage_comparisonÚwin32Údarwinc              C   sJ   t jddd…ddd…f \} }d|d  |  }d| | d  }|| ||fS )Néýÿÿÿé   y              Y@éÿÿÿÿé   é   )ÚnpZmgrid)ÚYÚXÚUÚV© r   úD/tmp/pip-unpacked-wheel-0c1wfn4v/matplotlib/tests/test_streamplot.pyÚvelocity_field   s    r   c              C   sx   t  ddd¡} t  ddd¡}t  | |¡\}}d}t  |¡|  t  |¡|  }t  |¡|  t  |¡|  }| |||fS )Ng      Àg      @éd   gš™™™™™¹?)r   ÚlinspaceÚmeshgridÚcosÚsin)ÚxÚyr   r   Úar   r   r   r   r   Úswirl_velocity_field   s    r   Zstreamplot_startpointsTZmpl20)Úremove_textÚstylec              C   sn   t ƒ \} }}}t |  ¡ |  ¡ d¡}t | ¡ | ¡ d¡}t ||g¡}tj| ||||d� t ||d¡ d S )Né
   )Ústart_pointsÚok)	r   r   r   ÚminÚmaxZcolumn_stackÚpltÚ
streamplotZplot)r   r   r   r   Zstart_xZstart_yr   r   r   r   Útest_startpoints   s    r%   Zstreamplot_colormapg{®Gáz¤?)Útolr   r   c           
   C   s8   t ƒ \} }}}tj| ||||ddtjjd� t ¡  d S )Ng333333ã?r	   )ÚcolorÚdensityÚ	linewidthÚcmap)r   r#   r$   ÚcmZautumnZcolorbar)r   r   r   r   r   r   r   Útest_colormap)   s    r,   Zstreamplot_linewidthc           	   C   sp   t ƒ \} }}}t ||¡}d| | ¡  }d}t ¡  ¡ }|jddd� |j| |||d| d| gd|d	� d S )
Né   g«ªªªªªê?)g      Àgôÿÿÿÿÿ@)g     Àgôÿÿÿÿÿ@)ÚxlimÚylimg      à?g      ð?Úk)r(   r'   r)   )	r   r   Úhypotr"   r#   ÚfigureÚsubplotsÚsetr$   )r   r   r   r   ÚspeedZlwZdfÚaxr   r   r   Útest_linewidth2   s    r7   Zstreamplot_masks_and_nans)r   r   r&   c           	   C   s¨   t ƒ \} }}}tj|jtd�}d|dd…dd…f< tj|d d…d d…f< tjj||d�}t 	¡  
¡ }|jddd	� tjd
d��  |j| ||||tjjd� W d Q R X d S )N)Zdtyper
   é(   é<   é   )Úmask)g      Àgôÿÿÿÿÿ@)g     Àgôÿÿÿÿÿ@)r.   r/   Úignore)Úinvalid)r'   r*   )r   r   ÚzerosÚshapeÚboolÚnanÚmaÚarrayr#   r2   r3   r4   Zerrstater$   r+   ZBlues)r   r   r   r   r;   r6   r   r   r   Útest_masks_and_nans@   s    rD   zstreamplot_maxlength.pnggü©ñÒMb`?c           
   C   sv   t ƒ \} }}}t ¡  ¡ }|j| |||dddggddd� | ¡ d | ¡ d   kr^dksdn t‚|jdd	d
� d S )Ng      $@g        g      ø?r	   )Ú	maxlengthr   r)   r(   r   r   )Ngž\‚bw
@)Ng‡ËÇi @)r.   r/   )	r   r#   r2   r3   r$   Zget_xlimZget_ylimÚAssertionErrorr4   )r   r   r   r   r6   r   r   r   Útest_maxlengthP   s    
*rG   zstreamplot_direction.pngc              C   s4   t ƒ \} }}}tj| |||ddddggddd�	 d S )NZbackwardg      ø?g        r	   )Zintegration_directionrE   r   r)   r(   )r   r#   r$   )r   r   r   r   r   r   r   Útest_direction]   s    
rH   c              C   s€   t  ¡ } t ddd¡}t ddd¡}t ||¡\}}t ¡  dd¡| j }t j	||t 
|¡t |¡|d� t| jjd	d
d� d S )Néûÿÿÿr   r:   éþÿÿÿé   é   é    )Z	transform)r:   é   é   é   r
   )Údecimal)r#   Zaxesr   r   r   ÚmtransformsZAffine2DÚ	translateZ	transDataZbarbsr   r   r   ZdataLimZbounds)r6   r   r   Ztransr   r   r   Útest_streamplot_limitsf   s     
rT   )ÚsysZnumpyr   Znumpy.testingr   Zmatplotlib.pyplotZpyplotr#   Zmatplotlib.testing.decoratorsr   Zmatplotlib.transformsZ
transformsrR   ÚplatformZon_winZon_macr   r   r%   r,   r7   rD   rG   rH   rT   r   r   r   r   Ú<module>   s*   



