U
    ?h                     @   sZ   d Z ddlmZmZ G dd dedZG dd deZG dd	 d	eZG d
d deZdS )z/
Defines CPU Options for use in the CPU target
    )ABCMetaabstractmethodc                   @   s0   e Zd ZdZeedddZedddZdS )AbstractOptionValuez2Abstract base class for custom option values.
    returnc                 C   s   dS )z*Returns an encoding of the values
        N selfr   r   H/var/www/html/venv/lib/python3.8/site-packages/numba/core/cpu_options.pyencode
   s    zAbstractOptionValue.encodec                 C   s   | j j d|   dS )N())	__class____name__r   r   r   r   r
   __repr__   s    zAbstractOptionValue.__repr__N)r   
__module____qualname____doc__r   strr   r   r   r   r   r
   r      s   r   )	metaclassc                   @   s:   e Zd ZdZdd Zdd ZeZedddZd	d
 Z	dS )FastMathOptionsz9
    Options for controlling fast math optimization.
    c                 C   s   ddddddddh}t |tr,|j | _n|d	kr>dh| _n|d
krPt | _nvt |trz|| }|rrtd| || _nLt |trt| | }|rtd| dd | D | _nd}t|d S )NfastZnnanZninfZnszZarcpZcontractZafnZreassocTFzUnrecognized fastmath flags: %sc                 S   s   h | ]\}}|r|qS r   r   ).0venabler   r   r
   	<setcomp>0   s      z+FastMathOptions.__init__.<locals>.<setcomp>z<Expected fastmath option(s) to be either a bool, dict or set)	
isinstancer   flagscopyset
ValueErrordictkeysitems)r	   valueZvalid_flagsinvalidmsgr   r   r
   __init__   s6         




zFastMathOptions.__init__c                 C   s
   t | jS N)boolr   r   r   r   r
   __bool__5   s    zFastMathOptions.__bool__r   c                 C   s
   t | jS r(   )r   r   r   r   r   r
   r   :   s    zFastMathOptions.encodec                 C   s    t |t | kr| j|jkS tS r(   )typer   NotImplementedr	   otherr   r   r
   __eq__=   s    zFastMathOptions.__eq__N)
r   r   r   r   r'   r*   __nonzero__r   r   r/   r   r   r   r
   r      s   r   c                   @   s:   e Zd ZdZdZdd Zdd Zdd Zed	d
dZ	dS )ParallelOptionsz7
    Options for controlling auto parallelization.
    )	enabledcomprehension	reductioninplace_binopsetitemnumpystencilfusionprangec                 C   sB  t |trB|| _|| _|| _|| _|| _|| _|| _|| _	|| _
nt |trd| _|dd| _|dd| _|dd| _|dd| _|dd| _|dd| _|dd| _	|d	d| _
|rd
|  }t|nbt |tr2|j| _|j| _|j| _|j| _|j| _|j| _|j| _|j	| _	|j
| _
nd}t|d S )NTr3   r4   r5   r6   r7   r8   r9   r:   z!Unrecognized parallel options: %sz4Expect parallel option to be either a bool or a dict)r   r)   r2   r3   r4   r5   r6   r7   r8   r9   r:   r!   popr"   	NameErrorr1   r    )r	   r$   r&   r   r   r
   r'   J   sF    



zParallelOptions.__init__c                    s    fdd j D S )z"Get values as dictionary.
        c                    s   i | ]}|t  |qS r   )getattr)r   kr   r   r
   
<dictcomp>s   s      z/ParallelOptions._get_values.<locals>.<dictcomp>)	__slots__r   r   r   r
   _get_valuesp   s    zParallelOptions._get_valuesc                 C   s$   t |t | kr |  | kS tS r(   )r+   rA   r,   r-   r   r   r
   r/   u   s    zParallelOptions.__eq__r   c                 C   s   d dd |   D S )Nz, c                 s   s    | ]\}}| d | V  qdS )=Nr   )r   r>   r   r   r   r
   	<genexpr>{   s     z)ParallelOptions.encode.<locals>.<genexpr>)joinrA   r#   r   r   r   r
   r   z   s    zParallelOptions.encodeN)
r   r   r   r   r@   r'   rA   r/   r   r   r   r   r   r
   r1   C   s   &r1   c                   @   s^   e Zd ZdZdd Zedd Zedd Zedd	 Zed
d Z	dd Z
edddZdS )InlineOptionsz*
    Options for controlling inlining
    c                 C   sF   d}t |tr|dkr&d}n
t|d}|r2|| _nd| }t|d S )NF)alwaysneverT__call__z~kwarg 'inline' must be one of the strings 'always' or 'never', or it can be a callable that returns True/False. Found value %s)r   r   hasattr_inliner    )r	   r$   okr&   r   r   r
   r'      s    

zInlineOptions.__init__c                 C   s
   | j dkS )z&
        True if never inline
        rG   rJ   r   r   r   r
   is_never_inline   s    zInlineOptions.is_never_inlinec                 C   s
   | j dkS )z'
        True if always inline
        rF   rL   r   r   r   r
   is_always_inline   s    zInlineOptions.is_always_inlinec                 C   s   | j p
| j S )z2
        True if a cost model is provided
        )rN   rM   r   r   r   r
   has_cost_model   s    zInlineOptions.has_cost_modelc                 C   s   | j S )z
        The raw value
        rL   r   r   r   r
   r$      s    zInlineOptions.valuec                 C   s    t |t | kr| j|jkS tS r(   )r+   r$   r,   r-   r   r   r
   r/      s    zInlineOptions.__eq__r   c                 C   s
   t | jS r(   )reprrJ   r   r   r   r
   r      s    zInlineOptions.encodeN)r   r   r   r   r'   propertyrM   rN   rO   r$   r/   r   r   r   r   r   r
   rE   ~   s   



rE   N)r   abcr   r   r   r   r1   rE   r   r   r   r
   <module>   s
   /;