o
    3Ih                     @   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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	eddd Z dS )    N)import_module)ccode)compile_link_import_stringshas_c)	may_xfail)skipskip_under_pyodide)	FunctionDefinitionFunctionPrototypeVariablePointerreal
Assignmentinteger	CodeBlockWhile)voidPreIncrement)render_as_source_filecython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   )valueour_test_function)r   r   r   r   r   r   r   r   as_Declarationr	   r   )declarsr   r   r   r   whlbody r!   e/home/air/sanwanet/gpt-api/venv/lib/python3.10/site-packages/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 )N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
   from_FunctionDefinitionr   formatname)funcdefr,   code_strr(   r!   r!   r"   _render_compile_import   s   
r2   z,Emscripten does not support process spawningc                  C   s   t std t std tstd d } t *}tt |d\}} t d}t 	|}|
|| t ||s;J W d    d S 1 sFw   Y  d S )Nznumpy not installed.zNo C compiler found.zCython not found.r+   g      $@)npr   r   r   tempfileTemporaryDirectoryr2   r#   arange
empty_like_our_test_functionallclose)infofoldermodr   r   r!   r!   r"   test_copying_function*   s   


"r=   )!r4   sympy.externalr   sympy.printing.codeprinterr   sympy.utilities._compilationr   r   !sympy.utilities._compilation.utilr   sympy.testing.pytestr   r   sympy.codegen.astr	   r
   r   r   r   r   r   r   r   sympy.codegen.cnodesr   r   sympy.codegen.cutilsr   r   r3   r#   r2   r=   r!   r!   r!   r"   <module>   s    ,