U
    0e                     @   s   d dl Z d dl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mZmZmZmZmZmZ d dlmZmZ d d	lmZ ed
ZedZdd Zdd Ze	dd ZdS )    N)import_module)ccode)compile_link_import_stringshas_c)	may_xfail)skip)	FunctionDefinitionFunctionPrototypeVariablePointerreal
Assignmentinteger	CodeBlockWhile)voidPreIncrement)render_as_source_filecythonZnumpyc                  C   st   t dttdttdtf } \}}}t dt}t||k t|| || t|g}t|jdd|}t	t
d| |S )Nninpoutir   )valueZour_test_function)r
   r   r   r   r   r   r   r   Zas_Declarationr   r   )Zdeclarsr   r   r   r   Zwhlbody r   I/tmp/pip-unpacked-wheel-_6tpq7m6/sympy/codegen/tests/test_applications.py	_mk_func1   s
    &
$r   c                 C   sN   t | ddid}tt| }td|fdddd j|| jd	d
fg|dS )NZcontractF)settingszour_test_func.cz_our_test_func.pyxz#cython: language_level={}
3zfcdef extern {declar}
def _{fname}({typ}[:] inp, {typ}[:] out):
    {fname}(inp.size, &inp[0], &out[0])double)declarfnametyp	build_dir)r   r   r	   Zfrom_FunctionDefinitionr   formatname)Zfuncdefr%   Zcode_strr!   r   r   r   _render_compile_import   s    
  r(   c               	   C   s   t std t std ts&td d } t H}tt |d\}} t d}t 	|}|
|| t ||svtW 5 Q R X d S )Nznumpy not installed.zNo C compiler found.zCython not found.r$   g      $@)npr   r   r   tempfileTemporaryDirectoryr(   r   ZarangeZ
empty_likeZ_our_test_functionZallcloseAssertionError)infofoldermodr   r   r   r   r   test_copying_function*   s    


r0   ) r*   Zsympy.externalr   Zsympy.printing.codeprinterr   Zsympy.utilities._compilationr   r   Z!sympy.utilities._compilation.utilr   Zsympy.testing.pytestr   Zsympy.codegen.astr   r	   r
   r   r   r   r   r   r   Zsympy.codegen.cnodesr   r   Zsympy.codegen.cutilsr   r   r)   r   r(   r0   r   r   r   r   <module>   s   ,