U
    	-e                     @   s  d dl mZmZ d dlmZ d dlmZmZ d dlm	Z	 d dl
mZ d dlmZmZmZ d dlmZmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZmZmZ d dlmZ d dl m!Z! d dl"Z"e  dddZ#dddddZ$dd Z%edd Z&dd Z'dd Z(dd Z)dS )     )Ipi)Eq)Symbolsymbols)re)exp)cossintan)AndOr)plot_implicit)
unset_show)NamedTemporaryFilemkdtemp)skipwarnsXFAIL)import_module)TmpFileManagerN c                 C   s   t d| ddjS )Nz.pngF)suffixdirdelete)r   namer   r    r   h/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/sympy/plotting/tests/test_plot_implicit.pytmp_file   s
      r   r   r   c                O   s0   t | f||}|t||d |j  d S )Nr   )r   saver   Z_backendclose)exprr   r   argskwargspr   r   r   plot_and_save   s    r'   c                 C   s  t  }t| td}td}tt|t||ddf|ddf| |d tt|d |d | |ddf|d	d
f| |d t|d| k|ddf|ddf| |d t|dt| k |ddf|ddf| |d t|dt| t| k|ddf|ddf| |d t||d k|ddf|ddf| |d tt|d |d | |d tt|d |d | d|d tt|d |d | dd|d t||k|ddf|d tt	|t
|k||d k|d tt||k|| k|d t|d d |ddf|d t|d d |d t||kd|d t||kd|d t|t|kd|d t|t|k d|d tt	|t|kt||kt|||d t|tt|  |d t|d d d|d d S )Nxy      r             )r   F)adaptiver   i  )r4   Zpointsr   )depthr   zAn implicit plot)titler   )r   r   
tmp_folderr   r'   r   r	   r   r
   r   r   r   r   )r   temp_dirr(   r)   r   r   r   plot_implicit_tests   sZ    
(            ""*r9   c               	   C   s   t ddtfd} | rzdt }t| td}td}ttdd. t	t
|tt|tt|  d|d	 W 5 Q R X W 5 t  X ntd
 d S )N
matplotlib1.1.0Zmin_module_versionZcatchr(   r)   z%Adaptive meshing could not be applied)matchtestr    "Matplotlib not the default backend)r   RuntimeErrorr   cleanupr   r7   r   r   UserWarningr'   r   r   r	   r   r
   r   )r:   r8   r(   r)   r   r   r   test_no_adaptive_meshingB   s    
6rC   c                  C   st   t d\} }t| d |d  d ddd}|jd jdks>tt| d |d  d ddd}|jd jdksptd S )	Nzx, yr-   r1   greenF)
line_colorshowr   r)r   r   Z_seriesrE   AssertionError)r(   r)   r&   r   r   r   test_line_colorV   s
    rI   c                  C   s@   t ddtfd} | r4ztd t  W 5 t  X ntd d S )Nr:   r;   r<   r>   r?   )r   r@   r   rA   r9   rI   r   )r:   r   r   r   test_matplotlib]   s    
rJ   c                  C   s  t ddtfd} | std ddlm} tjtjt	}zNt }t
| td\}}|d d	 |d	  d	k }|d d	 |d	  d	k }t|d
d}tj|d}	t||@ ||}
|
| ||	|d t|dd}tj|d}	t||B ||}
|
| ||	|d t|dd}tj|d}	t| ||}
|
| ||	|d t|dd}tj|d}	t||A ||}
|
| ||	|d W 5 t
  X d S )Nr:   r;   r<   r?   r   )compare_imageszx yr1   r-   test_region_andr   ztest_region_and.pngg{Gzt?Ztest_region_orztest_region_or.pngZtest_region_notztest_region_not.pngZtest_region_xorztest_region_xor.png)r   r@   r   Zmatplotlib.testing.comparerK   ospathdirnameabspath__file__r   rA   r   r7   r   r   joinr   r!   )r:   rK   Ztest_directoryr8   r(   r)   r1r2Ztest_filenameZcmp_filenamer&   r   r   r   rL   i   s@    




rL   )Nr   )*Zsympy.core.numbersr   r   Zsympy.core.relationalr   Zsympy.core.symbolr   r   Z$sympy.functions.elementary.complexesr   Z&sympy.functions.elementary.exponentialr   Z(sympy.functions.elementary.trigonometricr	   r
   r   Zsympy.logic.boolalgr   r   Zsympy.plotting.plot_implicitr   Zsympy.plotting.plotr   tempfiler   r   Zsympy.testing.pytestr   r   r   Zsympy.externalr   Zsympy.testing.tmpfilesr   rM   r   r'   r9   rC   rI   rJ   rL   r   r   r   r   <module>   s,   
$
