o
    Pŀg                     @   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   V/var/www/html/myenv/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   x_1A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   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$   r6   r   outr   r   r   test_scalarmulC      
z!TestUnaryOperators.test_scalarmulc                 C   s   d| j  }t|jd d S r9   r6   r;   r   r   r   test_rscalarmulG   r>   z"TestUnaryOperators.test_rscalarmulc                 C   s   | j d }t|jd d S )Nr
   r$   r6   r;   r   r   r   test_powK   r>   zTestUnaryOperators.test_powN)
r,   r-   r.   r   r   r   r8   r=   r?   r@   r   r   r   r   r4   <   s    r4   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 r5   r6   r   rA   r<   r   r   r   test_add^   r>   z&TestBinaryOperatorsSameSymbol.test_addc                 C   s   | j | }t|jd d S r5   r6   rG   r   r   r   test_subb   r>   z&TestBinaryOperatorsSameSymbol.test_subc                 C   s   | j | }t|jd d S r5   r6   rG   r   r   r   test_polymulf   r>   z*TestBinaryOperatorsSameSymbol.test_polymulc                 C   s"   t | j|D ]}t|jd qd S r5   divmodr   r   r   rG   r   r   r   test_divmodj      z)TestBinaryOperatorsSameSymbol.test_divmodc                 C   s   || j  }t|jd d S r5   r6   rG   r   r   r   	test_raddn   r>   z'TestBinaryOperatorsSameSymbol.test_raddc                 C   s   || j  }t|jd d S r5   r6   rG   r   r   r   	test_rsubr   r>   z'TestBinaryOperatorsSameSymbol.test_rsubc                 C   s   || j  }t|jd d S r5   r6   rG   r   r   r   	test_rmulv   r>   z'TestBinaryOperatorsSameSymbol.test_rmulc                 C   s"   t || jD ]}t|jd qd S r5   rK   rG   r   r   r   test_rdivmodz   rN   z*TestBinaryOperatorsSameSymbol.test_rdivmodN)r,   r-   r.   r/   r   r   r   rH   rI   rJ   rM   rO   rP   rQ   rR   r   r   r   r   rF   P   s    rF   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   rB   r'   fc                 C   s   t t|| j d S )N)r   r2   other)r   rT   r   r   r   test_binops_fails   s   z4TestBinaryOperatorsDifferentSymbol.test_binops_failsN)r,   r-   r.   r   r   r   rU   __add____sub____mul____floordiv____mod__opsr   r0   r1   rV   r   r   r   r   rS      s    rS   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   rU   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`   ra   r   r   r   r   r]      s    r]   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 r5   )r   copyr   r   r_   r   r   r   	test_copy   r>   zTestExtraMethods.test_copyc                 C   rc   r5   )r   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domainir:   windowkindc                 C   s"   | j jdi |}t|jd d S )Nr$   r   )r   convertr   r   )r   rj   rU   r   r   r   test_convert   s   zTestExtraMethods.test_convertc                 C   rc   r5   )r   integr   r   r_   r   r   r   
test_integ   r>   zTestExtraMethods.test_integc                 C   rc   r5   )r   derivr   r   r_   r   r   r   
test_deriv   r>   zTestExtraMethods.test_derivN)r,   r-   r.   r/   r   r   r   re   rg   ri   r   r0   r1   	Chebyshevro   rq   rs   r   r   r   r   rb      s    


rb   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   )rD   r   r   u   λ_1)r   r   r   )r   qrr   r   r   test_composition   s   rx   c                  C   s6   t dfd \} }tjj| |ddd}t|jd d S )Nr:   r	   r   r$   )degr   )ranger   r   fitr   r   )r   r'   r   r   r   r   test_fit   s   r|   c                  C   s(   ddg} t jj| dd}t|jd d S )Nr	   r$   r   )r   r   	fromrootsr   r   )rootsr   r   r   r   test_froomroots   s   r   c                  C   s*   t jjddgddgdd} t| jd d S )Nru   r   rD      r$   )rk   rl   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   basisr   r   r   r   r   r   
test_basis   s   r   )r/   r   numpy.polynomial
polynomialr   numpy._corer   numpy.testingr   r   r   r   r4   r0   r1   r   rF   rS   r]   rb   rx   r|   r   r   r   r   r   r   r   <module>   s,    1
(
$