o
    ʩZh                     @   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g d
ddeg d
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                   @   st   e Zd ZdZg d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   Y/var/www/html/lang_env/lib/python3.10/site-packages/numpy/polynomial/tests/test_symbol.pytest_default_symbol      zTestInit.test_default_symbol)	bad_input	exception 3Nr   c                 C   s@   t | tj| j|d}W d    d S 1 sw   Y  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   sF   t j| jdd}tt d|_W d   dS 1 sw   Y  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g dddZdd Zdd Zdd	 Zd
d Z	dS )TestUnaryOperatorsr   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"   r3   r   outr   r   r   test_scalarmulC      
z!TestUnaryOperators.test_scalarmulc                 C   s   d| j  }t|jd d S r6   r3   r8   r   r   r   test_rscalarmulG   r;   z"TestUnaryOperators.test_rscalarmulc                 C   s   | j d }t|jd d S )Nr
   r"   r3   r8   r   r   r   test_powK   r;   zTestUnaryOperators.test_powN)
r)   r*   r+   r   r   r   r5   r:   r<   r=   r   r   r   r   r1   <   s    r1   rhs         r"   r   c                   @   sb   e Zd ZdZejg d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   c                 C   s   | j | }t|jd d S r2   r3   r   r>   r9   r   r   r   test_add^   r;   z&TestBinaryOperatorsSameSymbol.test_addc                 C   s   | j | }t|jd d S r2   r3   rD   r   r   r   test_subb   r;   z&TestBinaryOperatorsSameSymbol.test_subc                 C   s   | j | }t|jd d S r2   r3   rD   r   r   r   test_polymulf   r;   z*TestBinaryOperatorsSameSymbol.test_polymulc                 C   s"   t | j|D ]}t|jd qd S r2   divmodr   r   r   rD   r   r   r   test_divmodj      z)TestBinaryOperatorsSameSymbol.test_divmodc                 C   s   || j  }t|jd d S r2   r3   rD   r   r   r   	test_raddn   r;   z'TestBinaryOperatorsSameSymbol.test_raddc                 C   s   || j  }t|jd d S r2   r3   rD   r   r   r   	test_rsubr   r;   z'TestBinaryOperatorsSameSymbol.test_rsubc                 C   s   || j  }t|jd d S r2   r3   rD   r   r   r   	test_rmulv   r;   z'TestBinaryOperatorsSameSymbol.test_rmulc                 C   s"   t || jD ]}t|jd qd S r2   rH   rD   r   r   r   test_rdivmodz   rK   z*TestBinaryOperatorsSameSymbol.test_rdivmodN)r)   r*   r+   r,   r   r   r   rE   rF   rG   rJ   rL   rM   rN   rO   r   r   r   r   rC   P   s    rC   c                   @   s^   e Zd Zejg dddZejg d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%   fc                 C   s   t t|| j d S )N)r   r/   other)r   rQ   r   r   r   test_binops_fails   s   z4TestBinaryOperatorsDifferentSymbol.test_binops_failsN)r)   r*   r+   r   r   r   rR   __add____sub____mul____floordiv____mod__opsr   r-   r.   rS   r   r   r   r   rP      s    rP   c                   @   s.   e Zd Zejg dddZdd Zdd ZdS )	TestEqualityr   r   r   c                 C   s$   t jg ddd}t| j|k d S )Nr   r   r   r   r   r   r   r   rR   r   r   r   test_eq   s   zTestEquality.test_eqc                 C   s&   t jg ddd}t| j|k  d S )Nr   r%   r   r[   r\   r   r   r   test_neq   s   zTestEquality.test_neqN)r)   r*   r+   r   r   r   r]   r^   r   r   r   r   rZ      s    rZ   c                   @   s|   e Zd ZdZejg d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      | j  }t|jd d S r2   )r   copyr   r   r\   r   r   r   	test_copy   r;   zTestExtraMethods.test_copyc                 C   r`   r2   )r   Ztrimr   r   r\   r   r   r   	test_trim   r;   zTestExtraMethods.test_trimc                 C   s   | j d}t|jd d S )Nr	   r"   )r   truncater   r   r\   r   r   r   test_truncate   r   zTestExtraMethods.test_truncatekwargdomainir7   windowkindc                 C   s"   | j jdi |}t|jd d S )Nr"   r   )r   convertr   r   )r   rf   rR   r   r   r   test_convert   s   zTestExtraMethods.test_convertc                 C   r`   r2   )r   Zintegr   r   r\   r   r   r   
test_integ   r;   zTestExtraMethods.test_integc                 C   r`   r2   )r   Zderivr   r   r\   r   r   r   
test_deriv   r;   zTestExtraMethods.test_derivN)r)   r*   r+   r,   r   r   r   rb   rc   re   r   r-   r.   Z	Chebyshevrk   rl   rm   r   r   r   r   r_      s    


r_   c                  C   s>   t jg ddd} t jg ddd}| |}|jdksJ d S )N)r
   r	   r   r&   r   )rA   r   r   u   λ_1)r   r   r   )r   qrr   r   r   test_composition   s   rq   c                  C   s6   t dfd \} }tjj| |ddd}t|jd d S )Nr7   r	   r   r"   )degr   )ranger   r   fitr   r   )r   r%   r   r   r   r   test_fit   s   ru   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   rx   c                  C   s*   t jjddgddgdd} t| jd d S )Nrn   r   rA      r"   )rg   rh   r   )r   r   identityr   r   r   r   r   r   test_identity   s   r|   c                  C   s    t jjddd} t| jd d S )Nr
   r"   r   )r   r   Zbasisr   r   r{   r   r   r   
test_basis   s   r}   )r,   r   Znumpy.polynomialZ
polynomialr   Z
numpy.corer   Znumpy.testingr   r   r   r   r1   r-   r.   r   rC   rP   rZ   r_   rq   ru   rx   r|   r}   r   r   r   r   <module>   s,    1
(
$