
    ea                        d dl Z d dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
 	 d$dee         deee                  ddfdZdedefdZ ej        d	          Z ej        d
          Z ej        d          Zdee         dee         fdZdee         dee         fdZdee         deeef         fdZdedeeef         dee         fdZ ej        d          Z ej        d          Zdee         dee         fdZdee         dee         fdZdee         dee         fdZdedee         dee         fdZ ej        d          Z ej        d          Zdee         dee         fdZdee         dee         fdZde	e         dee         de fdZ!dee         d e d!e	e         d"e	e         de
ee          ee          f         f
d#Z"dS )%    N)DictListOptionalPatternTupledirpathmodulesreturnc                 p   |g d}| $t           j                            t                    } |D ]}t           j                            | |dz             }t          j        t          j        | |dz                       }t           j                            | |dz             }t           j                            |          r5t          j        |          j        t          j        |          j        k     rt          |d          5 }|
                                }d d d            n# 1 swxY w Y   d                    |          t          |          z   }t          |          r|d         dk    r|dz  }t          |d          5 }|                    |           d d d            n# 1 swxY w Y   d S )	N)reducemove	nonreducenonreduce_axisz_template.cz.crz#line 1 "{}"

w)ospathdirname__file__joinrelpathexistsstatst_mtimeopenreadformattemplatelenwrite)r   r	   moduletemplate_fileposix_templatetarget_filefsrc_strs           :lib/python3.11/site-packages/bottleneck/src/bn_template.pymake_c_filesr*      s    CCC'//(++  Wf}.DEEdi-9O&P&PQQgll7FTM:: GNN;''	&&/"'+2F2F2OOO-%% 	ffhhG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	")).99HW<M<MMw<< 	GBK4//tOG+s## 	qGGG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	! s$   D''D+	.D+	F))F-	0F-	r(   c                    |                                  }g }d}t          |          D ]\  }}|                                                    d          r*|                    d          s|                    |           t          |                                          dk    sd|v r|dz   }t          |          }g }t          |          D ]I\  }}||v r+|                    d                    |dz                        |                    |           Jt          |          }t          |          }t          |          }d                    |          } t          j        dd	|           } | S )
Nr   { z*/   z#line {}r   z\n\s*\n\s*\nz\n\n)
splitlines	enumeratestripendswith
startswithappendr!   setr   repeat_templatingdtype_templatingstring_templatingr   resub)r(   src_listline_numberslast_empty_indildistinct_line_numbersnew_src_lists           r)   r    r    #   so   !!##HLN(## # #17799c"" 	01<<+<+< 	0///qwwyy>>Q$!))UN--L(##  1%%%
 1 1!a% 8 8999A ..H))H **Hii!!Gf_gw77GN    z^/\*\s*repeat\s*=\s*z^/\*\s*repeat endz.*\*\/.*linesc                     d}	 t          | |t          t                    \  }}||n7| ||         }t          |          }| d |         |z   | |dz   d          z   } |}[| S Nr   Tr.   )
next_blockREPEAT_BEGIN
REPEAT_ENDexpand_functions_repeatrC   indexidx0idx1	func_lists        r)   r6   r6   D   s    EulJGG
d<4<$t)$	+I66	etey(5+<< LrB   c                     t          t          |           }t          | d |dz                      }| |dz   d          } d                    |           }t	          ||          }|S Nr.   r   )first_occurenceCOMMENT_ENDrepeat_infor   expand_repeat)rC   idxrepeat_dictfunc_strrN   s        r)   rI   rI   R   sc    
+u
-
-CeIcAgI.//K#'))EyyHh44IrB   c                     d                     |           }t          j        d|          }t          j        |d                   }|S )N z\{.*\}r   )r   r9   findallastliteral_eval)rC   linerepeatrV   s       r)   rS   rS   [   s<    775>>DZ	4((F"%"26!9"="=KrB   rW   rV   c                    fdD             }t          t          |                    dk    rt          d          |d         }g }t          |          D ]K}| d d          }D ]$}|                    ||         |                   }%|                    d|z              Ld                    |                                          }|S )Nc                 :    g | ]}t          |                   S  )r!   ).0keyrV   s     r)   
<listcomp>z!expand_repeat.<locals>.<listcomp>c   s&    ===#K$%%===rB   r.   z(All repeat lists must be the same lengthr   r   rY   )r!   r5   
ValueErrorrangereplacer4   r   r/   )rW   rV   nrepeatsnrepeatrN   r>   r'   rc   s    `      r)   rT   rT   b   s    =======H
3x==QCDDDqkGI7^^ # #QQQK 	4 	4C		#{3/233AA""""##//11IrB   z^/\*\s*dtype\s*=\s*z^/\*\s*dtype endc                     d}	 t          | |t          t                    \  }}||n7| ||         }t          |          }| d |         |z   | |dz   d          z   } |}[| S rE   )rF   DTYPE_BEGIN	DTYPE_ENDexpand_functions_dtyperJ   s        r)   r7   r7   w   s    Euk9EE
d<4<$t)$	*955	etey(5+<< LrB   c                     t          t          |           }t          | d |dz                      }| |dz   d          } d                    |           }t	          ||          }|S rP   )rQ   rR   
dtype_infor   expand_dtypes)rC   rU   dtypesrW   rN   s        r)   rm   rm      sc    
+u
-
-Ciai())F#'))EyyHh//IrB   c                     d                     |           }t          j        d|          }t          |          dk    rt	          d          t          j        |d                   }|S )NrY   z\[.*\]r.   z)expecting exactly one dtype specificationr   )r   r9   rZ   r!   re   r[   r\   )rC   r]   rq   s      r)   ro   ro      s[    775>>DZ	4((F
6{{aDEEEfQi((FMrB   rq   c                     d| vrt          d          g }|D ]]}| d d          }t          |          D ])\  }}|                    d|z  |          }|dk    r|dz   }*|                    d|z              ^|S )NDTYPEzcannot find dtype markerzDTYPE%dr   r   z

)re   r0   rg   r4   )rW   rq   rN   dtyper'   r>   dts          r)   rp   rp      s    h3444I % %QQQKu%% 	 	EAr		)a-,,A1uuH!$$$$rB   z.*MULTILINE STRING BEGIN.*z.*MULTILINE STRING END.*c                     d}	 t          | |t          t                    \  }}||n:| |dz   |         }t          |          }| d |         |z   | |dz   d          z   } |}^| S rE   )rF   STRING_BEGIN
STRING_ENDquote_string)rC   rK   rL   rM   str_lists        r)   r8   r8      s    EulJGG
d<4<D)))etex'%q

*;; LrB   c                     t          t          |                     D ]}d| |         z   dz   dz   | |<   | d         dz   | d<   | S )N"z\nr   ;)rf   r!   )rC   r>   s     r)   rz   rz      sR    3u:: 0 0q>E)C/ab	CE"ILrB   patternc                     t          t          |                    D ]!}t          j        | ||                   r|c S "t	          d          )Nz`pattern` not foundrf   r!   r9   matchre   )r   rC   r>   s      r)   rQ   rQ      sT    3u::  8GU1X&& 	HHH	
*
+
++rB   rK   begin_patternend_patternc                     d }t          |t          |                     D ]N}| |         }t          j        ||          r|}"t          j        ||          r|t	          d          ||fc S OdS )Nz&found end of function before beginningNNr   )rC   rK   r   r   rU   r>   r]   s          r)   rF   rF      s     C5#e**%%  Qx8M4(( 	CCXk4(( 	{ !IJJJ6MMM	 :rB   r   )#r[   r   	posixpathr   r9   typingr   r   r   r   r   strr*   r    compilerG   rH   rR   r6   rI   rS   rT   rk   rl   r7   rm   ro   rp   rx   ry   r8   rz   intrQ   rF   ra   rB   r)   <module>r      s   



 				     				 7 7 7 7 7 7 7 7 7 7 7 7 7 7 CG c],4T#Y,?	   6c c    8 rz122RZ,--
bj%%T#Y 49    49 c    tCy T#s(^    C d38n c    " bj/00BJ*++	DI $s)    $s) S	    d3i DI    C c tCy      rz788RZ344

T#Y 
49 
 
 
 
S	 d3i    ,WS\ ,$s) , , , , ,9 18LSTWL
8C=(3-'(     rB   