U
    Fvf[  ć                   @   s"  d dl Zd dlmZ d dlZd dlmZ d dlm	Z	 d dl
mZ dd Zdd Ze	dgd	d
dgddd Ze	dgd	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
dddd Ze	d gd	d
ddd!d" Ze	d#gd	d
d$dd%d& Zd'd( Zd)d* Zd+d, ZdS )-é    N)Śassert_array_almost_equal)Śimage_comparisonc                  C   sJ   t jddddddf \} }d|d  |  }d| | d  }|| ||fS )Néż’’’é   y              Y@y              i@é’’’’é   é   )ŚnpZmgrid)ŚYŚXŚUŚV© r   śD/tmp/pip-unpacked-wheel-7vhvci0g/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mpl20Zpng)Śremove_textŚstyleŚ
extensionsc                  C   s~   t  \} }}}t t |  ” |  ” d”t | ” | ” d””\}}t | ” | ” g”}tj	| ||||d t 
||d” d S )Né   )Śstart_pointsŚok)r   r	   r   r   ŚminŚmaxZcolumn_stackZravelŚpltŚ
streamplotZplot)r   r
   r   r   Zstart_xZstart_yr   r   r   r   Śtest_startpoints   s    ’r%   Zstreamplot_colormapgŗI+?)r   r   Ztolc               
   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_linewidthgü©ńŅMb`?c               	   C   sV   t  \} }}}t ||”}d| | ”  }t ”  ” }|j| |||ddgd|d d S )Nr   g      ą?r   Śk)r'   r&   r(   )r   r	   Śhypotr"   r#   ŚfigureŚsubplotsr$   )r   r
   r   r   ŚspeedZlwŚaxr   r   r   Śtest_linewidth.   s
    r2   Zstreamplot_masks_and_nans)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 	”  
” }tjd	d
  |j| ||||tjjd W 5 Q R X d S )N)Zdtyper   é(   é<   éP   éx   é   )ŚmaskŚignore)Śinvalid)r&   r)   )r   r	   ŚzerosŚshapeŚboolŚnanŚmaŚarrayr#   r.   r/   Zerrstater$   r*   ZBlues)r   r
   r   r   r8   r1   r   r   r   Śtest_masks_and_nans8   s    rA   zstreamplot_maxlength.pnggŁĪ÷SÓ?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 )Nē      $@ē        ē      ų?r   )Ś	maxlengthr   r(   r'   r   r   ©Ng\bw
@©NgĖĒi @©ZxlimZylim©	r   r#   r.   r/   r$   Zget_xlimZget_ylimŚAssertionErrorŚset©r   r   r   r   r1   r   r   r   Śtest_maxlengthE   s     ’*rM   z"streamplot_maxlength_no_broken.pngc                  C   sx   t  \} }}}t ”  ” }|j| |||dddggdddd	 | ” d | ” d   kr`dksfn t|jd	d
d d S )NrB   rC   rD   r   F)rE   r   r(   r'   Zbroken_streamlinesr   r   rF   rG   rH   rI   rL   r   r   r   Śtest_maxlength_no_brokenQ   s      ’*rN   zstreamplot_direction.pnggć„Ä °²?c                  C   s4   t  \} }}}tj| |||ddddggddd	 d S )NZbackwardrD   rC   r   )Zintegration_directionrE   r   r(   r'   )r   r#   r$   )r   r   r   r   r   r   r   Śtest_direction]   s      žrO   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éū’’’é
   r7   éž’’’é   é   é    )Z	transform)r7   é   é   é   r   )Śdecimal)r#   Zaxesr	   r   r   ŚmtransformsZAffine2DŚ	translateZ	transDataZbarbsr   r   r   ZdataLimZbounds)r1   r   r   Ztransr   r   r   Śtest_streamplot_limitsf   s     
’r\   c               	   C   sņ  t  d”} t  d”}t  ddgddgg”}t  ddgddgg”}tjtdd t ||| |” W 5 Q R X t  ddgddgg”}t  ddgddgg”}tjtdd t ||| |” W 5 Q R X t  ddgddgg”}t  ddgddgg”}t ||| |” t  ddg”}t  ddggg”}tjtd	d t ||| |” W 5 Q R X t  d
”} t  d
”}t  dddg”}t  dddg”}tjtdd t ||| |” W 5 Q R X t  dddg”}t  dddg”}tjtdd t ||| |” W 5 Q R X d S )N)r   r   rQ   r7   rV   zThe rows of 'x' must be equal)Śmatchz The columns of 'y' must be equalr   z$'y' can have at maximum 2 dimensions©r   r   z!'y' values must be equally spacedr3   z'y' must be strictly increasing)	r	   Zonesr;   r@   ŚpytestZraisesŚ
ValueErrorr#   r$   )ŚuŚvr   r   r   r   r   Śtest_streamplot_gridt   s6    



rc   c                	   C   sn   t jt d”t d”t dtj”t dtj”tj dd”d t  tdtdtj dd”tj dd”” d S )Nr   r^   )r&   )	r#   r$   r	   ZarangeŚfullr>   ŚrandomZrandŚranger   r   r   r   Śtest_streamplot_inputs¢   s     ž ’rg   )Znumpyr	   Znumpy.testingr   r_   Zmatplotlib.pyplotZpyplotr#   Zmatplotlib.testing.decoratorsr   Zmatplotlib.transformsZ
transformsrZ   r   r   r%   r+   r2   rA   rM   rN   rO   r\   rc   rg   r   r   r   r   Ś<module>   sZ   

’
	
’

’
 ’
  ’

  ’

  ’
.