
    hZ                     X   S SK JrJr  S SKJr  S SKJrJrJr  S SKJr  SSKJ	r	  S SK
JrJr  S SKJrJr  S S	KJr  S S
KJr  S SKJr  SrSrSrSrSrSrSrSrSrSrSrSrSrSrSr Sr!Sr"Sr#Sr$Sr%S r&\!\"\#\$\%\&S!.r'S"S#S$S%S&S'S!.r(S(r)S)r*S*r+S+r,S,r-S- r. SjS. jr/ SkS/ jr0S0 r1S1 r2S2 r3SlS3 jr4 " S4 S5\Rj                  5      r6S6 r7S7 r8S8 r9S9 r:S: r;SmS; jr< " S< S=5      r= " S> S?\=5      r> " S@ SA\=5      r?SB r@SC rASD rBSE rCSF rDSG rESHSISJSKSLSMSN.rFSO rGSP rHSQ rISR rJSnST jrK SoSSSU.SV jjrLSW rM\,\R                  \-\R                  R                  SXSY.rQSZ rR\L" S[S\\QS]9rSS^ rT\L" S_5      rUS` rVSa rW\L" Sb\QSU9rX\L" Sc\QSU9rYSd rZ\	R                  Se 5       r\\	R                  Sf 5       r]Sg r^Sh r_Sir`gS)p   )CompileErrorerror)	ExprNodes)IntNodeNameNodeAttributeNode)Options   )Utils)UtilityCodeTempitaUtilityCode)CythonUtilityCodeCythonSharedUtilityCode)Buffer)
PyrexTypes)
ModuleNodezStart must not be given.z3Axis specification only allowed in the 'step' slot.z.Step must be omitted, 1, or a valid specifier.z>Cannot specify an array that is both C and Fortran contiguous.zInvalid axis specification.z+Variable was not cimported from cython.viewz=no expressions allowed in axis spec, only names and literals.z<Invalid axis specification for a C/Fortran contiguous array.zdCannot check if memoryview %s is initialized without the GIL, consider using initializedcheck(False)PyBUF_FORMATz#(PyBUF_C_CONTIGUOUS | PyBUF_FORMAT)z#(PyBUF_F_CONTIGUOUS | PyBUF_FORMAT)z%(PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT)PyBUF_FULL_ROPyBUF_RECORDS_RO__Pyx_MEMVIEW_DIRECT__Pyx_MEMVIEW_PTR__Pyx_MEMVIEW_FULL__Pyx_MEMVIEW_CONTIG__Pyx_MEMVIEW_STRIDED__Pyx_MEMVIEW_FOLLOW)directptrfullcontigstridedfollowdpfcs_z{ 0, 0, { 0 }, { 0 }, { 0 } }
memoryview__pyx_memoryview_type__pyx_memoryview_obj__Pyx_memviewslicec                 T    UR                  SU -  5        UR                  SU -  5        g )Nz%s.data = NULL;z%s.memview = NULL;)putln)mv_cnamecodes     T/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Compiler/MemoryView.pyput_init_entryr1   B   s&    JJ 8+,JJ#h./    c           
         UR                   R                  (       d   eUR                  5       =(       d    UR                  5       nU(       a  UR	                  5       nOBUR
                  R                  USS9nUR                  U< SUR                  U5      < S35        [        XXUXVS9  U(       d  UR
                  R                  U5        gg)zEWe can avoid decreffing the lhs if we know it is the first assignmentF
manage_ref = ;)have_gilfirst_assignmentN)typeis_memoryviewsliceresult_in_temp	is_simpleresult	funcstateallocate_tempr-   	result_asput_assign_to_memviewslicerelease_temp)		lhs_cnamelhs_typelhs_posrhsr/   r8   r9   
pretty_rhsrhstmps	            r0   put_acquire_memoryviewslicerJ   K   s     88&&&&##%8J--h5-I

x)@AB yv(0U ##F+ r2   c                     X:X  a  UR                  S5        g U(       d  UR                  XUS9  UR                  5       (       d  UR                  U5        UR                  U < SU< S35        g )Nz&/* memoryview self assignment no-op */r8   r6   r7   )r-   put_xdecrefr<   make_owned_memoryviewslice)rD   rG   	rhs_cnamememviewslicetyper/   r8   r9   s          r0   rB   rB   `   se     	

;<"* 	 	, &&t,JJY	23r2   c                     [        U 5      u  pU(       a  [        $ U(       a  [        $ [        U 6 u  p4SU;   d  SU;   a  [        $ [
        $ )Nr   r   )is_cf_contigmemview_c_contiguousmemview_f_contiguouszipmemview_full_accessmemview_strided_accessspecsis_c_contigis_f_contigaccesspackings        r0   get_buf_flagsr^   r   sF    +E2K##	##5kOF5F?""%%r2   c                     S/U-  nUR                  U R                  5        [        R                  " U R                  U5      $ )Nr   r    )extendaxesr   MemoryViewSliceTypedtype)memoryviewtypenrb   s      r0   insert_newaxesrg      s:    !"Q&DKK##$)).*>*>EEr2   c                     [        U R                  UR                  -
  5      nU R                  UR                  :  a  [        X5      U4$ U [        X5      4$ N)absndimrg   )srcdstrf   s      r0   broadcast_typesrn      sI    CHHsxx A
xx#((c%s**N3***r2   c                    U R                   (       a  U R                  R                  (       a  gU [        R                  L a  gU R
                  (       aJ  U R                  S:X  a:  U R                  R                   H  n[        UR                  5      (       a  M    g   gU R                  =(       d    U R                  =(       a%    US:  =(       a    [        U R                  US-   5      =(       da    U R                  =(       dN    U R                  =(       d;    U R                   =(       d(    U R"                  =(       a    [        U R$                  5      $ )z~
Return whether type dtype can be used as the base type of a
memoryview slice.

We support structs, numeric types and objects
FstructT   r   )
is_complex	real_typeis_intr   c_bint_type	is_structkindscopevar_entriesvalid_memslice_dtyper:   is_erroris_array	base_type
is_numericis_pyobjectis_fused
is_typedeftypedef_base_type)rd   imembers      r0   rz   rz      s     EOO22
&&&5::1kk--F'44 .  	 	M 
 
6AE 
6	eooq1u	5		M
 		M 		M 		M 
			K253J3JK
r2   c                   F    \ rS rSrSrS rS rS rS rS r	SS jr
S	 rS
rg)MemoryViewSliceBufferEntry   z
May be used during code generation time to be queried for
shape/strides/suboffsets attributes, or to perform indexing or slicing.
c                    Xl         UR                  U l        UR                  U l        SU R                  -  U l        U R                   R                  R                  n[
        R                  " U5      U l        U R                  5         g )Nz%s.data)	entryr:   cnamebuf_ptrrd   r   CPtrTypebuf_ptr_typeinit_attributes)selfr   rd   s      r0   __init__#MemoryViewSliceBufferEntry.__init__   s_    
JJ	[[
 4::-

%%&//6r2   c                 $    U R                  S5      $ )N%s.suboffsets[%d]_for_all_ndimr   s    r0   get_buf_suboffsetvars0MemoryViewSliceBufferEntry.get_buf_suboffsetvars   s    !!"566r2   c                 $    U R                  S5      $ )N%s.strides[%d]r   r   s    r0   get_buf_stridevars-MemoryViewSliceBufferEntry.get_buf_stridevars   s    !!"233r2   c                 $    U R                  S5      $ )N%s.shape[%d]r   r   s    r0   get_buf_shapevars,MemoryViewSliceBufferEntry.get_buf_shapevars   s    !!.11r2   c           	          [        U R                  R                  5       VVVs/ s H  u  nu  pEX2U   XE4PM     nnnnU R                  X5      $ s  snnnf ri   )	enumerater:   rb   _generate_buffer_lookup_code)r   r/   index_cnamesdimr\   r]   rb   s          r0   generate_buffer_lookup_code6MemoryViewSliceBufferEntry.generate_buffer_lookup_code   sZ    2;DIINN2KM2K..f 3'92K 	 M00<<Ms   Ac           
      n   U R                   nU R                  R                  R                  5       nU H  u  pgpSU R                  U4-  n
SU R                  U4-  nSU R                  U4-  n[        X5      nUS;   a3  UR                  R                  [        5        SU< SU< SU< SU< S3	nOiUS:X  a  S	U< S
U< SU< S3nSU< SU< S3nOHUS:X  a  SU< S
U< SU< S3nO2US:X  a  S	U< S
U< SU< S3nOUS:X  d   U5       eSU< SU< SU< S3nSXd4-  nM     U(       a  SU< SU< S3$ U$ )zT
Generate a single expression that indexes the memory view slice
in each dimension.
r   r   r   )genericgeneric_contiguousz__pyx_memviewslice_index_full(z, )indirect(z +  * z(*((char **) z) + indirect_contiguousr    
contiguousz((char *) ((( *) z))z( /* dim=%d */ %s )z(()	r   r:   rd   empty_declaration_coder   get_memoryview_flagglobalstateuse_utility_codememviewslice_index_helpers)r   r/   rb   cast_resultbufp	type_declr   indexr\   r]   shapestride	suboffsetflags                 r0   r   7MemoryViewSliceBufferEntry._generate_buffer_lookup_code   s2   
 ||IIOO::<	+/'C"djj#%66E%S(99F+tzz3.??I&v7D88
   112LM-15&)M #+/?48)D..8<eYO"+/? |+1T1+:CT5Q(C;6D? ,0B $-t44r2   c           	      8  ^^ U R                   nTR                  S[        5       -  5        TR                  S[        5       -  5        TR                  X4US9  [	        S U R
                  R                   5       5      n	/ mUU4S jn
SnSnU GH  nUR                  (       a(  S H  u  pTR                  S	X>X4-  5        M     US
-  nM=  US
-  nU R
                  R                  U   u  nnUR                  (       a  [        [        5       5      nSR                  5        HD  n[        UU5      nUR                  (       + =nUSU-   '   U(       a  UR                  5       OSUU'   MF     US   (       d  US   (       d  US   (       d  UUS'   SnO SnTR                  UR                  5      US'   US
-  nOUR                  5       nUS:g  nU(       a#  US:H  nUS:w  a  [        UR                  S5      s  $ [        [        5       [!        US   5      [!        US   5      S9nUS   (       a  TR                  UR                  5      US'   Sn["        R$                  " USUS9u  nnTR'                  U5        GM     T(       a  TR(                  R+                  TS   5        gg)ao  
Slice a memoryviewslice.

indices     - list of index nodes. If not a SliceNode, or NoneNode,
              then it must be coercible to Py_ssize_t

Simply call __pyx_memoryview_slice_memviewslice with the right
arguments, unless the dimension is omitted or a bare ':', in which
case we copy over the shape/strides/suboffsets attributes directly
for that dimension.
z%(dst)s.data = %(src)s.data;z"%(dst)s.memview = %(src)s.memview;rL   c              3   0   #    U  H  u  pUS :H  v   M     g7f)r   N ).0r\   r]   s      r0   	<genexpr>HMemoryViewSliceBufferEntry.generate_buffer_slice_code.<locals>.<genexpr>  s     #]n?6Fh$6ns   c                     > T(       dM  TR                   R                  [        R                  SS9n TR	                  SU -  5        TR                  U 5        TS   $ )NFr4   z%s = -1;    )r?   r@   r   
c_int_typer-   append)suboffset_dimr/   suboffset_dim_temps    r0   get_suboffset_dimPMemoryViewSliceBufferEntry.generate_buffer_slice_code.<locals>.get_suboffset_dim  sP    % $ < <Z=R=R_d < e

:56"))-8%a((r2   r   ))r   r   )stridesr   )
suboffsetsr   z%s.%s[%d] = %d;r   zstart stop stephave_0
have_start	have_stop	have_stepr\   SimpleSlice
ToughSlice
error_gotor   r   z7All preceding dimensions must be indexed and not sliced
wraparoundboundscheck)r   r   
SliceIndexMemoryView_C.ccontextN)r   r-   localsput_incref_memoryviewsliceallr:   rb   is_noneis_slicedictsplitgetattrr>   r   posr   intr   load_as_stringputr?   rC   )r   r/   indicesrm   dst_typer8   have_slices
directivesrl   all_dimensions_directr   r   new_ndimr   attribvaluer\   r]   r"   r&   idxhave_idx	util_namer   r   r'   implr   s    `                         @r0   generate_buffer_slice_code5MemoryViewSliceBufferEntry.generate_buffer_slice_code   s\    jj

1FH<=

7&(BC'''I ##]diinn#] ]	) E}}%WMFJJ0C3QQR &X A1HC"iinnS1OFG~~N*002A!%+C47KK?Hq1~+33::<AaD 3
 ,1[>Q{^ #)AhK -I ,I&*ooeii&@AlOA lln!X-$.G1}$UYY&> ? ? H":l#;< #J}$= >
 ]#&*ooeii&@AlO(	(77	CS]^_GAtHHTNi l NN''(:1(=> r2   )r   r   r   r   r:   N)T)__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r   __static_attributes__r   r2   r0   r   r      s,    	742=
,\W?r2   r   c                 X    [         R                  " U 5      n[         R                  " XXS9$ )N)startstopstep)r   NoneNode	SliceNode)r   nones     r0   empty_slicer  W  s*    c"Ds$(5 5r2   c                    / nSnSnU  Vs/ s H  oUR                   (       d  M  UPM     nn[        U 5      [        U5      -
  nU  H  n[        U[        R                  5      (       aQ  Sn[        UR                  5      n	U(       a  UR                  U	5        MS  X-
  S-   n
UR                  U	/U
-  5        SnMs  U=(       d    UR                  =(       d    UR                   nUR                  U5        M     [        U5      [        U5      -
  nX:  a1  SnX-
  n
UR                  [        U S   R                  5      /U
-  5        XBU4$ s  snf )NFTr   r   )
r   len
isinstancer   EllipsisNoder  r   r   ra   r   )r   rk   r>   seen_ellipsisr   newaxisnewaxes	n_indicesr   
full_slicenslicesresult_lengths               r0   unellipsifyr  ]  s   FMK&-Ag7wgGAGs7|+IeY3344K$UYY/Jj)*Q.zlW45 $%HH5==KMM%   K#g,.M&{72;??34w>?''1 Bs
   EEc                     U S:X  a  US;   a  gU S:X  a  US:X  a  gU S:X  a  US;   a  gU S:X  a  US:X  a  gU S	:X  a  US;   a  g
X4S:X  d   X45       eg)Nr   )r    r!   r   r   r   r   r   r   r   r    r   r   r   r   )r\   r]   s     r0   r   r   }  sz    G'<<	6	g1#	5W(==	5W0$	8	+@ @ $88K6:KK8r2   c                     U S;   d   eSX4-  $ )NCFz!__pyx_memviewslice_is_contig_%s%dr   )contig_typerk   s     r0   get_is_contig_func_namer    s    *$$$.+1DDDr2   c                 R    U S;   d   e[        [        XS9n[        SU[        /S9nU$ )Nr  )rk   r  MemviewSliceCheckContigr   requires)r   template_contextload_memview_c_utilityis_contig_utility)r  rk   r  utilitys       r0   get_is_contig_utilityr#    s8    *$$$DBA$%>/@.ACGNr2   c                     U R                   (       d  U R                  (       a  U(       d  [        XX#5      $ [        XX#5      $ ri   )rZ   r[   ContigSliceIterStridedSliceIter)
slice_typeslice_resultrk   r/   force_strideds        r0   
slice_iterr*    s/    *"8"8-zDD
$EEr2   c                       \ rS rSrS rSrg)	SliceIteri  c                 4    Xl         X l        X@l        X0l        g ri   )r'  r(  r/   rk   )r   r'  r(  rk   r/   s        r0   r   SliceIter.__init__  s    $(		r2   )r/   rk   r(  r'  N)r   r   r   r   r   r   r   r2   r0   r,  r,    s    r2   r,  c                        \ rS rSrS rS rSrg)r%  i  c                   ^  T R                   nUR                  5         T R                  R                  R	                  5       nSR                  U 4S j[        T R                  5       5       5      nUR                  SU-  5        UR                  S5        UR                  U< SU< ST R                  < S35        UR                  S5        g	)
Nr   c              3   F   >#    U  H  nS TR                   U4-  v   M     g7f)r   N)r(  )r   r   r   s     r0   r   .ContigSliceIter.start_loops.<locals>.<genexpr>  s(       ;)9A !/$2C2CQ1G G)9s   !z"Py_ssize_t __pyx_temp_extent = %s;zPy_ssize_t __pyx_temp_idx;z *__pyx_temp_pointer = (r   z.data;zPfor (__pyx_temp_idx = 0; __pyx_temp_idx < __pyx_temp_extent; __pyx_temp_idx++) {__pyx_temp_pointer)
r/   begin_blockr'  rd   r   joinrangerk   r-   r(  )r   r/   r   
total_sizes   `   r0   start_loopsContigSliceIter.start_loops  s    yyOO))@@B	ZZ  ;).tyy)9 ; ;


7*DE

/0

y$"3"35 	6

 . 	/ $r2   c                     U R                   R                  S5        U R                   R                  S5        U R                   R                  5         g )Nz__pyx_temp_pointer += 1;})r/   r-   	end_blockr   s    r0   	end_loopsContigSliceIter.end_loops  s3    		23				r2   r   Nr   r   r   r   r8  r=  r   r   r2   r0   r%  r%    s    $$r2   r%  c                        \ rS rSrS rS rSrg)r&  i  c                 .   U R                   nUR                  5         [        U R                  5       Ha  nX R                  U4nUR                  SU-  5        UR                  SU-  5        UR                  SU-  5        UR                  SU-  5        Mc     UR                  SU R                  -  5        [        U R                  5       H7  nUS:  a  UR                  SX"S-
  4-  5        UR                  S	X"X"4-  5        M9     S
U R                  S-
  -  $ )Nz/Py_ssize_t __pyx_temp_extent_%d = %s.shape[%d];z1Py_ssize_t __pyx_temp_stride_%d = %s.strides[%d];zchar *__pyx_temp_pointer_%d;zPy_ssize_t __pyx_temp_idx_%d;z__pyx_temp_pointer_0 = %s.data;r   z.__pyx_temp_pointer_%d = __pyx_temp_pointer_%d;r   z\for (__pyx_temp_idx_%d = 0; __pyx_temp_idx_%d < __pyx_temp_extent_%d; __pyx_temp_idx_%d++) {z__pyx_temp_pointer_%d)r/   r4  r6  rk   r(  r-   )r   r/   r   ts       r0   r8  StridedSliceIter.start_loops  s   yytyy!A$$a'AJJH1LMJJJQNOJJ59:JJ6:; " 	

4t7H7HHItyy!A1u

KqVWRWjXYJJ 589a|D E	 " '$))a-88r2   c                     U R                   n[        U R                  S-
  SS5       H)  nUR                  SX"4-  5        UR                  S5        M+     UR	                  5         g )Nr   r   z.__pyx_temp_pointer_%d += __pyx_temp_stride_%d;r;  )r/   r6  rk   r-   r<  )r   r/   r   s      r0   r=  StridedSliceIter.end_loops  sQ    yytyy1}b"-AJJG1&PQJJsO . 	r2   r   Nr?  r   r2   r0   r&  r&    s    9.r2   r&  c                 ^    U R                   (       a  SnOSnSU R                  5       < SU< 3$ )Nr%   r$   __pyx_memoryview_copy_slice_r'   )rZ   specialization_suffix)memviewc_or_fs     r0   copy_c_or_fortran_cnamerK    s0     ))+V5 5r2   c                 8   UR                   UR                   :w  aL  UR                   R                  (       a$  UR                   R                  UR                   :X  d  [        U S5        g [	        UR
                  5      [	        UR
                  5      :w  a  [        U S5        g UR                  (       d  UR                  (       d  [        U S5        g UR
                   H  u  p4US:w  d  M  [        U S5          g    UR                  (       a	  Sn[        nOUR                  (       d   eSn[        n[        5       n[        S[        [        UUR                   R                  5       UUR                  [!        U5      [#        UR                   R$                  5      S	9U/S
9$ )Nzdtypes must be the same!z!number of dimensions must be samez%to_memview must be c or f contiguous.r   z2cannot handle 'full' or 'ptr' access at this time.r%   fortranCopyContentsUtility)mode
dtype_declcontig_flagrk   
func_cnamedtype_is_objectr  )rd   is_cv_qualifiedcv_base_typer   r  rb   rZ   r[   rS   rT   _get_copy_contents_new_utilityr   r   r  r   rk   rK  r   r   )r   from_memview
to_memviewr\   r]   rO  rQ  copy_contents_new_utilitys           r0   get_copy_new_utilityrZ    sT   j...##338J8J8W8W[e[k[k8kc-.
<Z__!55c67""j&<&<c:;)..X#KL /
 *%%%%* > @!!''>>@#.z:
 0 0 < <=? ,,
. 
.r2   c                    U R                   R                  nUR                  5         UR                  n[	        S Vs/ s H  nUR                  U5      PM     sn5      n[	        S Vs/ s H  nUR                  U5      PM     sn5      nSu  pxSu  pU	Sp/ n[        U5       GH  u  pUR                  R                  (       d$  [        UR                  R                  [        5      eUR                  R                  (       d$  [        UR                  R                  [        5      eUR                  R                  (       a  UR                  X45        M  [!        UR                  ["        5      (       aY  UR                  R%                  U 5      S:w  a$  [        UR                  R                  [&        5      eUR                  US45        GM+  [!        UR                  [(        [*        45      (       ar  [-        XR                  5      nUR.                  [0        ;   a%  UR                  [0        UR.                     5        GM  [        UR                  R                  [2        5      e[        UR                  R                  [2        5      e   SnS	n[        U5       HF  u  nu  nnUS:X  d  M  U(       a$  [        WR                  R                  [4        5      eUnUS
4X'   SnMH     U(       Ga  U[7        U5      S-
  :X  a  SnO1SnU(       a(  UUS-
     S   S;  a  [        UU   R                  S5      eU(       a<  Sn[        [9        U5      5       H"  u  nu  nnUS;   d  M  [7        U5      U-
  S-
  nM$     US-   n[7        U5      U-
  n[        UUU 5       HS  u  nu  nnUS-   U-   nUS:w  a  [        X   R                  S5      eUS
:X  a  [        X   R                  S5      eUU4X'   MU     U(       a  US   u  nnUS
4US'   [;        U Vs/ s H  oR                  R                  PM     snUUU5        U$ s  snf s  snf s  snf )z
get_axes_specs(env, axes) -> list of (access, packing) specs for each axis.
access is one of 'full', 'ptr' or 'direct'
packing is one of 'contig', 'strided' or 'follow'
)r   r   r   r   r    r!   FFr`   r!   r   cfcontigr   Fr   T)r   r   z>Fortran contiguous specifier must follow an indirect dimensionr   r   r   r   z>Indirect dimension may not follow Fortran contiguous dimensionzDimension may not be contiguous)r   cython_scopeload_cythonscope	viewscopetuplelookupr   r   r   r   r   	START_ERRr  STOP_ERRr  r   r	  r   compile_time_valueSTEP_ERRr   r   _get_resolved_specnameview_constant_to_access_packingINVALID_ERRBOTH_CF_ERRr  reversedvalidate_axes_specs)envrb   cythonscoperb  rj  access_specspacking_specsr[   rZ   default_accessdefault_packing	cf_access
cf_packing
axes_specsr   axisr   
contig_dim	is_contigr\   r]   r   r  ar#   s                            r0   get_axes_specsr}    s    ++**K  "%%I 9; 9 $**40 9; <L ?A ? %++D1 ?A BM  ,K&9#N*HzJt_	zz!!tzz~~	::yy  tyy}}h7799~?@		7++ yy++C0A5"499==(;;y*56		Hm#<==&sII6Ezz<<!!"A%**"MN"499==+>> tyy}}k::5 %: JI"+J"7fgj "499==+>>J%x0JOI #8 TQ&KK*Z!^"<Q"??"R"4
#3#7#7#ce e J*3HZ4H*I&&fg_,!$TS1!4J +J Q4y;&&/
50F&G"C"&'q.3&C!"49==$BC C (""49==#DF F%z2JO 'H  b>DAq[JrND9DDD9"##%
 I;Az :s   P5'P:
P?c                 X    [        U5      [        R                  :  a  [        U S5        gg)NzGMore dimensions than the maximum number of buffer dimensions were used.FT)r  r	   buffer_max_dimsr   )r   rb   s     r0   validate_axesr    s)    
4yG+++c 6 	7r2   c                     S=p[        U 5      S:X  a  U S/:X  a  SnX4$ U S   S:X  a  [        S U S S  5       5      (       a  SnX4$ [        U 5      S:  a%  U S   S:X  a  [        S U SS   5       5      (       a  SnX4$ )	NFr   r  Tr   c              3   *   #    U  H	  oS :H  v   M     g7f)r   r!   Nr   r   ry  s     r0   r   is_cf_contig.<locals>.<genexpr>  s     C
++
   r   c              3   *   #    U  H	  oS :H  v   M     g7fr  r   r  s     r0   r   r    s     B	++	r  )r  r   )rY   rZ   r[   s      r0   rR   rR     s     %%K
5zQ5%9$:: ## )*
*Ccr
CCC ## e*q.!H++Bab	BBB##r2   c                 d    [        U 5      u  pU(       a  gU(       a  gU  H  u  p4US;   d  M    g   g)Nr%   rM  r_  r   r    )rR   rX   s        r0   get_moder    s7    +E2K	 _$ ! r2   )r   r    r`   )r   r    )r   r   r  )r   r   )r   r    r   r   r   r   c                 <   SnSnS=n=n=pSn
[        U5       H  u  nu  pUS:X  d  M  Un
M     [        [        X5      5       H  u  nu  nu  pX;   a  X;   d  [        US5      eUS:X  a  SnOUS	:X  ai  U(       a  [        US
5      eU
S-   [        U5      S-
  4nX;  a8  US:w  a2  U
S-   [        U5      S-
  :w  a  SU-  nOSUS   -  n[        USU-  5      eUS:g  nO3US:X  a-  U(       a  [        US5      eU(       d  U(       d  [        US5      eUS;   d  M  SnM     g )Nr\  )r   r   r   Fr   r   zInvalid axes specification.r    Tr   z1Only one direct contiguous axis may be specified.r   zdimensions %d and %dzdimension %dr   z$Only %s may be contiguous and directr!   zAA memoryview cannot have both follow and strided axis specifiers.z$Invalid use of the follow specifier.r_  )r   rU   r   r  )	positionsrY   rZ   r[   rs  rr  
has_contig
has_followhas_stridedhas_generic_contiglast_indirect_dimensionr   r\   r]   r   valid_contig_dimsdimss                    r0   ro  ro    se   3M,L BGFJFFk "+E"2fU?&)# #3 *33y3H)I%%c$F&(s$ABBiK "3 )A B B !8! ;SZ!^ K+%*Q.#e*q.@14EED),=a,@@D"3(NQU(UVV5J "3(kll;"3(NOO_$K= *Jr2   c                     [        U[        5      (       a  [        X5      $ [        U[        5      (       a  [	        X5      $ [        UR                  [        5      eri   )r	  r   _resolve_NameNoder   _resolve_AttributeNoder   r   rl  )rp  specs     r0   ri  ri    sC    $!! ++	D-	(	(%c00488[11r2   c                 >    U R                  UR                  5      R                  nU R                  R                  R                  nUR                  U5      nUc  [        UR                  [        5      eU$ ! [         a    [        UR                  [
        5      ef = fri   )
rd  rj  AttributeErrorr   r   rl  r   r`  rb  NOT_CIMPORTED_ERR)rp  noderesolved_namerb  r   s        r0   r  r    s    2

499-22 ((22I]+E}488%677L  2488[112s   %A7 7%Bc                    / n[        U[        5      (       a?  UR                  SUR                  5        UR                  n[        U[        5      (       a  M?  [        U[
        5      (       a  UR                  SUR                  5        O[        UR                  [        5      eUS S nU(       d   eU nU HQ  nUR                  U5      nU(       a  UR                  (       d  [        UR                  SU-  5      eUR                  nMS     UR                  US   5      nU(       d  [        UR                  SUS   -  5      eU$ )Nr   r   zundeclared name not builtin: %szNo such attribute '%s')r	  r   insert	attributeobjr   rj  r   r   EXPR_ERRrd  	as_module)rp  r  pathmodnamesrx   modnamemodr   s           r0   r  r    s   D
T=
)
)At~~&xx T=
)
) $!!Atyy!488X..CRyHO8Ell7##--HH?'IK K  LLb"E488%=R%HIILr2   Nc                 6    [         R                  " U S4SU0UD6$ )NzMemoryView.pyxr   )r   load)util_code_namer   kwargss      r0   load_memview_cy_utilityr    s*    !!.2B =*1=5;= =r2   r   c                h    Uc  [         R                  " X40 UD6$ [        R                  " X4SU0UD6$ )Nr   )r   r  r   )r  util_code_filenamer   r  s       r0   r   r   "  sH     MfMM!&&~ B/6B:@B 	Br2   c                     U R                   R                  (       a  g U R                   R                  nUR                  5         SUR                  R                  S5      l        g )NTarray_cwrapper)r   shared_utility_qualified_namer`  ra  rb  rd  used)rp  r`  s     r0   use_cython_array_utility_coder  ,  sG    
{{00;;++L!!#;?L!!"238r2   rq   )memview_struct_namemax_dimsmemviewslice_namememslice_initTHREAD_LOCKS_PREALLOCATEDc                  $    [        S[        / S9n U $ )NMemviewSliceStructr  r   r  )memviewslice_declare_codes    r0   _get_memviewslice_declare_coder  ;  s     6 $! %$r2   AtomicszSynchronization.c)r  r   c                 \    [        S[        [        [        R                  S9U [
        /S9nU$ )NMemviewSliceInit)BUF_MAX_NDIMSr  )r   r   r  r	   r  atomic_utility)r  memviewslice_init_codes     r0   _get_memviewslice_init_coder  E  s4    3%W5L5LM+  "!r2   MemviewSliceIndexc                  4    [        S[        R                  /S9$ )NBufferFormatFromTypeInfo)r  )r  r   _typeinfo_to_format_coder   r2   r0   _get_typeinfo_to_format_coder  P  s    ""f.M.M-NP Pr2   c                 D    U (       a  [        SU [        / S9$ [        5       $ )NzBufferFormatFromTypeInfo.pxdr  r  )r   r  r  r  s    r0   get_typeinfo_to_format_coder  T  s)    $&*)-	 	 ,--r2   MemviewSliceIsContigOverlappingSlicesc                  $    [        S[        / S9n U $ )NMemviewSliceCopyTemplater  r  )rY  s    r0   rV  rV  a  s     6" !
 %$r2   c            
      $   [        5       n [        U 5      n[        5       n[        S[        [
        R                  [
        R                  U[        [        U/S9nU R                  R                  U5        UR                  R                  U5        X14$ )NzView.MemoryViewr  )r  r  rV  r  r  r   buffer_struct_declare_codebuffer_formats_declare_coder!  overlapping_utilityr  r   )r  r  rY  memoryview_utility_codes       r0   _get_memoryview_utility_coder  i  s     > @89RS > @5$5566*%'- &&--.EF&&--.EF"::r2   c                    [        5       n[        U5      n[        5       n[        SU [        [
        R                  [
        R                  U/S9nUR                  R                  U5        UR                  R                  U5        XB4$ )NzMemoryView.pxdr  )
r  r  rV  r   r  r   r  r  r  r   )r  r  r  rY  shared_utility_codes        r0   #_get_memoryview_shared_utility_coder  ~  s     > @89RS > @1%)1122&		 &&--.AB&&--.AB88r2   c                 F    U (       a  [        U 5      S   $ [        5       S   $ )Nr   r  r  r  s    r0   get_view_utility_coder    %    $23PQRSTT+-a00r2   c                 F    U (       a  [        U 5      S   $ [        5       S   $ )Nr   r  r  s    r0   get_memviewslice_init_coder    r  r2   )arrayr(   r  r   r    r   r   r   )FTr]  )r   )Fri   )r   )aErrorsr   r    r   r   r   r   r	   r   Coder   r   r   r   r   r   r   re  rf  rh  rm  rl  r  r  CF_ERRERR_UNINITIALIZEDformat_flagrS   rT   memview_any_contiguousrV   rW   MEMVIEW_DIRECTMEMVIEW_PTRMEMVIEW_FULLMEMVIEW_CONTIGMEMVIEW_STRIDEDMEMVIEW_FOLLOW_spec_to_const_spec_to_abbrevmemslice_entry_initmemview_namememview_typeptr_cnamememview_objstruct_cnamememviewslice_cnamer1   rJ   rB   r^   rg   rn   rz   BufferEntryr   r  r  r   r  r#  r*  r,  r%  r&  rK  rZ  r}  r  rR   r  rk  ro  ri  r  r  r  r   r  r  rc   default_valuer  r  r  r  r   r  r  r!  r  rV  cached_functionr  r  r  r  view_utility_allowlistr   r2   r0   <module>r     s   '  7 7   1 C   &	@;N+A J	GC  < < @ % + '$%'(' "!"!
  6 / 0 ) 0 BF,, AF4$& F+Bc?!3!3 c?L5(@ E
F i 2y B5%.Pod$( 211000# , \2>=
 ,<B B@ 3''+33AA!" % ("5?OQ" 44GH P. ++AK[\ ,-@JZ[ % ; ;( 9 9$111 r2   