
    Ti>                         d Z ddlZddlZddlmZmZ ddlmZmZ ddl	m
Z
 ddlZddlmZ ddlmZ  G d d	          Zd
 Zefdee         dee         fdZdS )z!Decorators for Shapely functions.    N)CallableIterable)	lru_cachewraps)unwrap)libUnsupportedGEOSVersionErrorc                       e Zd ZdZd Zd ZdS )requires_geosz,Decorator to require a minimum GEOS version.c                     |                     d          dk    rt          d          t          d |                    d          D                       | _        dS )z8Create a decorator that requires a minimum GEOS version..   z.Version must be <major>.<minor>.<patch> formatc              3   4   K   | ]}t          |          V  d S N)int).0xs     j/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/shapely/decorators.py	<genexpr>z)requires_geos.__init__.<locals>.<genexpr>   s(      @@SVV@@@@@@    N)count
ValueErrortuplesplitversion)selfr   s     r   __init__zrequires_geos.__init__   sV    ==""MNNN@@W]]3-?-?@@@@@r   c                     t           j        | j        k    }t          j                            d          dk    }|r|sS  dj        j        g| j        R  |rt                    fd            }nt                    fd            }|j	        }|re|
                    d          dz   }d}	 |||z            d
k    r|dz  }nn|                    dd                    d
|z            d          |_	        |S )zReturn the wrapped function.SPHINX_DOC_BUILD1z%'{}' requires at least GEOS {}.{}.{}.c                       | i |S r    )argskwargsfuncs     r   wrappedz'requires_geos.__call__.<locals>.wrapped$   s    tT,V,,,r   c                  "    t                    r   r	   )r$   r%   msgs     r   r'   z'requires_geos.__call__.<locals>.wrapped*   s    1#666r   z

r   r   T    z

{}.. note:: {}

)r   geos_versionr   osenvirongetformat__name__r   __doc__findreplace)	r   r&   is_compatibleis_doc_buildr'   docpositionindentr)   s	    `      @r   __call__zrequires_geos.__call__   s_   (DL8z~~&899S@ 	 	K<5<M
 L
 
 
  
	74[[- - - - [- -
 4[[7 7 7 7 [7 o 	xx''!+HFx&()S00aKFF	
 "kk077fcJJA GO r   N)r1   
__module____qualname__r2   r   r:   r#   r   r   r   r      s;        66A A A% % % % %r   r   c                 <     t                      fd            }|S )zEnable multithreading.

    To do this, the writable flags of object type ndarrays are set to False.

    NB: multithreading also requires the GIL to be released, which is done in
    the C extension (ufuncs.c).
    c                  8   d | D             d |                                 D             z   }d |D             }	 |D ]}d|j        _         | i |t          ||          D ]\  }}||j        _        S # t          ||          D ]\  }}||j        _        w xY w)Nc                 f    g | ].}t          |t          j                  r|j        t          k    ,|/S r#   
isinstancenpndarraydtypeobject)r   args     r   
<listcomp>z;multithreading_enabled.<locals>.wrapped.<locals>.<listcomp>K   s@     
 
 
:c2:#>#>
CF9PVCVCVCCVCVCVr   c                 t    g | ]5\  }}|d vr,t          |t          j                  r|j        t          k    3|6S )>   outwherer@   )r   namerF   s      r   rG   z;multithreading_enabled.<locals>.wrapped.<locals>.<listcomp>M   sU     
 
 
c+++3
++ ,	V##	  $##r   c                 &    g | ]}|j         j        S r#   )flags	writeable)r   arrs     r   rG   z;multithreading_enabled.<locals>.wrapped.<locals>.<listcomp>T   s    ???SSY(???r   F)itemsrM   rN   zip)r$   r%   
array_args	old_flagsrO   old_flagr&   s         r   r'   z'multithreading_enabled.<locals>.wrappedI   s    
 

 
 

 
#\\^^
 
 


 @?J???		/! , ,&+	##4(((!$Z!;!; / /X&.	##/Z!;!; / /X&.	##/s   A5 5$B)r   )r&   r'   s   ` r   multithreading_enabledrU   @   s5     4[[/ / / / [/& Nr   should_be_kwargscategoryc                 &     dt           f fd}|S )aS  Show warning if positional arguments are used that should be keyword.

    Parameters
    ----------
    should_be_kwargs : Iterable[str]
        Names of parameters that should be passed as keyword arguments.
    category : type[Warning], optional (default: DeprecationWarning)
        Warning category to use for deprecation warnings.

    Returns
    -------
    callable
        Decorator function that adds positional argument deprecation warnings.

    Examples
    --------
    >>> from shapely.decorators import deprecate_positional
    >>> @deprecate_positional(['b', 'c'])
    ... def example(a, b, c=None):
    ...     return a, b, c
    ...
    >>> example(1, 2)  # doctest: +SKIP
    DeprecationWarning: positional argument `b` for `example` is deprecated. ...
    (1, 2, None)
    >>> example(1, b=2)  # No warnings
    (1, 2, None)
    r&   c                 b    t                     j        }|j        d |j                 }d t	          |          D             fd	D             s S t                    d         t          d          dt          f fd            t                      fd            }|S )Nc                     i | ]\  }}||	S r#   r#   )r   idxrK   s      r   
<dictcomp>z;deprecate_positional.<locals>.decorator.<locals>.<dictcomp>   s    GGGYS$tSGGGr   c                 ,    g | ]}|v |         |fS r#   r#   )r   rK   name_to_idxs     r   rG   z;deprecate_positional.<locals>.decorator.<locals>.<listcomp>   s8     
 
 
{"" %"""r   r   
   n_argsc                 r     fdD             }t          |          dk    rd|d          d}d}d}nmd}d}t          |          d	k    r d
                    d |D                       }n6d                    d |d d         D                       }|d|d          dz  }d| d| dj         d| d| dS )Nc                 &    g | ]\  }}|k     |S r#   r#   )r   r[   rK   r`   s      r   rG   zMdeprecate_positional.<locals>.decorator.<locals>.make_msg.<locals>.<listcomp>   s"    NNNYS$vDr   r+   `r    issarer   z and c              3   "   K   | ]
}d | d V  dS rc   Nr#   r   us     r   r   zLdeprecate_positional.<locals>.decorator.<locals>.make_msg.<locals>.<genexpr>   s*      +C+CHHHH+C+C+C+C+C+Cr   z, c              3   "   K   | ]
}d | d V  dS ri   r#   rj   s     r   r   zLdeprecate_positional.<locals>.decorator.<locals>.make_msg.<locals>.<genexpr>   s*      (E(EaQ(E(E(E(E(E(Er   z, and `zpositional argumentr*   z for `z` z( deprecated. Please use keyword argumentz	 instead.)lenjoinr1   )r`   usedargs_txtplrisaredeprecate_positionsr&   s   `    r   make_msgz9deprecate_positional.<locals>.decorator.<locals>.make_msg   s"   NNNN*=NNND4yyA~~)tAw>>>t99>>&||+C+Cd+C+C+CCCHH#yy(E(E49(E(E(EEEH 5$r( 5 5 55HQc Q QH Q QDM Q QQ QBEQ Q Qr   c                       | i |}t          |           }|k    r t          j         |          d           |S )Nr   )rW   
stacklevel)rn   warningswarn)r$   r%   resultnrW   r&   ru   	warn_froms       r   wrapperz8deprecate_positional.<locals>.decorator.<locals>.wrapper   sO    T4*6**FD		A9}}hhqkkHKKKKMr   )	r   __code__co_varnamesco_argcount	enumerateminr   r   r   )
r&   code	pos_namesr}   rt   ru   r^   r|   rW   rV   s
   `   @@@@r   	decoratorz'deprecate_positional.<locals>.decorator   s   d||$ $%7t'7%78	GG)I2F2FGGG
 
 
 
(
 
 
 # 	K +,,Q/		2	S 	 	 	 	 	 	 
	* 
t	 	 	 	 	 	 	 
	 r   )r   )rV   rW   r   s   `` r   deprecate_positionalr   `   s8    @5 5 5 5 5 5 5 5n r   )r2   r-   rx   collections.abcr   r   	functoolsr   r   inspectr   numpyrB   shapelyr   shapely.errorsr
   r   rU   DeprecationWarningstrtypeWarningr   r#   r   r   <module>r      s   ' ' 				  . . . . . . . . & & & & & & & &                 6 6 6 6 6 6. . . . . . . .b  D 1W WsmW7mW W W W W Wr   