U
    O8c                     @   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   F/tmp/pip-unpacked-wheel-fd_gsd75/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__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   rV   rW   r   r   r   test_neq   s    zTestEquality.test_neqN)r'   r(   r)   r   r   r   rX   rY   r   r   r   r   rU      s   rU   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   rW   r   r   r   	test_copy   s    
zTestExtraMethods.test_copyc                 C   s   | j  }t|jd d S r0   )r   Ztrimr   r   rW   r   r   r   	test_trim   s    
zTestExtraMethods.test_trimc                 C   s   | j d}t|jd d S )Nr   r    )r   truncater   r   rW   r   r   r   test_truncate   s    zTestExtraMethods.test_truncatekwargdomainir5   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   rW   r   r   r   
test_integ   s    
zTestExtraMethods.test_integc                 C   s   | j  }t|jd d S r0   )r   Zderivr   r   rW   r   r   r   
test_deriv   s    
zTestExtraMethods.test_derivN)r'   r(   r)   r*   r   r   r   r\   r]   r_   r   r+   r,   Z	Chebyshevre   rf   rg   r   r   r   r   rZ      s   


rZ   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    rl   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   Z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 )Nr   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 )Nrh   r   r=      r    )ra   rb   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   rU   rZ   rl   ro   rr   rv   rw   r   r   r   r   <module>   s*   1(
$