o
    Jf	                     @   sN   d dl Z d dlmZ d dlZd dlmZ d dlmZ G dd dZ	dd Z
dS )	    Nwraps)libUnsupportedGEOSVersionErrorc                   @   s   e Zd Zdd Zdd ZdS )requires_geosc                 C   s4   | ddkrtdtdd |dD | _d S )N.   z.Version must be <major>.<minor>.<patch> formatc                 s   s    | ]}t |V  qd S N)int).0x r   ^/home/deployuser/azure_apps/autowriter/venv/lib/python3.10/site-packages/shapely/decorators.py	<genexpr>   s    z)requires_geos.__init__.<locals>.<genexpr>)count
ValueErrortuplesplitversion)selfr   r   r   r   __init__   s   zrequires_geos.__init__c                    s   t j| jk}tjddk}|r|s S dj jg| jR  |r,t  fdd}n
t fdd}|j	}|rb|
dd }d	}	 |||  dkrR|d7 }nnqE|ddd| d|_	|S )NSPHINX_DOC_BUILD1z%'{}' requires at least GEOS {}.{}.{}.c                     s    | i |S r
   r   argskwargsfuncr   r   wrapped   s   z'requires_geos.__call__.<locals>.wrappedc                     s   t  r
   r   r   )msgr   r   r   !   s   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   )r   r    r   __call__   s6   
zrequires_geos.__call__N)r(   
__module____qualname__r   r1   r   r   r   r   r   
   s    r   c                    s   t   fdd}|S )zPrepare multithreading by setting the writable flags of object type
    ndarrays to False.

    NB: multithreading also requires the GIL to be released, which is done in
    the C extension (ufuncs.c).c               	      s   dd | D dd |  D  }dd |D }z|D ]}d|j_q | i |W t||D ]\}}||j_q-S t||D ]\}}||j_q<w )Nc                 S   s&   g | ]}t |tjr|jtkr|qS r   
isinstancenpndarraydtypeobject)r   argr   r   r   
<listcomp>@   s    z;multithreading_enabled.<locals>.wrapped.<locals>.<listcomp>c                 S   s2   g | ]\}}|d vrt |tjr|jtkr|qS )>   outwherer4   )r   namer:   r   r   r   r;   B   s    

c                 S   s   g | ]}|j jqS r   )flags	writeable)r   arrr   r   r   r;   I   s    F)itemsr?   r@   zip)r   r   
array_args	old_flagsrA   old_flagr   r   r   r   >   s"   	


z'multithreading_enabled.<locals>.wrappedr   )r   r   r   r   r   multithreading_enabled7   s   rG   )r$   	functoolsr   numpyr6   shapelyr   shapely.errorsr   r   rG   r   r   r   r   <module>   s    -