
    Ngc                        d dl mZ ddlmZmZmZ d dlZ	 d dlZ e e	e
ej                            d          d d                             dk     Z e e	e
ej                            d          d d                             d	k     Zn# e$ r	 dZd
Zd
ZY nw xY werdZndZd Zej        d             Zd'dZej        d             Zd Zd Zej        d             Zd Zd Zd Zd Zd Zed Znd Zd Z d Z!ej        d(d            Z"ej        d             Z#d  Z$ej        d!             Z%d" Z&ej        d#             Z'd$ Z(d% Z)d& Z*dS ))    )absolute_import   )CTypeCTypedefTypeCStructOrUnionTypeN.   )r   	      )r   r
      T__builtin__builtinsc                 \    | dS t          | dd           }|o|                    dd          S )NF
directives
np_pythran)getattrget)envr   s     S/var/www/html/ai-engine/env/lib/python3.11/site-packages/Cython/Compiler/Pythran.pyhas_np_pythranr      s6    
{ulD11J>:>>,>>?    c                 b    t          | t                    rt          | j                  S | j        S N)
isinstancer   is_pythran_supported_typetypedef_base_type
is_numerictype_s    r   is_pythran_supported_dtyper        s/    %&& B()@AAAr   ndarrayc           	         | j         r| j        | j        }}t          |t                    r|j        }nYt          |t                    r|                                }n/t          |t                    r|j	        }nt          d|z            t          rd|||fz  S d|d|dd                    d|z            dS | j        r| j        S | j        r|                                 S t          d	| d
t!          |           d          )Nzunsupported type %s!zpythonic::types::%s<%s,%d>pythonic::types::<z,pythonic::types::pshape<,)longz>>zunsupported pythran type z ())	is_bufferndimdtyper   r   cnamer   sign_and_namer   typedef_cname
ValueErrorpythran_is_pre_0_9joinis_pythran_exprpythran_typer   type)Typtyper)   r*   ctypes        r   r2   r2   '   s8   	| sWbhUe/00 	=KEEu%% 	=''))EE|,, 	='EE3e;<<< 	s/52EEE	s MREERWRWRWY\YaYabklpbpYqYqYqYqrr	  
} "!!!
*222tBxxxxH
I
IIr   c                     d| z  S )Nz(typename std::remove_reference<%s>::type )tys    r   type_remove_refr:   ?   s    5::r   c                     | dk    r#dt          |          dt          |          dS dt          |          d| dt          |          dS )	Nz**z8decltype(pythonic::numpy::functor::power{}(std::declval<z>(), std::declval<z>()))decltype(std::declval<z>() z std::declval<>())r2   )optAtBs      r   pythran_binop_typerB   D   sp    	Tzzzl2....0 	0 
 bbb,r"2"2"2"24 	4r   c                 .    d| dt          |          dS )N	decltype(zstd::declval<r=   r>   )r?   r   s     r   pythran_unaryop_typerE   M   s%     
L! !r   c                 z     d                      fd|D                       }t          |          dk    rdnd|z  S )Nr%   c                 &    g | ]} |          S r8   r8   ).0idx
index_codes     r   
<listcomp>z!_index_access.<locals>.<listcomp>T   s!    <<<SC<<<r   r   z[%s]z(%s))r0   len)rJ   indicesindexings   `  r   _index_accessrO   R   sH    xx<<<<G<<<==H'lla''FFVx??r   c                     | \  }}|j         rBdt          |j        j                   z   }dt          dd                    dg|z            dS |j        rd|                                z  S |j        r
d|j	        z  S t          d|z            )	Nr	   z
pythonic::z::functor::slice{}(r%   0r'   std::declval<%s>()zunsupported indexing type %s!)is_sliceintstepis_nonepythran_builtinsr0   is_intr,   r1   r2   r.   )index_with_typerI   
index_typens       r   _index_type_coder\   X   s    %OC
| >(()))HHcU1W 	 
	 >#j&>&>&@&@@@		# >#j&===
4zA
B
BBr   c                 ^   | j         rU| j        | j        | j        f}| j        j        rd}|d d         }nd}d|dd                    d |D                       dS | j        j        rt          |           S | j        j	        r| 
                                S t          d	| j        z            )
Ncontiguous_slicer	   slicer#   (r%   c              3   >   K   | ]}|                                 V  d S r   )pythran_result)rH   vs     r   	<genexpr>z_index_code.<locals>.<genexpr>o   s.      ??1A,,..??????r   r'   zunsupported indexing type %s)rS   startstoprU   rV   r0   r3   rX   
to_pythranr1   rb   r.   )rI   valuesfuncs      r   _index_coderj   f   s    
| $CHch.8 	%DBQBZFFDDD#((?????@@@@B 	B	 $#		! $!!###
3ch>
?
??r   c           	      n    t          dt          |           dt          t          |          d          S )Nr<   z>()r'   )r:   r2   rO   r\   )r   rM   s     r   pythran_indexing_typerl   w   s@    ?U&0000   r   c                 ,    t          t          |           S r   )rO   rj   )rM   s    r   pythran_indexing_codern   ~   s    g...r   c                 N    | j         sg S t          | j                  | j        gz   S r   )is_numpy_attributenp_func_to_listobj	attributeri   s    r   rq   rq      s,    " 	48$$'777r   c                     dS )NFr8   )names    r   pythran_is_numpy_func_supportedrw      s    ur   c                     t           j        j        d         }t          |           }|D ]}|                    |d           }| dS dS )NnumpyFT)pythrantablesMODULESrq   r   )ri   CurFFLFs       r   rw   rw      sV    ~%g.T"" 	 	A88At$$D|uu tr   c                 ~    t          |           } d                    | d d         dgz             }d|d| d         S )Nz::functorzpythonic::numpy::rq   r0   )ri   
submoduless     r   pythran_functorr      sF    4  D49	{233JJ(2

DHH==r   c                 l    d                     d |D                       }dt          |           d|dS )Nr%   c              3   D   K   | ]}d t          |j                  z  V  dS )rR   N)r2   r3   )rH   as     r   rd   z$pythran_func_type.<locals>.<genexpr>   s2      OOQ)L,@,@@OOOOOOr   rD   z{}(z)))r0   r   )ri   argss     r   pythran_func_typer      sA    88OO$OOOPPDD#24#8#8#8#8$$$??r   c                 N   | j         }|j        r'|                    |                                           S t	          |g d          r|                                 S | j        r
dt          z  S |t          |          }| j         j        sJ d|d| 	                                dS )N)r1   r   is_float
is_complexzpythonic::%s::Nonezfrom_python<z>(r'   )
r3   rX   	cast_coderesultis_typerV   rW   r2   is_pyobject	py_result)r?   r5   op_types      r   rg   rg      s    gG~ .  ---wSSSTT yy{{	z 7#&666}W%%7$)EE2<<>>>>::r   c                 8    |D ]}t          | |d          r dS dS )NFT)r   )r   typesattrs      r   r   r      s6      5$&& 	44	5r   c                 8    | j         pt          | j                  S r   )rV   r   r3   )nodes    r   !is_pythran_supported_node_or_noner      s    <?4TY???r   c                 D    d}t          | |          pt          |           S )N)r1   rX   r   r   rV   r   r   r1   r   pythran_supporteds     r   r   r      s)    X5+,,F0F0FFr   c                 D    d}t          | |          pt          |           S )N)r1   rX   r   r   r   r   r   s     r   #is_pythran_supported_operation_typer      s)    M5*++Eu/E/EEr   c                     | j         S r   )r1   r   s    r   r1   r1      s      r   c                 Z    | j         o$t          | j                  o| j        dv o| j         S )N)cstrided)is_numpy_bufferr    r*   modecastr   s    r   is_pythran_bufferr      s;    ! >&@&M&M >J**>38:~?r   c                 P    t          |           } dd                    |           z  S )Nzpythonic/numpy/%s.hpp/r   rt   s    r   pythran_get_func_include_filer      s$    4  D"SXXd^^33r   c                    |                      d           |                      d           |                      d           |                      d           |                      d           |                      dt          z             |                      d           dD ]2}|                      d	|z             |                      d
|z             3dD ]}|                      d|z             d S )Nzpythonic/core.hppzpythonic/python/core.hppzpythonic/types/bool.hppzpythonic/types/ndarray.hppzpythonic/numpy/power.hppzpythonic/%s/slice.hppz<new>)          @   zpythonic/types/uint%d.hppzpythonic/types/int%d.hpp)
floatfloat32float64setr_   tuplerT   complex	complex64
complex128zpythonic/types/%s.hpp)add_include_filerW   )r   its      r   include_pythran_genericr      s   ,---344423335666344403CCDDD!!! = =81<===7!;<<<<4 : :4q89999: :r   )r!   r   )+
__future__r   
PyrexTypesr   r   r   cythonrz   r   maprT   __version__splitr/   pythran_is_pre_0_9_6ImportErrorrW   r   ccallr    r2   cfuncr:   rB   rE   rO   r\   rj   rl   rn   rq   rw   r   r   rg   r   r   r   r   r1   r   r   r   r8   r   r   <module>r      s)   ' & & & & & ? ? ? ? ? ? ? ? ? ?  NNNss3(;(A(A#(F(Fqs(KLLMMPVV 5S'*=*C*CC*H*H1*M!N!NOOR[[      G 
  "$!
@ @ @   J J J J0 ; ; ;4 4 4! ! !
 @ @ @
C C C@ @ @"  / / /8 8 8
 ?     > > >
@ @ @
 ; ; ; ;    @ @ @ G G GF F F ! ! !? ? ?4 4 4: : : : :s   A6B BB