a
    p=ic=                  
   @   sb  d dl Z d dlmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ G dd dZG dd	 d	ZG d
d dZdd Zdd Ze jdeeddeddgeddfeddeddgeddfeededdgeddffdd Ze jdeg dedd feddddggedd!ffd"d# ZG d$d% d%ZG d&d' d'ZG d(d) d)ZdS )*    N)arrayarangeprintoptions)assert_equalassert_)Fraction)Decimalc                   @   sZ  e Zd Zejddddd Zejdg ddfg d	d
feddffdd Z	ejdg ddfg d	dfeddffdd Z
ejdg ddfg d	dfeddffdd Zejdg ddfg d	dfeddffdd Zejdg ddfg d	dfedd ffd!d" Zejdg dd#fg d	d$fedd%ffd&d' Zd(S ))TestStrUnicodeSuperSubscriptsclassTscopeZautousec                 C   s   t d d S Nunicodepolyset_default_printstyleself r   u/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/numpy/polynomial/tests/test_printing.pyuse_unicode   s    z)TestStrUnicodeSuperSubscripts.use_unicodeinptgt            1.0 + 2.0·x¹ + 3.0·x²r   r   r    u%   -1.0 + 0.0·x¹ + 3.0·x² - 1.0·x³   u   0.0 + 1.0·x¹ + 2.0·x² + 3.0·x³ + 4.0·x⁴ + 5.0·x⁵ + 6.0·x⁶ + 7.0·x⁷ +
8.0·x⁸ + 9.0·x⁹ + 10.0·x¹⁰ + 11.0·x¹¹c                 C   s   t t|}t|| d S Nstrr   
Polynomialr   r   r   r   resr   r   r   test_polynomial_str   s    z1TestStrUnicodeSuperSubscripts.test_polynomial_str!   1.0 + 2.0·T₁(x) + 3.0·T₂(x)u1   -1.0 + 0.0·T₁(x) + 3.0·T₂(x) - 1.0·T₃(x)u   0.0 + 1.0·T₁(x) + 2.0·T₂(x) + 3.0·T₃(x) + 4.0·T₄(x) + 5.0·T₅(x) +
6.0·T₆(x) + 7.0·T₇(x) + 8.0·T₈(x) + 9.0·T₉(x) + 10.0·T₁₀(x) + 11.0·T₁₁(x)c                 C   s   t t|}t|| d S r"   r$   r   	Chebyshevr   r&   r   r   r   test_chebyshev_str   s    z0TestStrUnicodeSuperSubscripts.test_chebyshev_stru!   1.0 + 2.0·P₁(x) + 3.0·P₂(x)u1   -1.0 + 0.0·P₁(x) + 3.0·P₂(x) - 1.0·P₃(x)u   0.0 + 1.0·P₁(x) + 2.0·P₂(x) + 3.0·P₃(x) + 4.0·P₄(x) + 5.0·P₅(x) +
6.0·P₆(x) + 7.0·P₇(x) + 8.0·P₈(x) + 9.0·P₉(x) + 10.0·P₁₀(x) + 11.0·P₁₁(x)c                 C   s   t t|}t|| d S r"   r$   r   Legendrer   r&   r   r   r   test_legendre_str'   s    z/TestStrUnicodeSuperSubscripts.test_legendre_stru!   1.0 + 2.0·H₁(x) + 3.0·H₂(x)u1   -1.0 + 0.0·H₁(x) + 3.0·H₂(x) - 1.0·H₃(x)u   0.0 + 1.0·H₁(x) + 2.0·H₂(x) + 3.0·H₃(x) + 4.0·H₄(x) + 5.0·H₅(x) +
6.0·H₆(x) + 7.0·H₇(x) + 8.0·H₈(x) + 9.0·H₉(x) + 10.0·H₁₀(x) + 11.0·H₁₁(x)c                 C   s   t t|}t|| d S r"   r$   r   Hermiter   r&   r   r   r   test_hermite_str2   s    z.TestStrUnicodeSuperSubscripts.test_hermite_stru#   1.0 + 2.0·He₁(x) + 3.0·He₂(x)u4   -1.0 + 0.0·He₁(x) + 3.0·He₂(x) - 1.0·He₃(x)u   0.0 + 1.0·He₁(x) + 2.0·He₂(x) + 3.0·He₃(x) + 4.0·He₄(x) + 5.0·He₅(x) +
6.0·He₆(x) + 7.0·He₇(x) + 8.0·He₈(x) + 9.0·He₉(x) + 10.0·He₁₀(x) +
11.0·He₁₁(x)c                 C   s   t t|}t|| d S r"   r$   r   HermiteEr   r&   r   r   r   test_hermiteE_str=   s    	z/TestStrUnicodeSuperSubscripts.test_hermiteE_stru!   1.0 + 2.0·L₁(x) + 3.0·L₂(x)u1   -1.0 + 0.0·L₁(x) + 3.0·L₂(x) - 1.0·L₃(x)u   0.0 + 1.0·L₁(x) + 2.0·L₂(x) + 3.0·L₃(x) + 4.0·L₄(x) + 5.0·L₅(x) +
6.0·L₆(x) + 7.0·L₇(x) + 8.0·L₈(x) + 9.0·L₉(x) + 10.0·L₁₀(x) + 11.0·L₁₁(x)c                 C   s   t t|}t|| d S r"   r$   r   Laguerrer   r&   r   r   r   test_laguerre_strI   s    z/TestStrUnicodeSuperSubscripts.test_laguerre_strN)__name__
__module____qualname__pytestfixturer   markparametrizer   r(   r,   r/   r2   r5   r8   r   r   r   r   r	      sL   























r	   c                   @   sZ  e Zd Zejddddd Zejdg ddfg d	d
feddffdd Z	ejdg ddfg d	dfeddffdd Z
ejdg ddfg d	dfeddffdd Zejdg ddfg d	dfeddffdd Zejdg ddfg d	dfedd ffd!d" Zejdg dd#fg d	d$fedd%ffd&d' Zd(S ))TestStrAsciir
   Tr   c                 C   s   t d d S Nasciir   r   r   r   r   	use_asciiW   s    zTestStrAscii.use_asciir   r   1.0 + 2.0 x**1 + 3.0 x**2r   z%-1.0 + 0.0 x**1 + 3.0 x**2 - 1.0 x**3r!   z0.0 + 1.0 x**1 + 2.0 x**2 + 3.0 x**3 + 4.0 x**4 + 5.0 x**5 + 6.0 x**6 +
7.0 x**7 + 8.0 x**8 + 9.0 x**9 + 10.0 x**10 + 11.0 x**11c                 C   s   t t|}t|| d S r"   r#   r&   r   r   r   r(   [   s    z TestStrAscii.test_polynomial_str1.0 + 2.0 T_1(x) + 3.0 T_2(x)z+-1.0 + 0.0 T_1(x) + 3.0 T_2(x) - 1.0 T_3(x)z0.0 + 1.0 T_1(x) + 2.0 T_2(x) + 3.0 T_3(x) + 4.0 T_4(x) + 5.0 T_5(x) +
6.0 T_6(x) + 7.0 T_7(x) + 8.0 T_8(x) + 9.0 T_9(x) + 10.0 T_10(x) +
11.0 T_11(x)c                 C   s   t t|}t|| d S r"   r*   r&   r   r   r   r,   f   s    	zTestStrAscii.test_chebyshev_strz1.0 + 2.0 P_1(x) + 3.0 P_2(x)z+-1.0 + 0.0 P_1(x) + 3.0 P_2(x) - 1.0 P_3(x)z0.0 + 1.0 P_1(x) + 2.0 P_2(x) + 3.0 P_3(x) + 4.0 P_4(x) + 5.0 P_5(x) +
6.0 P_6(x) + 7.0 P_7(x) + 8.0 P_8(x) + 9.0 P_9(x) + 10.0 P_10(x) +
11.0 P_11(x)c                 C   s   t t|}t|| d S r"   r-   r&   r   r   r   r/   r   s    	zTestStrAscii.test_legendre_strz1.0 + 2.0 H_1(x) + 3.0 H_2(x)z+-1.0 + 0.0 H_1(x) + 3.0 H_2(x) - 1.0 H_3(x)z0.0 + 1.0 H_1(x) + 2.0 H_2(x) + 3.0 H_3(x) + 4.0 H_4(x) + 5.0 H_5(x) +
6.0 H_6(x) + 7.0 H_7(x) + 8.0 H_8(x) + 9.0 H_9(x) + 10.0 H_10(x) +
11.0 H_11(x)c                 C   s   t t|}t|| d S r"   r0   r&   r   r   r   r2   ~   s    	zTestStrAscii.test_hermite_strz1.0 + 2.0 He_1(x) + 3.0 He_2(x)z.-1.0 + 0.0 He_1(x) + 3.0 He_2(x) - 1.0 He_3(x)z0.0 + 1.0 He_1(x) + 2.0 He_2(x) + 3.0 He_3(x) + 4.0 He_4(x) +
5.0 He_5(x) + 6.0 He_6(x) + 7.0 He_7(x) + 8.0 He_8(x) + 9.0 He_9(x) +
10.0 He_10(x) + 11.0 He_11(x)c                 C   s   t t|}t|| d S r"   r3   r&   r   r   r   r5      s    	zTestStrAscii.test_hermiteE_strz1.0 + 2.0 L_1(x) + 3.0 L_2(x)z+-1.0 + 0.0 L_1(x) + 3.0 L_2(x) - 1.0 L_3(x)z0.0 + 1.0 L_1(x) + 2.0 L_2(x) + 3.0 L_3(x) + 4.0 L_4(x) + 5.0 L_5(x) +
6.0 L_6(x) + 7.0 L_7(x) + 8.0 L_8(x) + 9.0 L_9(x) + 10.0 L_10(x) +
11.0 L_11(x)c                 C   s   t t|}t|| d S r"   r6   r&   r   r   r   r8      s    	zTestStrAscii.test_laguerre_strN)r9   r:   r;   r<   r=   rC   r>   r?   r   r(   r,   r/   r2   r5   r8   r   r   r   r   r@   U   sL   























r@   c                   @   sX   e Zd Zejddddd Zdd Zdd	 Zd
d Zdd Z	ej
dddd ZdS )TestLinebreakingr
   Tr   c                 C   s   t d d S rA   r   r   r   r   r   rC      s    zTestLinebreaking.use_asciic                 C   s2   t g d}ttt|d tt|d d S )N)[rG   rG     r   J   zJ123456789.0 + 123456789.0 x**1 + 123456789.0 x**2 + 1234.0 x**3 + 1.0 x**4r   r%   r   lenr$   r   pr   r   r   test_single_line_one_less   s
    z*TestLinebreaking.test_single_line_one_lessc                 C   s2   t g d}ttt|d tt|d d S )N)rG   rG   rG   rH   
   K   zK123456789.0 + 123456789.0 x**1 + 123456789.0 x**2 + 1234.0 x**3 +
10.0 x**4rJ   rL   r   r   r   test_num_chars_is_linewidth   s
    z,TestLinebreaking.test_num_chars_is_linewidthc                 C   s<   t g d}ttt|dd d tt|d d S )N)rG   rG   rG   r!   r   rG   
r   rI   z[123456789.0 + 123456789.0 x**1 + 123456789.0 x**2 + 12.0 x**3 + 1.0 x**4 +
123456789.0 x**5)r   r%   r   rK   r$   splitrL   r   r   r   6test_first_linebreak_multiline_one_less_than_linewidth   s    zGTestLinebreaking.test_first_linebreak_multiline_one_less_than_linewidthc                 C   s    t g d}tt|d d S )N)rG   rG   rG   {   r   rG   z\123456789.0 + 123456789.0 x**1 + 123456789.0 x**2 + 123.0 x**3 +
1.0 x**4 + 123456789.0 x**5)r   r%   r   r$   rL   r   r   r   +test_first_linebreak_multiline_on_linewidth   s    z<TestLinebreaking.test_first_linebreak_multiline_on_linewidth)lwr   ))rP   z0.0 + 10.0 x**1 + 200.0 x**2 + 3000.0 x**3 + 40000.0 x**4 +
500000.0 x**5 + 600000.0 x**6 + 70000.0 x**7 + 8000.0 x**8 + 900.0 x**9)-   z0.0 + 10.0 x**1 + 200.0 x**2 + 3000.0 x**3 +
40000.0 x**4 + 500000.0 x**5 +
600000.0 x**6 + 70000.0 x**7 + 8000.0 x**8 +
900.0 x**9)   z0.0 + 10.0 x**1 + 200.0 x**2 + 3000.0 x**3 + 40000.0 x**4 + 500000.0 x**5 + 600000.0 x**6 + 70000.0 x**7 + 8000.0 x**8 + 900.0 x**9c                 C   sn   t g d}t|dB tt|| t|dD ]}tt||k  q6W d    n1 s`0    Y  d S )N)
r   rO      i  i@  i  i'	 ip i@  i  )Z	linewidthrR   )r   r%   r   r   r$   rS   r   rK   )r   rW   r   rM   liner   r   r   test_linewidth_printoption   s    z+TestLinebreaking.test_linewidth_printoptionN)r9   r:   r;   r<   r=   rC   rN   rQ   rT   rV   r>   r?   r\   r   r   r   r   rF      s   
		
rF   c                  C   s   t g d} t g d}t d tt| d tt|d t d tt| d tt|d tt t d W d    n1 s0    Y  d S )	Nr   rB   rD   rE   r   r   r)   Zinvalid_input)	r   r%   r+   r   r   r$   r<   raises
ValueError)rM   cr   r   r   test_set_default_printoptions   s    

r`   c                  C   st   g d} t | }t t| td}t d tt|d tt|d t d tt|d tt|d d	S )
z%Test both numpy and built-in complex.)y              ?y      ?      ?y              @y      @        Zdtyper   u,   1j + (1+1j)·x¹ - (2-2j)·x² + (3+0j)·x³u-   1j + (1+1j)·x¹ + (-2+2j)·x² + (3+0j)·x³rB   z,1j + (1+1j) x**1 - (2-2j) x**2 + (3+0j) x**3z-1j + (1+1j) x**1 + (-2+2j) x**2 + (3+0j) x**3N)r   r%   r   objectr   r   r$   )coefsp1p2r   r   r   test_complex_coefficients   s    


rf   )rc   r   r   r   r      ra   u   1/2 + 3/4·x¹      u   1 + 2·x¹ + 5/7·x²z1.00z2.2u   1.00 + 2.2·x¹ + 3·x²c                 C   s&   t | }t d tt|| d S r   r   r%   r   r   r$   rc   r   rM   r   r   r    test_numeric_object_coefficients  s    

rl   )r   r   fu   1 + 2·x¹ + f·x²u   1 + 2·x¹ + [3, 4]·x²c                 C   s&   t | }t d tt|| dS )zK
    Test coef fallback for object arrays of non-numeric coefficients.
    r   Nrj   rk   r   r   r   #test_nonnumeric_object_coefficients  s    

rn   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )

TestFormatc                 C   s,   t d t g d}tt|dd d S )NrB   r   r   r   r    r   u$   1.0 + 2.0·x¹ + 0.0·x² - 1.0·x³r   r   r%   r   formatrL   r   r   r   test_format_unicode   s    
zTestFormat.test_format_unicodec                 C   s,   t d t g d}tt|dd d S )Nr   rp   rB   z$1.0 + 2.0 x**1 + 0.0 x**2 - 1.0 x**3rq   rL   r   r   r   test_format_ascii%  s
    

zTestFormat.test_format_asciic                 C   s6   t d t g d}tt|d t| d d S )NrB   r   rD   rq   rL   r   r   r   test_empty_formatstr,  s    
zTestFormat.test_empty_formatstrc                 C   sF   t g d}tt t|d W d    n1 s80    Y  d S )Nrp   z.2f)r   r%   r<   r]   r^   rr   rL   r   r   r   test_bad_formatstr2  s    zTestFormat.test_bad_formatstrN)r9   r:   r;   rs   rt   ru   rv   r   r   r   r   ro     s   ro   c                   @   s<   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )TestReprc                 C   s$   t tddg}d}t|| d S )Nr   r   z6Polynomial([0., 1.], domain=[-1,  1], window=[-1,  1]))reprr   r%   r   r   r'   r   r   r   r   r(   9  s    zTestRepr.test_polynomial_strc                 C   s$   t tddg}d}t|| d S )Nr   r   z5Chebyshev([0., 1.], domain=[-1,  1], window=[-1,  1]))rx   r   r+   r   ry   r   r   r   r,   >  s    zTestRepr.test_chebyshev_strc                 C   s$   t tddg}d}t|| d S )Nr   r   z4Legendre([0., 1.], domain=[-1,  1], window=[-1,  1]))rx   r   r.   r   ry   r   r   r   test_legendre_reprC  s    zTestRepr.test_legendre_reprc                 C   s$   t tddg}d}t|| d S )Nr   r   z3Hermite([0., 1.], domain=[-1,  1], window=[-1,  1]))rx   r   r1   r   ry   r   r   r   test_hermite_reprH  s    zTestRepr.test_hermite_reprc                 C   s$   t tddg}d}t|| d S )Nr   r   z4HermiteE([0., 1.], domain=[-1,  1], window=[-1,  1]))rx   r   r4   r   ry   r   r   r   test_hermiteE_reprM  s    zTestRepr.test_hermiteE_reprc                 C   s$   t tddg}d}t|| d S )Nr   r   z0Laguerre([0., 1.], domain=[0, 1], window=[0, 1]))rx   r   r7   r   ry   r   r   r   test_laguerre_reprR  s    zTestRepr.test_laguerre_reprN)	r9   r:   r;   r(   r,   rz   r{   r|   r}   r   r   r   r   rw   8  s   rw   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )TestLatexReprz#Test the latex repr used by Jupyterc                 C   s$   dd |_ z| W |` S |` 0 d S )Nc                 S   s   t | S r"   )r$   )xr   r   r   <lambda>_      z(TestLatexRepr.as_latex.<locals>.<lambda>)Z_repr_latex_scalar_repr_latex_)r   objr   r   r   as_latex[  s    
zTestLatexRepr.as_latexc                 C   s   t g d}t| |d t jg dddgd}t| |d t jg dddgd}t| |d	 t jg dd
dgd}t| |d d S )Nr   z%$x \mapsto 1.0 + 2.0\,x + 3.0\,x^{2}$r   domainzK$x \mapsto 1.0 + 2.0\,\left(1.0 + x\right) + 3.0\,\left(1.0 + x\right)^{2}$g      g      ?zE$x \mapsto 1.0 + 2.0\,\left(2.0x\right) + 3.0\,\left(2.0x\right)^{2}$r    zQ$x \mapsto 1.0 + 2.0\,\left(1.0 + 2.0x\right) + 3.0\,\left(1.0 + 2.0x\right)^{2}$)r   r%   r   r   rL   r   r   r   test_simple_polynomiale  s     



z$TestLatexRepr.test_simple_polynomialc                 C   sH   t g d}t| |d t jg dddgd}t| |d d S )Nr   z?$x \mapsto 1.0\,{T}_{0}(x) + 2.0\,{T}_{1}(x) + 3.0\,{T}_{2}(x)$r    r   r   zZ$x \mapsto 1.0\,{T}_{0}(1.0 + 2.0x) + 2.0\,{T}_{1}(1.0 + 2.0x) + 3.0\,{T}_{2}(1.0 + 2.0x)$)r   r+   r   r   rL   r   r   r   test_basis_funcz  s    

zTestLatexRepr.test_basis_funcc                 C   s"   t g d}t| |d d S )Nr   zB$x \mapsto 1.0\,{He}_{0}(x) + 2.0\,{He}_{1}(x) + 3.0\,{He}_{2}(x)$)r   r4   r   r   rL   r   r   r   test_multichar_basis_func  s    
z'TestLatexRepr.test_multichar_basis_funcN)r9   r:   r;   __doc__r   r   r   r   r   r   r   r   r~   X  s
   
	r~   )r<   Z
numpy.corer   r   r   Znumpy.polynomialZ
polynomialr   Znumpy.testingr   r   	fractionsr   decimalr   r	   r@   rF   r`   rf   r>   r?   rb   rl   rn   ro   rw   r~   r   r   r   r   <module>   s<   JNB

	 