
    h#                    z   S SK Jr  S SKJrJr  S SKJr  S SKrS SK	J
r
JrJr  S SKJrJrJrJrJrJr  \(       a  S SKJr  SS jr      SS jrSS	 jrSS
 jrSS jrS S jr    S!S jrS"S jr    S#S jr    S#S jr S"S jr!S$S jr"S%S jr#S&S jr$S'S jr%S S jr&S(S jr'S)S jr(      S*S jr)S+S jr*g),    )annotations)chainpairwise)TYPE_CHECKINGN)check_code_arraycheck_offset_arraycheck_point_array)	CLOSEPOLYLINETOMOVETO
code_dtypeoffset_dtypepoint_dtypec                    [        U 5        U S   n[        R                  " U[        [        S9n[
        X SS '   [        X SS S-
  '   U$ )zSDetermine codes from offsets, assuming they all correspond to closed polygons.
    dtypeN   )r   npfullr   r   r   r
   )offsetsncodess      A/var/www/html/env/lib/python3.13/site-packages/contourpy/array.pycodes_from_offsetsr      sL     wAGGAvZ0E E#2,&E!"+/L    c                    [        U 5        [        U5        [        R                  " [	        U5      [
        [        S9n[        X SS '   U SS S-
  n[        R                  " XSS    X   :H  SS9n[        X#U   '   U$ )zDetermine codes from offsets and points, using the equality of the start and end points of
each line to determine if lines are closed or not.
r   Nr   r   axis)
r   r	   r   r   lenr   r   r   allr
   )r   pointsr   end_offsetscloseds        r   codes_from_offsets_and_pointsr%      sz     wfGGCKz:E E#2,!"+/KVVF3B<(F,??aHF!*Ef
Lr   c                    [        U 5        [        U 5      n[        R                  " U[        [
        S9n[        US'   [        R                  " U S   U S   :H  5      (       a	  [        US'   U$ )z}Determine codes for a single line, using the equality of the start and end points to
determine if the line is closed or not.
r   r   r   )	r	   r    r   r   r   r   r   r!   r
   )r"   r   r   s      r   codes_from_pointsr'   /   sZ     fFAGGAvZ0EE!H	vvfQi6":%&&b	Lr   c                X    U (       d  [        S5      e[        R                  " U [        S9$ )zAConcatenate a list of codes arrays into a single code array.
    z!Empty list passed to concat_codesr   )
ValueErrorr   concatenater   )list_of_codess    r   concat_codesr,   =   s$     <==>>-z::r   c                ^    U  Vs/ s H	  oc  M  UPM     nnU(       a  [        U5      $ gs  snf )zQConcatenate a list of codes arrays or None into a single code array or None.
    N)r,   )list_of_codes_or_noner   r+   s      r   concat_codes_or_noner/   F   s1     )>S(=uU(=MSM**	 T   **c                  ^ ^ T (       d  [        S5      e[        T 5      n[        R                  " T  Vs/ s H  o"S   PM	     sn[        S9m[        R
                  " T S   /UU 4S j[        US-
  5       5       Q7[        S9nU$ s  snf )zEConcatenate a list of offsets arrays into a single offset array.
    z#Empty list passed to concat_offsetsr   r   r   c              3  F   >#    U  H  nTUS -      S S TU   -   v   M     g7f)r   N ).0i
cumulativelist_of_offsetss     r   	<genexpr>!concat_offsets.<locals>.<genexpr>Y   s,     \Q[Aqs3AB7*Q-GQ[s   !r   )r)   r    r   cumsumr   r*   range)r7   r   r   retr6   s   `   @r   concat_offsetsr=   P   s     >??OAGGBKG|\J>>		]\QVWXYZWZQ[\]C J Hs   Bc                ^    U  Vs/ s H	  oc  M  UPM     nnU(       a  [        U5      $ gs  snf )zUConcatenate a list of offsets arrays or None into a single offset array or None.
    N)r=   )list_of_offsets_or_noner   r7   s      r   concat_offsets_or_noner@   _   s2    
 /F].E7w.EO]o..	 ^r0   c                X    U (       d  [        S5      e[        R                  " U [        S9$ )zBConcatenate a list of point arrays into a single point array.
    z"Empty list passed to concat_pointsr   )r)   r   r*   r   )list_of_pointss    r   concat_pointsrC   k   s$     =>>>>.<<r   c                ^    U  Vs/ s H	  oc  M  UPM     nnU(       a  [        U5      $ gs  snf )zRConcatenate a list of point arrays or None into a single point array or None.
    N)rC   list_of_points_or_noner"   rB   s      r   concat_points_or_nonerG   t   s2    
 ,BX+Af+ANX^,,	 Yr0   c                ^    U  Vs/ s H	  oc  M  UPM     nnU(       a  [        U5      $ gs  snf )znConcatenate a list of points or None into a single point array or None, with NaNs used to
separate each line.
N)concat_points_with_nanrE   s      r   concat_points_or_none_with_nanrJ      s2     ,BX+Af+ANX%n55	 Yr0   c           	        ^ U (       d  [        S5      e[        U 5      S:X  a  U S   $ [        R                  " S[        R                  [
        S9mU S   /[        [        U4S jU SS  5       6 5      Qn [        U 5      $ )zaConcatenate a list of points into a single point array with NaNs used to separate each line.
    z+Empty list passed to concat_points_with_nanr   r   )r      r   c              3  ,   >#    U  H	  nTU4v   M     g 7f)Nr3   )r4   x
nan_spacers     r   r8   )concat_points_with_nan.<locals>.<genexpr>   s     'TASAQASs   N)	r)   r    r   r   nanr   listr   rC   )rB   rO   s    @r   rI   rI      s     FGG
>aa  WWVRVV;?
(+ X'TPQPRAS'T UVX^,,r   c                *   [        U 5        [        U5        [        U5      S::  a  U $ [        R                  " [        R
                  [        R
                  /[        S9n[        R                  " XSS R                  [        R                  5      USS9$ )zNInsert NaNs into a point array at locations specified by an offset array.
    rL   r   r   r   r   r   )
r	   r   r    r   arrayrQ   r   insertastypeint64)r"   r   rO   s      r   insert_nan_at_offsetsrX      sk     fw
7|qXXrvvrvv.kB
yy2!5!5bhh!?RSTTr   c                    [        U 5        [        R                  " [        R                  " U [        :H  5      S   [        U 5      5      R                  [        5      $ )zBDetermine offsets from codes using locations of MOVETO codes.
    r   )r   r   appendnonzeror   r    rV   r   )r   s    r   offsets_from_codesr\      s>     U99RZZ03SZ@GGUUr   c           	         U (       d  [        S5      e[        R                  " S/U  Vs/ s H  n[        U5      PM     sn-   [        S9$ s  snf )z4Determine offsets from lengths of point arrays.
    z)Empty list passed to offsets_from_lengthsr   r   r)   r   r:   r    r   )rB   lines     r   offsets_from_lengthsr`      sA     DEE99aS.A.$CI.AAVVAs   A

c           
         U (       d  [        S5      e[        R                  " S/U  Vs/ s H   n[        R                  " U[        :H  5      PM"     sn-   [
        S9$ s  snf )zHDetermine outer offsets from codes using locations of MOVETO codes.
    z5Empty list passed to outer_offsets_from_list_of_codesr   r   )r)   r   r:   count_nonzeror   r   )r+   r   s     r    outer_offsets_from_list_of_codesrc      sQ     PQQ99aS=Y=%B,,Uf_==YY') )Ys   'A
c           	         U (       d  [        S5      e[        R                  " S/U  Vs/ s H  n[        U5      S-
  PM     sn-   [        S9$ s  snf )z4Determine outer offsets from a list of offsets.
    z7Empty list passed to outer_offsets_from_list_of_offsetsr   r   r   r^   )r7   r   s     r   "outer_offsets_from_list_of_offsetsre      sF     RSS99aS/J/wCLN/JJR^__Js   A
c                   [        U 5        [        R                  " [        R                  " U SS2S4   5      5      S   n[	        U5      S:X  a&  U [        R
                  " S[	        U 5      /[        S94$ [        R                  " XSS9n U[        R                  " [	        U5      5      -  n[        R                  " [	        U5      S-   [        S9nSUS'   XSS& [	        U 5      US'   X4$ )z^Remove NaN from a points array, also return the offsets corresponding to the NaN removed.
    Nr   r   r   rL   r   r   )
r	   r   r[   isnanr    rT   r   deletearangeempty)r"   nan_offsetsr   s      r   
remove_nanrl      s     f**RXXfQTl34Q7K
;1rxxCK 0EEE6Q7ryy[!122#%88C,<Q,>l#S
#"&kr   c                    [        U 5        [        U5        [        U5      S:  a  [        R                  " XSS 5      $ U /$ )z]Split a code array at locations specified by an offset array into a list of code arrays.
    rL   r   r   )r   r   r    r   split)r   r   s     r   split_codes_by_offsetsro      s<     Uw
7|axxq}--wr   c                    [        U 5        [        U5        [        U5      S:  a  [        R                  " XSS 5      $ U /$ )z_Split a point array at locations specified by an offset array into a list of point arrays.
    rL   r   r   )r	   r   r    r   rn   )r"   r   s     r   split_points_by_offsetsrq      s<     fw
7|axx"..xr   c                B   [        U 5        [        R                  " [        R                  " U SS2S4   5      5      S   n[	        U5      S:X  a  U /$ [        R
                  " S/U[	        U 5      /45      n[        U5       VVs/ s H  u  p#XS-   U PM     snn$ s  snnf )z>Split a points array at NaNs into a list of point arrays.
    Nr   r   r   )r	   r   r[   rg   r    r*   r   )r"   rk   ses       r   split_points_at_nanru      s     f**RXXfQTl34Q7K
;1xnnrdK#f+%GH*2;*?@*?$!s1*?@@@s   B)r   cpy.OffsetArrayreturncpy.CodeArray)r   rv   r"   cpy.PointArrayrw   rx   )r"   ry   rw   rx   )r+   list[cpy.CodeArray]rw   rx   )r.   zlist[cpy.CodeArray | None]rw   zcpy.CodeArray | None)r7   zlist[cpy.OffsetArray]rw   rv   )r?   zlist[cpy.OffsetArray | None]rw   zcpy.OffsetArray | None)rB   list[cpy.PointArray]rw   ry   )rF   zlist[cpy.PointArray | None]rw   zcpy.PointArray | None)r"   ry   r   rv   rw   ry   )r   rx   rw   rv   )rB   r{   rw   rv   )r+   rz   rw   rv   )r"   ry   rw   z&tuple[cpy.PointArray, cpy.OffsetArray])r   rx   r   rv   rw   rz   )r"   ry   r   rv   rw   r{   )r"   ry   rw   r{   )+
__future__r   	itertoolsr   r   typingr   numpyr   contourpy.typecheckr   r   r	   contourpy.typesr
   r   r   r   r   r   contourpy._contourpy
_contourpycpyr   r%   r'   r,   r/   r=   r@   rC   rG   rJ   rI   rX   r\   r`   rc   re   rl   ro   rq   ru   r3   r   r   <module>r      s    " %    W W \ \&	 (;	9		=	7		
7

-UVW)`$	 
Ar   