B
    0zf                 @   sp   d Z ddlZddlZdZdd Zdd Zdd	 Zd
d Zdd Zda	e
 Zdd ZedkrlddlZee  dS )aN  
This is a toolkit for determining which module set the "flush to zero" flag.

For details, see the docstring and comments in `identify_ftz_culprit()`.  This module
is defined outside the main Hypothesis namespace so that we can avoid triggering
import of Hypothesis itself from each subprocess which must import the worker function.
    N)1zarchive-pdf-toolszbgfx-pythonzbicleaner-ai-gloveZBTreesZcadbiomZctranslate2ZdyNETZdyNET38Zgeventzglove-python-binaryZhigraZhybridqZikomiaZiohz	jij-cimodZlavavuzlavavu-osmesaZMulticoreTSNEzneural-compressorZnwhyZopenjijZ	openturnsZperfmetricsZpHashPyz
pyace-liteZpyaprZ
pycompadrezpycompadre-serialZPyKEPZpykepzpylimer-toolsZpyquboZpyscfZPyTATzpython-prtreez
qiskit-aerzqiskit-aer-gpuZ
RelStoragezsail-mlZsegmentationZsenteZsinrZsnapmlZsupermanZ	symenginezsystran-alignztexture-toolztsne-mpZxcsfc               C   s   ddkS )Ng       r    r   r   r   [/home/ankuromar296_gmail_com/.local/lib/python3.7/site-packages/_hypothesis_ftz_detector.pyflush_to_zero&   s    r   c             G   sP   dd l }|jddd | }|jt|| f|d}|  | }|  |S )Nr   spawnT)force)targetargs)multiprocessingZset_start_methodQueueProcessr   startgetjoin)fnr   mpqpretvalr   r   r   run_in_process+   s    r   c             G   s   |  ||  d S )N)put)r   r   r   r   r   r   r   7   s    r   c               C   s   t  ttjfS )N)r   setsysmodulesr   r   r   r   always_imported_modules;   s    r   c             C   sL   t tj}yt|  W n tk
r2   dt  fS X t tj| }t |fS )z7Return the set of modules imported transitively by mod.N)r   r   r   	importlibimport_module	Exceptionr   )modbeforeimportsr   r   r   modules_imported_by?   s    
r    c                 s  t rt S tt\} }| r tdt| dd }ttjt }i }x\|rt	||d}|
| tt|\}}|t8 }|r|||< ||M }qF||8 }t| qFW tdd |D   fdd|D }xDt|D ]8}	x2t|D ]&}
|	||
 kr|
||	 kr|
|
 qW qW t	|a t S )	zAFind the modules in sys.modules which cause "mod" to be imported.z3Python is always in FTZ mode, even without imports!c             S   s   | t k| d| fS )zEPrefer known-FTZ modules, then top-level packages, then alphabetical..)KNOWN_EVER_CULPRITScount)namer   r   r   keya   s    z"identify_ftz_culprits.<locals>.key)r%   c             s   s   | ]}|d  V  qdS )r!   Nr   ).0nr   r   r   	<genexpr>y   s    z(identify_ftz_culprits.<locals>.<genexpr>c                s   h | ]}|  s|qS r   )
startswith)r&   k)prefixesr   r   	<setcomp>z   s    z(identify_ftz_culprits.<locals>.<setcomp>)	KNOWN_FTZr   r   RuntimeErrorCHECKED_CACHEupdater   r   r   mindiscardr    tuplesorted)Zalways_enables_ftzZalways_importsr%   
candidatesZtriggering_modulesr   Zenables_ftzr   resultabr   )r+   r   identify_ftz_culpritsP   s6    


r9   __main__)__doc__r   r   r"   r   r   r   r   r    r-   r   r/   r9   __name__Z	grequestsprintr   r   r   r   <module>   s   ;