o
    ¦ƒðjå  ã                   @   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!   ú§/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/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    ,