
    -PhJi                     F   d dl mZ d dlm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 d d	l	mZ d d
l	mZ d;dZ G d de          ZdZd ddddZd ZdZdZdZdZdZdZdZdZd<dZ G d d          Zd  Zd! Zd" Z d# Z!d$ Z"d% Z#d& Z$d' Z%d( Z&d) Z'd* Z(d+ Z)d, Z*d- Z+d. Z,d=d/Z-d=d0Z. e/e
j0        1          Z1 e.d2e13          Z2 e.d4          Z3 e.d5          Z4 e.d6          Z5 e.d7          Z6 e.d8e13          Z7 e.d9e13          Z8 e.d:          Z9dS )>   )CythonTransform)
ModuleNode)CompileError)CythonUtilityCode)UtilityCodeTempitaUtilityCode)Options)Interpreter)
PyrexTypes)Naming)Symtab    c                     ddl m}  ||           } |dk    r9d|z  d                    fd|                     d          D                       } | S )Nr   dedent 
c                     g | ]}|z   S  r   ).0xindents     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Compiler/Buffer.py
<listcomp>zdedent.<locals>.<listcomp>   s    ???&1*???    )textwrapr   joinsplit)textreindentr   r   s      @r   r   r      sk    6$<<D!||xyy????djj.>.>???@@Kr   c                   8     e Zd ZdZdZ fdZd Zd Zd Z xZ	S )IntroduceBufferAuxiliaryVarsFc                     t          |t                    sJ d| _        t                                          |          }| j        rt          |j                   |S )Nr   )
isinstancer   max_ndimsuper__call__buffers_existsuse_bufstruct_declare_codescope)selfnoderesult	__class__s      r   r'   z%IntroduceBufferAuxiliaryVars.__call__   sW    $
+++++!!$'' 	3&tz222r   c                   
 j                                         }d |D             }t          |          dk    r|                    d            d| _        d |D             }t          |          dk    rd| _        |D ].\  dk    r#t          j        t                    r	d| _         n/~t          t                    r(t          |          dk    rt          j        d          |D ]j        j        j        rt          j        d	          j        j        }|j        t"          j        k    r"t          j        d
t"          j        z            |j        | j        k    r|j        | _        fd
t(          j        t,          j        ft(          j        t,          j        ff}
fd|D             \  }}	t5          j        ||	          _        |_        | _        d S )Nc                 0    g | ]\  }}|j         j        |S r   )type	is_bufferr   nameentrys      r   r   z=IntroduceBufferAuxiliaryVars.handle_scope.<locals>.<listcomp>0   s&    PPP[T55:;OP5PPPr   r   c                     | j         S N)r4   )r5   s    r   <lambda>z;IntroduceBufferAuxiliaryVars.handle_scope.<locals>.<lambda>2   s    5: r   )keyTc                 0    g | ]\  }}|j         j        |S r   )r1   is_memoryviewslicer3   s      r   r   z=IntroduceBufferAuxiliaryVars.handle_scope.<locals>.<listcomp>5   s&    bbbkdEEJDabEbbbr   
memoryviewz'Buffer vars not allowed in module scopez-Buffers with pointer types not yet supported.z1Buffer ndims exceeds Options.buffer_max_dims = %dc                                          |          }                    d || j                  }j        rd|_        |S )N)r4   cnamer1   posT)mangledeclare_varr?   is_argused)r1   prefixr>   aux_varr5   r4   r,   r*   s       r   decvarz9IntroduceBufferAuxiliaryVars.handle_scope.<locals>.decvarP   sS    VT22++U1548 , E E< (#'GLr   c                 .    g | ]\  }} ||          S r   r   )r   r1   rD   rF   s      r   r   z=IntroduceBufferAuxiliaryVars.handle_scope.<locals>.<listcomp>[   s)    #W#W#W^dFFF4$8$8#W#W#Wr   )entriesitemslensortr(   r$   utility_code_definitionr   using_memoryviewr   r   r?   r1   dtypeis_ptrr4   ndimr	   buffer_max_dimsr%   r   c_pyx_buffer_nd_typer   pybuffernd_prefixc_pyx_buffer_typepybufferstruct_prefixr   	BufferAux
buffer_auxbuffer_entriesr*   )r+   r,   r*   scope_itemsbufvarsmemviewslicevarsbuftypeauxvars
pybufferndrcbufferrF   r5   r4   s    ``       @@@r   handle_scopez)IntroduceBufferAuxiliaryVars.handle_scope+   s0    m))++PPKPPPw<<!LL55L666"&Dbb[bbb  1$$"&D ) 	 	MT5|##
53PRc(d(d#(,%dJ'' 	TCLL1,<,<tx)RSSS 	F 	FEz& ^"48-\]]]:DjG|g555"48KgNeeg g g|dm++ '        #79QR"4f6RSUG#W#W#W#Ww#W#W#W J%/
HEEE&


r   c                 f    |                      ||j                   |                     |           |S r7   )r`   r*   visitchildrenr+   r,   s     r   visit_ModuleNodez-IntroduceBufferAuxiliaryVars.visit_ModuleNodeb   s3    $
+++4   r   c                 f    |                      ||j                   |                     |           |S r7   )r`   local_scoperb   rc   s     r   visit_FuncDefNodez.IntroduceBufferAuxiliaryVars.visit_FuncDefNodeg   s4    $ 01114   r   )
__name__
__module____qualname__r(   rM   r'   r`   rd   rg   __classcell__)r.   s   @r   r"   r"      ss         N    5 5 5n  
      r   r"   )rN   rP   modenegative_indicescastfullTF)rP   rl   rm   rn   z"%s" is not a buffer optionzToo many buffer optionsz#"%s" buffer option already suppliedz"%s" missingz[Only allowed buffer modes are: "c", "fortran", "full", "strided" (as a compile-time string)z#ndim must be a non-negative integerz0dtype must be "object", numeric type or a structz"%s" must be a booleanNc                 $    |t           }t          j        |||d          \  }}t          |          t          k    r!t          |d         d         t                    i |                                D ].\  }\  }}|t          vrt          |t          |z            ||<   /t          t          |          D ]J\  }\  }}|t          vrt          |t          |z            |v rt          |t          |z            ||<   Kt          D ]=}|vr7	 ||         |<   # t          $ r |rt           t          |z            Y 9w xY w>                    d          }	|	r|	j        rt           t                                         d          }
|
r0t#          |
t$                    r|
dk     rt           t&                                        d	          }|r|d
vrt           t(                     fd} |d            |d           S )aO  
    Must be called during type analysis, as analyse is called
    on the dtype argument.

    posargs and dictargs should consist of a list and a dict
    of tuples (value, pos). Defaults should be a dict of values.

    Returns a dict containing all the options a buffer can have and
    its value (with the positions stripped).
    N)r   rN   )type_env	type_argsr   rN   rP   r   rl   )ro   stridedcfortranc                                          |           }t          |t                    st          t          | z            d S r7   )getr$   boolr   ERR_BUF_BOOL)r4   r   	globalposoptionss     r   assert_boolz+analyse_buffer_options.<locals>.assert_bool   sE    KK!T"" 	?y,*=>>>	? 	?r   rm   rn   )buffer_defaultsr
   interpret_compiletime_optionsrJ   buffer_positional_options_countr   ERR_BUF_TOO_MANYrI   buffer_optionsERR_BUF_OPTION_UNKNOWNzipERR_BUF_DUPKeyErrorERR_BUF_MISSINGrx   is_extension_typeERR_BUF_DTYPEr$   intERR_BUF_NDIMERR_BUF_MODE)r{   envposargsdictargsdefaultsneed_completer4   valuer?   rN   rP   rl   r}   r|   s   `            @r   analyse_buffer_optionsr   |   s    "#AC<A A AGX 7||55572;q>+;<<<G&nn..  luc~%%s$:T$ABBB!.'::  luc~%%s$:T$ABBB7??sK$$6777  J JwJ ( J J J  J&y/D2HIIIJ JJ  KK  E 5( 59m444;;vD 4Zc** 4dQhh9l333;;vD 4T@@@9l333? ? ? ? ? ?
 K"###KNs   D$EEc                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	BufferEntryc                     || _         |j        | _        |j        j        j        | _        d| j        z  | _        |j        j        | _        |                                  d S )Nz%s.rcbuffer->pybuffer.buf)	r5   r1   rW   buflocal_nd_varr>   buf_ptrbuffer_ptr_typebuf_ptr_typeinit_attributes)r+   r5   s     r   __init__zBufferEntry.__init__   sU    
J	%5;
2TZ?!J6r   c                     |                                  | _        |                                 | _        |                                 | _        d S r7   )get_buf_shapevarsshapeget_buf_stridevarsstridesget_buf_suboffsetvars
suboffsetsr+   s    r   r   zBufferEntry.init_attributes   s?    ++--
..004466r   c                 ,    |                      d          S )Nz%s.diminfo[%d].suboffsets_for_all_ndimr   s    r   r   z!BufferEntry.get_buf_suboffsetvars   s    !!"=>>>r   c                 ,    |                      d          S )Nz%s.diminfo[%d].stridesr   r   s    r   r   zBufferEntry.get_buf_stridevars   s    !!":;;;r   c                 ,    |                      d          S )Nz%s.diminfo[%d].shaper   r   s    r   r   zBufferEntry.get_buf_shapevars   s    !!"8999r   c                 R      fdt           j        j                  D             S )Nc                 (    g | ]}j         |fz  S r   )r>   )r   isr+   s     r   r   z-BufferEntry._for_all_ndim.<locals>.<listcomp>   s$    CCCTZO#CCCr   )ranger1   rP   )r+   r   s   ``r   r   zBufferEntry._for_all_ndim   s-    CCCCCU49>-B-BCCCCr   c           	         g }| j         j        }| j         j        }|dk    rt          ||                                 |                                           D ]E\  }}}|                    |           |                    |           |                    |           Fd|z  }	t          }
n|dk    rd|z  }	t          }
n(|dk    rd|z  }	t          }
n|dk    rd|z  }	t          }
nJ t          ||                                           D ]/\  }}|                    |           |                    |           0|	|j        j        vrH|j        j                            |	           |j        d
         }|j        d         } |
|||	|           | j                                        }|	d|d| j        dd                    |          d}|S )Nro   z__Pyx_BufPtrFull%ddrt   z__Pyx_BufPtrStrided%ddru   z__Pyx_BufPtrCContig%ddrv   z__Pyx_BufPtrFortranContig%ddFutility_code_protoutility_code_def)r4   nd(, ))r1   rP   rl   r   r   r   appendbuf_lookup_full_codebuf_lookup_strided_codebuf_lookup_c_codebuf_lookup_fortran_codeglobalstateutility_codesaddr   empty_declaration_coder   r   )r+   codeindex_cnamesparamsr   rl   r   r   ofuncnamefuncgen	protocodedefcodebuf_ptr_type_codeptrcodes                  r   generate_buffer_lookup_codez'BufferEntry.generate_buffer_lookup_code   s    Y^y~6>>|#6688#99;;= = ! !1a a   a   a    ,r1H*GGy  3b813b8+""9B>1L$*A*A*C*CDD ! !1a   a     4+999*..x888()=>I&'9:GGIwX"==== -DDFF&.hh0A0A0A4<<<&*ii&7&7&7&79r   N)
rh   ri   rj   r   r   r   r   r   r   r   r   r   r   r   r      s          7 7 7
? ? ?< < <: : :D D D* * * * *r   r   c                     d}|j         }|dk    r|dz  }n&|dk    r|dz  }n|dk    r|dz  }n|dk    r|d	z  }nJ | j        r|dz  }|S )NPyBUF_FORMATro   z| PyBUF_INDIRECTrt   z| PyBUF_STRIDESru   z| PyBUF_C_CONTIGUOUSrv   z| PyBUF_F_CONTIGUOUSFz| PyBUF_WRITABLE)rl   writable_needed)rW   buffer_typeflagsrl   s       r   	get_flagsr     s    EDv~~##			""	''			''!>5,>#>5Lr   c                 D    | j         }d|j        _        d|j        _        d S NT)rW   r   rC   	rcbuf_var)r5   rW   s     r   used_buffer_aux_varsr     s&    !J&*J# $Jr   c                 T   | j         | j        j        }}|j        j        }ddg}|dk    r|                    d           g }t          | j        j                  D ]%}|D ] }|                    d||||||fz             !&|                    d	                    |                     d S )Nr   r   ro   r   z1%s.diminfo[%d].%s = %s.rcbuffer->pybuffer.%s[%d];r   )
rW   r1   rl   r   r>   r   r   rP   putlnr   )		buf_entryr   rW   rl   pybuffernd_structfldnameslnr   fldnames	            r    put_unpack_buffer_aux_into_scoper     s     !+Y^-@J"287#Hv~~%%%	B9>&''   	 	GIII!1g!7AM     	
 	JJsxx||r   c                 
   | j         }|j        j        }|j        j        }|                    d|z             |                    d|z             |                    d|z             |                    |d|d           d S )Nz%s.pybuffer.buf = NULL;z%s.refcount = 0;z%s.data = NULL;z.rcbuffer = &;)rW   r   r>   r   r   )r5   r   bufauxr   pybuffer_structs        r   put_init_varsr   0  s    F.4&,OJJ(?:;;;JJ!O3444 	JJ #44555JJ'8'8'8///JKKKKKr   c                    | j         }t          || j        || j                  }|                    d           |                    d| j        j                                        z             |                    |                    d|z  |                     |                    d           t          | |           d S )N{'__Pyx_BufFmt_StackElem __pyx_stack[%d];%s == -1})	rW   get_getbuffer_callr>   r1   r   rN   struct_nesting_deptherror_goto_ifr   )r5   r   r?   rW   	getbuffers        r   put_acquire_arg_bufferr   >  s    !J"4j%*MMI 	JJsOOOJJ85:;K;`;`;b;bbcccJJt!!*y"8#>>???JJsOOO %UD11111r   c                     | j                             t                     |                     d|j        j        j        z             d S )N0__Pyx_SafeReleaseBuffer(&%s.rcbuffer->pybuffer);)r   use_utility_codeacquire_utility_coder   rW   r   r>   )r   r5   s     r   put_release_buffer_coder   L  sA    %%&:;;;JJAEDTDdDjjkkkkkr   c                     |j         }t          |j                  }t          ||          }|j        j        }t          | |j                  }| j        	                    t                     dt                      z  S )Nz__Pyx_GetBufferAndValidate(&%(pybuffernd_struct)s.rcbuffer->pybuffer, (PyObject*)%(obj_cname)s, &%(dtype_typeinfo)s, %(flags)s, %(ndim)d, %(cast)d, __pyx_stack))rP   r   rn   r   r   r>   get_type_information_cnamerN   r   r   r   locals)	r   	obj_cnamerW   r   rP   rn   r   r   dtype_typeinfos	            r   r   r   Q  su    D{  Dj+..E"28/k6GHHN%%&:;;;%'-xx0 1r   c           	      (   |j         |j        }}|j        j        }t	          ||          }	                    d                               d|j                                        z             t          d||          }
|r)                    d|z             j	        
                    t          j        d          }                    |d|
|z  d                               d	                    d
|z            z             t          fdt          d          D                       }                    d|z                                 d	                    d|
| z  z            z                                 d|z             j                            t$                                         d                               d                               d|z                                 d                               d|z             |D ]}j	                            |                               d           t)          |                                                   ||                     j	                            |           nω                    d	                    d|
|z  z            z                                 | dt          j        |t          j        d          d|d                                                   |                                         d           t)          |                               d                               d           dS )aJ  
    Generate code for reassigning a buffer variables. This only deals with getting
    the buffer auxiliary structure and variables set up correctly, the assignment
    itself and refcounting is the responsibility of the caller.

    However, the assignment operation may throw an exception so that the reassignment
    never happens.

    Depending on the circumstances there are two possible outcomes:
    - Old buffer released, new acquired, rhs assigned to lhs
    - Old buffer released, new acquired which fails, reaqcuire old lhs buffer
      (which may or may not succeed).
    r   r   z%sr   F
manage_refz = r   	if (%s) {%s < 0c              3   d   K   | ]*}j                             t          j        d           V  +dS )Fr   N)	funcstateallocate_tempr   py_object_type)r   _r   s     r   	<genexpr>z'put_assign_to_buffer.<locals>.<genexpr>  sP       - - .66z7P]b6cc - - - - - -r      zPyErr_Fetch(&%s, &%s, &%s);r   z/Py_XDECREF(%s); Py_XDECREF(%s); Py_XDECREF(%s);z!__Pyx_RaiseBufferFallbackError();z} else {zPyErr_Restore(%s, %s, %s);r   z%s = %s = %s = 0;Py_Nonez; __Pyx_INCREF(Py_None); z.rcbuffer->pybuffer.buf = NULL;N)rW   r1   r   r>   r   r   rN   r   r   r   r   r   
c_int_typeunlikelytupler   r   r   raise_buffer_fallback_coderelease_tempr   error_goto_if_negtypecastr   
error_gotoput)	lhs_cname	rhs_cnamer   is_initializedr?   r   rW   r   r   r   r   retcode_cname	exc_tempsts        `        r   put_assign_to_bufferr  _  sv     (2INJ"28j+..EJJsOOOJJ8;;L;a;a;c;ccddd"4z;GGI *

EHYYZZZ44Z5JW\4]]

	I0E0E0EFGGG

;$--=0H"I"IJKKK
  - - - -#(88- - - - -	

09<===

;zY=R/S!T!TTUUU

DyPQQQ))*DEEE

6777

:

/);<<<

3

&2333 	+ 	+AN''****

3(D999

4))-==>>>##M2222
 	

;zY=R/S!T!TTUUU

II'Z5NPYZZZZ%%%' 	( 	( 	( 	

4??3''((((D999

3JJsOOOOOr   c           
      j   |d         o|}|d         r:|j                             t          j        d          }|                    d|z             t          t          |||                                                     D ]\  }	\  }
}}|
dk    r|                    d|z             |rM|                    |d|d	           |                    d
|                    d|z            ||	fz             n|                    d||	fz             |	                    d           |
dk    rd}nd}|                    d
|                    |d||          ||	fz             |r"|j
                            t                     d}n!|j
                            t                     d}|                    d|                    d|z            z             |                    |d|d           |                    |                    |                     |                    d           |j                             |           nQ|rOt          |||                                           D ]+\  }
}}|
dk    r|                    d|d|d|d	           ,|                     ||          S )ae  
    Generates code to process indices and calculate an offset into
    a buffer. Returns a C string which gives a pointer which can be
    read from or written to at will (it is an expression so caller should
    store it in a temporary if it is used more than once).

    As the bounds checking can have any number of combinations of unsigned
    arguments, smart optimizations etc. we insert it directly in the function
    body. The lookup however is delegated to a inline function that is instantiated
    once per ndim (lookup with suboffsets tend to get quite complicated).

    entry is a BufferEntry
    
wraparoundboundscheckFr   z%s = -1;r   zif (%s < 0) {z += r   zif (%s) %s = %d;r   z%s = %d;z} else  z(size_t)z >=  __Pyx_RaiseBufferIndexErrorNogil__Pyx_RaiseBufferIndexErrorr   z%s != -1r   );r   zif (z < 0) )r   r   r   r  r   	enumerater   r   r  r
  r   r   raise_indexerror_nogilraise_indexerror_coder	  r  r   )r5   index_signedsr   
directivesr?   r   rm   in_nogil_contextfailed_dim_tempdimsignedr>   r   rn   funcs                  r   put_buffer_lookup_coder#    s    ",/D4D-  ,L
 .66z7LY^6__

:/000+4SV[VmVmVoVo5p5p+q+q 	' 	''C'&%{{

?U2333# DJJeeeUUU;<<<JJ1h&677'5.  . / / / / JJz_c,BBCCC###{{!JJ)eeeTT55ABB-& & ' ' ' '  	1--.DEEE5DD--.CDDD0D

;zO/K!L!LLMMM

ooo6777

4??3''(((

3##O4444	 L$'|UE\E\E^E^$_$_ 	L 	L FE5{{


eeeUUUEEEJKKK,,T<@@@r   c                 :    |                      t                     d S r7   )r   buffer_struct_declare_code)r   s    r   r)   r)     s    344444r   c                    d                     d t          |          D                       }|                     d|d|d|d|d	           d                     d t          |          D                       }|                     d	|d
|d           |                    t          d          ||fz  d                     d t          |          D                       z   dz              dS )
    Generates a buffer lookup function for the right number
    of dimensions. The function gives back a void* at the right location.
    r   c                     g | ]
}d |||fz  S )zi%d, s%d, o%dr   r   r   s     r   r   z(buf_lookup_full_code.<locals>.<listcomp>  s#    JJJ1?aAY6JJJr   #define (type, buf, z	) (type)(z
_imp(buf, z))c                     g | ]
}d |||fz  S )z.Py_ssize_t i%d, Py_ssize_t s%d, Py_ssize_t o%dr   r)  s     r   r   z(buf_lookup_full_code.<locals>.<listcomp>  s'    jjj[\JaQRTUYVjjjr   zstatic CYTHON_INLINE void* z_imp(void* buf, r  zf
        static CYTHON_INLINE void* %s_imp(void* buf, %s) {
          char* ptr = (char*)buf;
        r  c                 :    g | ]}t          d           ||||fz  S )zX          ptr += s%d * i%d;
          if (o%d >= 0) ptr = *((char**)ptr) + o%d;
        r   r)  s     r   r   z(buf_lookup_full_code.<locals>.<listcomp>  sK     +0 +0 +0 !" ,2 3 , , 1a|, +0 +0 +0r   z
return ptr;
}N)r   r   r   r   )protodefinr4   r   	macroargsfuncargss         r   r   r     s.    		JJb		JJJKKI	KKKtttYYYX\X\X\^g^g^ghiiiyyjj`efh`i`ijjjkkH	KKKtttXXXVWWW	KK    h  #%'' +0 +0 &+2YY+0 +0 +0 #
 #

           r   c           	          d                     d t          |          D                       }d                     d t          |          D                       }|                     d|d|d|d           d	S )
r'  r   c                     g | ]	}d ||fz  
S zi%d, s%dr   r)  s     r   r   z+buf_lookup_strided_code.<locals>.<listcomp>  s!    ===ajAq6)===r    + c                     g | ]	}d ||fz  
S z	i%d * s%dr   r)  s     r   r   z+buf_lookup_strided_code.<locals>.<listcomp>	  s!    AAA!1v-AAAr   r*  r+  z) (type)((char*)buf + r   N)r   r   r   r.  r/  r4   r   argsoffsets         r   r   r     s     99==599===>>DZZAAuRyyAAABBF	KKKtttTTTSYSYSYZ[[[[[r   c                 :   |dk    r|                      d|z             dS d                    d t          |          D                       }d                    d t          |dz
            D                       }|                      d||||dz
  fz             dS )	z
    Similar to strided lookup, but can assume that the last dimension
    doesn't need a multiplication as long as.
    Still we keep the same signature for now.
    r   .#define %s(type, buf, i0, s0) ((type)buf + i0)r   c                     g | ]	}d ||fz  
S r4  r   r)  s     r   r   z%buf_lookup_c_code.<locals>.<listcomp>  !    AAA!*1v-AAAr   r5  c                     g | ]	}d ||fz  
S r7  r   r)  s     r   r   z%buf_lookup_c_code.<locals>.<listcomp>  s!    IIIa[Aq61IIIr   9#define %s(type, buf, %s) ((type)((char*)buf + %s) + i%d)Nr   r   r   r8  s         r   r   r     s     
QwwDtKLLLLLyyAAuRyyAAABBII5a==IIIJJOSWY]_egilmgmRnnooooor   c                 0   |dk    r|                      d|z             d	S d                    d t          |          D                       }d                    d t          d|          D                       }|                      d|||dfz             d	S )
zB
    Like C lookup, but the first index is optimized instead.
    r   r<  r   c                     g | ]	}d ||fz  
S r4  r   r)  s     r   r   z+buf_lookup_fortran_code.<locals>.<listcomp>"  r>  r   r5  c                     g | ]	}d ||fz  
S r7  r   r)  s     r   r   z+buf_lookup_fortran_code.<locals>.<listcomp>#  s!    HHHa[Aq61HHHr   r@  r   NrA  r8  s         r   r   r     s     
QwwDtKLLLLLyyAAuRyyAAABBHH5B<<HHHIIOSWY]_eghRiijjjjjr   c                 z    | j         rdS | j        rdS | j        s| j        rd}nd}||                                 z   S )Nobjectptrnn_r  )is_pyobjectrO   
is_typedefis_struct_or_unionspecialization_name)rN   rD   s     r   mangle_dtype_namerM  '  s[      	4x	 4u 	u7 	FFF113333r   c                     t          |          }d|z  }d|z  }|j        rdS |                                dk    rJ | j        j        vr j        j                            |            j        d         }g }|j        r/|j        r(|                    |j                   |j	        }|j        (|j
        o|                                }|                                }	|                                rd}n|j        r|j        }
|j        r|
j        }
|
j        }t'          |          dk    sJ  fd	|D             }|                    d
|z  d           |j        r|j                                        }n|                                }t-          ||          D ]3\  }}|                    d|d|j        d|d|j        d	d           4|                    dd           |                    dd           nJ t3          |          }d}d}|t4          j        u rd|	z  }d}nO|j        rd|	z  }d|z  }n=|s|j        rd}n1|j        rd}n'|j        rd}|j        rd}n|j         rd}n
J |            d}||||	d!                    d |D                       pdt'          |          |||f	}|                    ||z  d           |S )ar  
    Output the run-time type information (__Pyx_TypeInfo) for given dtype,
    and return the name of the type info struct.

    Structs with two floats of the same size are encoded as complex numbers.
    One can separate between complex numbers declared as struct or with native
    encoding by inspecting to see if the fields field of the type is
    filled in.
    z__Pyx_TypeInfo_%sz__Pyx_StructFields_%sz<error>Nr   FtypeinfoNULLc                 B    g | ]}t          |j        d z
            S )r   )r   r1   )r   fr   maxdepths     r   r   z.get_type_information_cname.<locals>.<listcomp>a  s;     & & & 0afhlKK & & &r   z'static const __Pyx_StructField %s[] = {T)safez  {&z, "z", offsetof(r   z)},z  {NULL, NULL, 0}z};0z__PYX_IS_UNSIGNED(%s)z'H'z%s ? 'U' : 'I'z'C'z'R'z'S'__PYX_BUF_FLAGS_PACKED_STRUCTz'O'zRstatic const __Pyx_TypeInfo %s = { "%s", %s, sizeof(%s), { %s }, %s, %s, %s, %s };c                 ,    g | ]}t          |          S r   )str)r   r   s     r   r   z.get_type_information_cname.<locals>.<listcomp>  s    555Q#a&&555r   )"rM  is_errorr   r   r   r   is_arrayr   size	base_typerK  can_be_complexr   is_simple_buffer_dtype	is_structr*   is_cv_qualifiedbase_type_scopevar_entriesrJ   r   cv_base_typer   r4   r>   rX  r   c_char_typeis_int
is_complexis_floatpackedrI  r   )r   rN   rS  
namesuffixr4   structinfo_nametypecode
arraysizescomplex_possibledeclcodestruct_scopefieldstypesstruct_typerR  rO  repr   is_unsigned	typegrouptups   ` `                  r   r   r   5  s    #5))J+D-
:O~'ii E$>$>$@$@1}}4#111&**4000#J/
> 	(. (!!%*--- . ( !3N8L8L8N8N//11'')) 	$OO_ 	 ;L$ <+;!-Fv;;????& & & & &$& & &ENNDV]aNbbb$ =#0GGII#::<<"6511 T T8 (!&&&+++qwww HNR  T T T T NN.TN:::NN4dN++++L%jjJ***1H<KII\ 	 1H<K(;6II 	 !1 	 II^ 		 II_ 	 I| 87 	 II%LS/8yy55*55566=#s:+u. 	x#~D111Kr   c                 V    |t          j        | dfi |S t          j        | dfd|i|S )NzBuffer.ccontext)r   loadr   )util_code_namerx  kwargss      r   load_buffer_utilityr|    sC    
EEfEEE!&~z]]7]V\]]]r   )max_dimsBufferStructDeclare)rx  BufferFormatStructsBufferIndexErrorBufferIndexErrorNogilBufferFallbackErrorBufferGetAndValidateBufferFormatCheckTypeInfoToFormat)r   r   r7   ):Visitorr   r   Errorsr   r   r   Coder   r  r	   r
   r   r   r   r   r"   r   r~   r   r   r   r   r   r   r   r   rz   r   r   r   r   r   r   r   r   r   r  r#  r)   r   r   r   r   rM  r   r|  dictrQ   rx  r%  buffer_formats_declare_coder  r  r  r   buffer_format_check_code_typeinfo_to_format_coder   r   r   <module>r     s   $ $ $ $ $ $ " " " " " "             * * * * * * 1 1 1 1 1 1 1 1                                 U U U U U? U U Ut Gf$PUVV"# 6 , 3 l4B'> > > >JD D D D D D D DN   % % %
  &L L L2 2 2l l l
1 1 1E E EP?A ?A ?AD5 5 5     *\ \ \p p p	k 	k 	k4 4 4] ] ] ]~^ ^ ^ ^ $/
0
0
0001FPWXXX 112GHH  ,+,>?? ,,-DEE 001FGG **+A7SSS ../BGTTT  /./ABB   r   