U
    ¸mœdû  ã                   @   sä   d Z ddlZddlmZ ddlmZ ddlmZm	Z	m
Z
 G dd„ dƒZG dd„ dƒZej d	ejd
ddgdd�ed
ddgƒf¡G dd„ dƒƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZdd„ Zdd„ Zdd„ Zdd„ Zdd „ ZdS )!zE
Tests related to the ``symbol`` attribute of the ABCPolyBase class.
é    N)Úarray)Úassert_equalÚassert_raisesÚassert_c                   @   sv   e Zd ZdZdddgZdd„ Zej dde	fd	e	fd
e
fde
ff¡dd„ ƒZej dd¡dd„ ƒZdd„ Zdd„ Zd
S )ÚTestInitz5
    Test polynomial creation with symbol kwarg.
    é   é   é   c                 C   s   t  | j¡}t|jdƒ d S )NÚx©ÚpolyÚ
PolynomialÚcr   Úsymbol©ÚselfÚp© r   ú[/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numpy/polynomial/tests/test_symbol.pyÚtest_default_symbol   s    zTestInit.test_default_symbol)Ú	bad_inputÚ	exceptionÚ Ú3Nc              	   C   s*   t  |¡� tj| j|d�}W 5 Q R X d S )N©r   )ÚpytestÚraisesr   r   r   )r   r   r   r   r   r   r   Útest_symbol_bad_input   s    zTestInit.test_symbol_bad_inputr   )r
   Zx_1ÚAZxyzu   Î²c                 C   s    t j| j|d�}t|j|ƒ dS )zF
        Values for symbol that should pass input validation.
        r   Nr   )r   r   r   r   r   r   Útest_valid_symbols   s    zTestInit.test_valid_symbolsc              	   C   s0   t j| jdd�}t t¡� d|_W 5 Q R X dS )z2
        'symbol' attribute is read only.
        r
   r   ÚzN)r   r   r   r   r   ÚAttributeErrorr   r   r   r   r   Útest_property-   s    zTestInit.test_propertyc                 C   s0   t j| jdd�}t j|jdd�}t|jdƒ d S )NÚyr   Út)r   r   r   Zcoefr   r   )r   r   Úptr   r   r   Útest_change_symbol5   s    zTestInit.test_change_symbol)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   ÚmarkÚparametrizeÚ
ValueErrorÚ	TypeErrorr   r   r"   r&   r   r   r   r   r      s   
ü

r   c                   @   s@   e Zd Zejdddgdd�Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚTestUnaryOperatorsr   r   r	   r    r   c                 C   s   | j  }t|jdƒ d S ©Nr    ©r   r   r   )r   Únr   r   r   Útest_neg?   s    zTestUnaryOperators.test_negc                 C   s   | j d }t|jdƒ d S ©Né
   r    r1   ©r   Úoutr   r   r   Útest_scalarmulC   s    
z!TestUnaryOperators.test_scalarmulc                 C   s   d| j  }t|jdƒ d S r4   r1   r6   r   r   r   Útest_rscalarmulG   s    
z"TestUnaryOperators.test_rscalarmulc                 C   s   | j d }t|jdƒ d S )Nr	   r    r1   r6   r   r   r   Útest_powK   s    
zTestUnaryOperators.test_powN)
r'   r(   r)   r   r   r   r3   r8   r9   r:   r   r   r   r   r/   <   s
   r/   Úrhsé   é   é   r    r   c                   @   sd   e Zd ZdZejdddgdd�Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTestBinaryOperatorsSameSymbolzc
    Ensure symbol is preserved for numeric operations on polynomials with
    the same symbol
    r   r   r	   r    r   c                 C   s   | j | }t|jdƒ d S r0   r1   ©r   r;   r7   r   r   r   Útest_add^   s    
z&TestBinaryOperatorsSameSymbol.test_addc                 C   s   | j | }t|jdƒ d S r0   r1   r@   r   r   r   Útest_subb   s    
z&TestBinaryOperatorsSameSymbol.test_subc                 C   s   | j | }t|jdƒ d S r0   r1   r@   r   r   r   Útest_polymulf   s    
z*TestBinaryOperatorsSameSymbol.test_polymulc                 C   s"   t | j|ƒD ]}t|jdƒ qd S r0   ©Údivmodr   r   r   r@   r   r   r   Útest_divmodj   s    z)TestBinaryOperatorsSameSymbol.test_divmodc                 C   s   || j  }t|jdƒ d S r0   r1   r@   r   r   r   Ú	test_raddn   s    
z'TestBinaryOperatorsSameSymbol.test_raddc                 C   s   || j  }t|jdƒ d S r0   r1   r@   r   r   r   Ú	test_rsubr   s    
z'TestBinaryOperatorsSameSymbol.test_rsubc                 C   s   || j  }t|jdƒ d S r0   r1   r@   r   r   r   Ú	test_rmulv   s    
z'TestBinaryOperatorsSameSymbol.test_rmulc                 C   s"   t || jƒD ]}t|jdƒ qd S r0   rD   r@   r   r   r   Útest_rdivmodz   s    z*TestBinaryOperatorsSameSymbol.test_rdivmodN)r'   r(   r)   r*   r   r   r   rA   rB   rC   rF   rG   rH   rI   rJ   r   r   r   r   r?   P   s   r?   c                   @   sb   e Zd Zejdddgdd�Zejdddgd	d�Zejejej	ej
ejfZej d
e¡dd„ ƒZdS )Ú"TestBinaryOperatorsDifferentSymbolr   r   r	   r
   r   r<   r=   r>   r#   Úfc                 C   s   t t|| jƒ d S )N)r   r-   Úother)r   rL   r   r   r   Útest_binops_fails„   s    z4TestBinaryOperatorsDifferentSymbol.test_binops_failsN)r'   r(   r)   r   r   r   rM   Ú__add__Ú__sub__Ú__mul__Ú__floordiv__Ú__mod__Zopsr   r+   r,   rN   r   r   r   r   rK      s
   rK   c                   @   s0   e Zd Zejdddgdd�Zdd„ Zdd	„ Zd
S )ÚTestEqualityr   r   r	   r
   r   c                 C   s&   t jdddgdd�}t| j|kƒ d S )Nr   r   r	   r
   r   ©r   r   r   r   ©r   rM   r   r   r   Útest_eqŒ   s    zTestEquality.test_eqc                 C   s(   t jdddgdd�}t| j|k ƒ d S )Nr   r   r	   r#   r   rU   rV   r   r   r   Útest_neq�   s    zTestEquality.test_neqN)r'   r(   r)   r   r   r   rW   rX   r   r   r   r   rT   ‰   s   rT   c                   @   s€   e Zd ZdZejddddgdd�Zdd	„ Zd
d„ Zdd„ Z	e
j ddddgidddgidejif¡dd„ ƒZdd„ Zdd„ ZdS )ÚTestExtraMethodszJ
    Test other methods for manipulating/creating polynomial objects.
    r   r   r	   r   r    r   c                 C   s   | j  ¡ }t|jdƒ d S r0   )r   Úcopyr   r   rV   r   r   r   Ú	test_copy›   s    
zTestExtraMethods.test_copyc                 C   s   | j  ¡ }t|jdƒ d S r0   )r   Ztrimr   r   rV   r   r   r   Ú	test_trimŸ   s    
zTestExtraMethods.test_trimc                 C   s   | j  d¡}t|jdƒ d S )Nr   r    )r   Útruncater   r   rV   r   r   r   Útest_truncate£   s    zTestExtraMethods.test_truncateÚkwargÚdomainiöÿÿÿr5   ÚwindowÚkindc                 C   s   | j jf |Ž}t|jdƒ d S r0   )r   Úconvertr   r   )r   r_   rM   r   r   r   Útest_convert§   s    zTestExtraMethods.test_convertc                 C   s   | j  ¡ }t|jdƒ d S r0   )r   Zintegr   r   rV   r   r   r   Ú
test_integ°   s    
zTestExtraMethods.test_integc                 C   s   | j  ¡ }t|jdƒ d S r0   )r   Zderivr   r   rV   r   r   r   Ú
test_deriv´   s    
zTestExtraMethods.test_derivN)r'   r(   r)   r*   r   r   r   r[   r\   r^   r   r+   r,   Z	Chebyshevrd   re   rf   r   r   r   r   rY   •   s   

ý
rY   c                  C   sD   t jdddgdd�} t jddddgd	d�}| |ƒ}|jd	ks@t‚d S )
Nr	   r   r   r$   r   r=   r   éÿÿÿÿu   Î»_1)r   r   r   ÚAssertionError)r   ÚqÚrr   r   r   Útest_composition¹   s    rk   c                  C   s6   t dƒfd \} }tjj| |ddd�}t|jdƒ d S )Nr5   r   r   r    )Údegr   )Úranger   r   Úfitr   r   )r
   r#   r   r   r   r   Útest_fitÅ   s    ro   c                  C   s(   ddg} t jj| dd�}t|jdƒ d S )Néþÿÿÿr   r    r   )r   r   Z	fromrootsr   r   )Úrootsr   r   r   r   Útest_froomrootsË   s    rr   c                  C   s*   t jjddgddgdd�} t| jdƒ d S )Nrg   r   r=   é   r    )r`   ra   r   )r   r   Úidentityr   r   ©r   r   r   r   Útest_identityÑ   s    rv   c                  C   s    t jjddd�} t| jdƒ d S )Nr	   r    r   )r   r   Zbasisr   r   ru   r   r   r   Ú
test_basisÖ   s    rw   )r*   r   Znumpy.polynomialZ
polynomialr   Z
numpy.corer   Znumpy.testingr   r   r   r   r/   r+   r,   r   r?   rK   rT   rY   rk   ro   rr   rv   rw   r   r   r   r   Ú<module>   s*   1þþ(
$