
    Ng-P                     n   d dl mZmZ 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          Z G d	 d
          Z G d d          Zd Zd Zej                            d e edd           edd          ge          df edd edd          ge          df e ed           ed          dge          dff          d             Zej                            d eg de          df eddddgge          dff          d              Z G d! d"          Zej                            d#e
j        d$fe
j        d%fe
j        d&fe
j         d'fe
j!        d(fe
j"        d)ff          d*             Z# G d+ d,          Z$ G d- d.          Z%d/Z& G d0 d1          Z'dS )2    )naninfN)arrayarangeprintoptions)assert_equalassert_)Fraction)Decimalc                      e Zd Z ej        dd          d             Zej                            dg ddfg dd	f ed
          dff          d             Z	ej                            dg ddfg ddf ed
          dff          d             Z
ej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d              Zd!S )"TestStrUnicodeSuperSubscriptsclassTscopeautousec                 .    t          j        d           d S Nunicodepolyset_default_printstyleselfs    `/var/www/html/ai-engine/env/lib/python3.11/site-packages/numpy/polynomial/tests/test_printing.pyuse_unicodez)TestStrUnicodeSuperSubscripts.use_unicode   s    #I.....    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                 h    t          t          j        |                    }t          ||           d S Nstrr   
Polynomialr   r   r   r   ress       r   test_polynomial_strz1TestStrUnicodeSuperSubscripts.test_polynomial_str   1     $/#&&''S#r   !   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                 h    t          t          j        |                    }t          ||           d S r)   r+   r   	Chebyshevr   r-   s       r   test_chebyshev_strz0TestStrUnicodeSuperSubscripts.test_chebyshev_str   s1     $.%%&&S#r   u!   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                 h    t          t          j        |                    }t          ||           d S r)   r+   r   Legendrer   r-   s       r   test_legendre_strz/TestStrUnicodeSuperSubscripts.test_legendre_str(   1     $-$$%%S#r   u!   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                 h    t          t          j        |                    }t          ||           d S r)   r+   r   Hermiter   r-   s       r   test_hermite_strz.TestStrUnicodeSuperSubscripts.test_hermite_str3   s1     $,s##$$S#r   u#   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                 h    t          t          j        |                    }t          ||           d S r)   r+   r   HermiteEr   r-   s       r   test_hermiteE_strz/TestStrUnicodeSuperSubscripts.test_hermiteE_str>   1     $-$$%%S#r   u!   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                 h    t          t          j        |                    }t          ||           d S r)   r+   r   Laguerrer   r-   s       r   test_laguerre_strz/TestStrUnicodeSuperSubscripts.test_laguerre_strJ   r:   r   N)__name__
__module____qualname__pytestfixturer   markparametrizer   r/   r5   r9   r>   rB   rG    r   r   r   r      s       V^'4000/ / 10/ [^	-.	>?	 $ 	&.     [^	78	LM	 K 	M.     [^	78	LM	 K 	M.     [^	78	LM	 K 	M.     [^	9:	OP	 * 	,.     [^	78	LM	 K 	M.      r   r   c                      e Zd Z ej        dd          d             Zej                            dg ddfg dd	f ed
          dff          d             Z	ej                            dg ddfg ddf ed
          dff          d             Z
ej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d             Zej                            dg ddfg ddf ed
          dff          d              Zd!S )"TestStrAsciir   Tr   c                 .    t          j        d           d S Nasciir   r   s    r   	use_asciizTestStrAscii.use_asciiX       #G,,,,,r   r   r    1.0 + 2.0 x + 3.0 x**2r%   z"-1.0 + 0.0 x + 3.0 x**2 - 1.0 x**3r'   z}0.0 + 1.0 x + 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                 h    t          t          j        |                    }t          ||           d S r)   r*   r-   s       r   r/   z TestStrAscii.test_polynomial_str\   r0   r   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                 h    t          t          j        |                    }t          ||           d S r)   r3   r-   s       r   r5   zTestStrAscii.test_chebyshev_strg   s1     $.%%&&S#r   z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                 h    t          t          j        |                    }t          ||           d S r)   r7   r-   s       r   r9   zTestStrAscii.test_legendre_strs   rC   r   z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                 h    t          t          j        |                    }t          ||           d S r)   r<   r-   s       r   r>   zTestStrAscii.test_hermite_str   s1     $,s##$$S#r   z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                 h    t          t          j        |                    }t          ||           d S r)   r@   r-   s       r   rB   zTestStrAscii.test_hermiteE_str   rC   r   z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                 h    t          t          j        |                    }t          ||           d S r)   rE   r-   s       r   rG   zTestStrAscii.test_laguerre_str   rC   r   N)rH   rI   rJ   rK   rL   rU   rM   rN   r   r/   r5   r9   r>   rB   rG   rO   r   r   rQ   rQ   V   s       V^'4000- - 10- [^	,-	=>	 ; 	=.     [^	34	FG	 % 	'.     [^	34	FG	 % 	'.     [^	34	FG	 % 	'.     [^	56	IJ	 6 	8.     [^	34	FG	 % 	'.      r   rQ   c                       e Zd Z ej        dd          d             Zd Zd Zd Zd Z	ej
                            d	d
          d             ZdS )TestLinebreakingr   Tr   c                 .    t          j        d           d S rS   r   r   s    r   rU   zTestLinebreaking.use_ascii   rV   r   c                     t          j        g d          }t          t          t	          |                    d           t          t	          |          d           d S )N)Na rc   rc   rc   {   J   zJ12345678.0 + 12345678.0 x + 12345678.0 x**2 + 12345678.0 x**3 + 123.0 x**4r   r,   r   lenr+   r   ps     r   test_single_line_one_lessz*TestLinebreaking.test_single_line_one_less   s]    OIIIJJSQ[["%%%SVV+	 	 	 	 	r   c                     t          j        g d          }t          t          t	          |                    d           t          t	          |          d           d S )N)rc   rc   rc   rc   i  K   zK12345678.0 + 12345678.0 x + 12345678.0 x**2 + 12345678.0 x**3 +
1234.0 x**4rf   rh   s     r   test_num_chars_is_linewidthz,TestLinebreaking.test_num_chars_is_linewidth   s]    OJJJKKSQ[["%%%SVV-	 	 	 	 	r   c                     t          j        g d          }t          t          t	          |                              d          d                   d           t          t	          |          d           d S )N)rc   rc   rc   rc   r!   rc   
r   re   zZ12345678.0 + 12345678.0 x + 12345678.0 x**2 + 12345678.0 x**3 + 1.0 x**4 +
12345678.0 x**5)r   r,   r   rg   r+   splitrh   s     r   6test_first_linebreak_multiline_one_less_than_linewidthzGTestLinebreaking.test_first_linebreak_multiline_one_less_than_linewidth   sv    OEEE  	SQd++A.//444SVV<	 	 	 	 	r   c                 l    t          j        g d          }t          t          |          d           d S )N)rc   rc   rc   g=
)gAr!   rc   z[12345678.0 + 12345678.0 x + 12345678.0 x**2 + 12345678.12 x**3 +
1.0 x**4 + 12345678.0 x**5)r   r,   r   r+   rh   s     r   +test_first_linebreak_multiline_on_linewidthz<TestLinebreaking.test_first_linebreak_multiline_on_linewidth   sG    OHHH  	SVV=	 	 	 	 	r   )lwr   ))rl   z0.0 + 10.0 x + 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 + 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 + 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                 J   t          j        g d          }t          |          5  t          t	          |          |           t	          |                              d          D ]"}t          t          |          |k                #	 d d d            d S # 1 swxY w Y   d S )N)
r   
      i  i@  i  i'	 ip i@  i  )	linewidthro   )r   r,   r   r   r+   rp   r	   rg   )r   rt   r   ri   lines        r   test_linewidth_printoptionz+TestLinebreaking.test_linewidth_printoption   s     OGGG
 
 B''' 	( 	(Q%%%AT** ( (D		B''''(	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   A#BBBN)rH   rI   rJ   rK   rL   rU   rj   rm   rq   rs   rM   rN   r|   rO   r   r   r`   r`      s        V^'4000- - 10-    	 	 	   [] 
- 
 
( (
 
( ( (r   r`   c                  "   t          j        g d          } t          j        g d          }t          j        d           t	          t          |           d           t	          t          |          d           t          j        d           t	          t          |           d           t	          t          |          d           t          j        t                    5  t          j        d           d d d            d S # 1 swxY w Y   d S )	Nr    rT   rW   rY   r   r$   r1   invalid_input)	r   r,   r4   r   r   r+   rK   raises
ValueError)ri   cs     r   test_set_default_printoptionsr      s+   			""Ayyy!!A(((Q1222Q8999	***Q2333Q<===	z	"	" 5 5#O4445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   "DDDc                     g d} t          j        |           }t          j        t          | t                              }t          j        d           t          t          |          d           t          t          |          d           t          j        d           t          t          |          d           t          t          |          d           d	S )
z%Test both numpy and built-in complex.)y              ?y      ?      ?y              @y      @        dtyper   u*   1j + (1+1j)·x - (2-2j)·x² + (3+0j)·x³u+   1j + (1+1j)·x + (-2+2j)·x² + (3+0j)·x³rT   z)1j + (1+1j) x - (2-2j) x**2 + (3+0j) x**3z*1j + (1+1j) x + (-2+2j) x**2 + (3+0j) x**3N)r   r,   r   objectr   r   r+   )coefsp1p2s      r   test_complex_coefficientsr      s    %%%E			B	uF333	4	4B	***RFGGGRGHHH(((REFFFRFGGGGGr   )r   r   r!   r"   r#      r   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                     t          j        |           }t          j        d           t          t	          |          |           d S r   r   r,   r   r   r+   r   r   ri   s      r    test_numeric_object_coefficientsr     s@     	A	***Qr   )r!   r"   fu   1 + 2·x + f·x²u   1 + 2·x + [3, 4]·x²c                     t          j        |           }t          j        d           t          t	          |          |           dS )zK
    Test coef fallback for object arrays of non-numeric coefficients.
    r   Nr   r   s      r   #test_nonnumeric_object_coefficientsr     s@     	A	***Qr   c                   &    e Zd Zd Zd Zd Zd ZdS )
TestFormatc                     t          j        d           t          j        g d          }t          t	          |d          d           d S )NrT   r!   r"   r   r&   r   u"   1.0 + 2.0·x + 0.0·x² - 1.0·x³r   r   r,   r   formatrh   s     r   test_format_unicodezTestFormat.test_format_unicode!  sG    #G,,,OMMM**VAy))+OPPPPPr   c                     t          j        d           t          j        g d          }t          t	          |d          d           d S )Nr   r   rT   z!1.0 + 2.0 x + 0.0 x**2 - 1.0 x**3r   rh   s     r   test_format_asciizTestFormat.test_format_ascii&  sR    #I...OMMM**1g C	
 	
 	
 	
 	
r   c                     t          j        d           t          j        g d          }t          t	          |          d           t          | d           d S )NrT   r    rW   r   rh   s     r   test_empty_formatstrzTestFormat.test_empty_formatstr-  sV    #G,,,OIII&&VAYY 8999V566666r   c                     t          j        g d          }t          j        t                    5  t          |d           d d d            d S # 1 swxY w Y   d S )Nr   z.2f)r   r,   rK   r   r   r   rh   s     r   test_bad_formatstrzTestFormat.test_bad_formatstr3  s    OMMM**]:&& 	 	1e	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AAAN)rH   rI   rJ   r   r   r   r   rO   r   r   r   r      sS        Q Q Q

 
 
7 7 7    r   r   )r   r   u   1.0 + 2.0·z + 3.0·z²u!   1.0 + 2.0·T₁(z) + 3.0·T₂(z)u!   1.0 + 2.0·H₁(z) + 3.0·H₂(z)u#   1.0 + 2.0·He₁(z) + 3.0·He₂(z)u!   1.0 + 2.0·L₁(z) + 3.0·L₂(z)u!   1.0 + 2.0·P₁(z) + 3.0·P₂(z)c                 H     | g dd          }t          |d|           d S )Nr    zsymbolr   )r   )r   r   ri   s      r   test_symbolr   9  s6     	YYYs###AA%%%%%r   c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestReprc                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   zBPolynomial([0., 1.], domain=[-1,  1], window=[-1,  1], symbol='x'))reprr   r,   r   r   r.   r   s      r   r/   zTestRepr.test_polynomial_strG  s?    4?Aq6**++ 	 	S#r   c                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   zAChebyshev([0., 1.], domain=[-1,  1], window=[-1,  1], symbol='x'))r   r   r4   r   r   s      r   r5   zTestRepr.test_chebyshev_strO  s?    4>1a&))** 	 	S#r   c                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   z@Legendre([0., 1.], domain=[-1,  1], window=[-1,  1], symbol='x'))r   r   r8   r   r   s      r   test_legendre_reprzTestRepr.test_legendre_reprW  ?    4=!Q(()) 	 	S#r   c                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   z?Hermite([0., 1.], domain=[-1,  1], window=[-1,  1], symbol='x'))r   r   r=   r   r   s      r   test_hermite_reprzTestRepr.test_hermite_repr_  s?    4<A''(( 	 	S#r   c                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   z@HermiteE([0., 1.], domain=[-1,  1], window=[-1,  1], symbol='x'))r   r   rA   r   r   s      r   test_hermiteE_reprzTestRepr.test_hermiteE_reprg  r   r   c                 p    t          t          j        ddg                    }d}t          ||           d S )Nr   r!   z<Laguerre([0., 1.], domain=[0, 1], window=[0, 1], symbol='x'))r   r   rF   r   r   s      r   test_laguerre_reprzTestRepr.test_laguerre_repro  r   r   N)	rH   rI   rJ   r/   r5   r   r   r   r   rO   r   r   r   r   F  sn                      r   r   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )TestLatexReprz#Test the latex repr used by Jupyterc                 P    dd|_         	 |                                |` S # |` w xY w)NFc                      t          |           S r)   )r+   )xparenss     r   <lambda>z(TestLatexRepr.as_latex.<locals>.<lambda>  s    Q r   )F)_repr_latex_scalar_repr_latex_)r   objs     r   as_latexzTestLatexRepr.as_latex{  sB     "@!?!?	'##%%&&&&&&&s   ! %c                    t          j        g d          }t          |                     |          d           t          j        g dddg          }t          |                     |          d           t          j        g dddg          }t          |                     |          d	           t          j        g dd
dg          }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}$            ?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   rh   s     r   test_simple_polynomialz$TestLatexRepr.test_simple_polynomial  s   OIII&&T]]1%%4	6 	6 	6 OIIIr1g666T]]1%%Z	\ 	\ 	\ OIIItSk:::T]]1%%T	V 	V 	V OIIIr1g666T]]1%%`	b 	b 	b 	b 	br   c                     t          j        g d          }t          |                     |          d           t          j        g dddg          }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   r4   r   r   rh   s     r   test_basis_funczTestLatexRepr.test_basis_func  s    N999%%T]]1%%N	P 	P 	P N999b!W555T]]1%%i	k 	k 	k 	k 	kr   c                 x    t          j        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   rA   r   r   rh   s     r   test_multichar_basis_funcz'TestLatexRepr.test_multichar_basis_func  sG    M)))$$T]]1%%Q	S 	S 	S 	S 	Sr   c                    t          j        g d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    r   r   z%$z \mapsto 1.0 + 2.0\,z + 3.0\,z^{2}$r   r   )r   r   zK$z \mapsto 1.0 + 2.0\,\left(1.0 + z\right) + 3.0\,\left(1.0 + z\right)^{2}$r   r   zE$z \mapsto 1.0 + 2.0\,\left(2.0z\right) + 3.0\,\left(2.0z\right)^{2}$r&   zQ$z \mapsto 1.0 + 2.0\,\left(1.0 + 2.0z\right) + 3.0\,\left(1.0 + 2.0z\right)^{2}$r   rh   s     r   test_symbol_basiczTestLatexRepr.test_symbol_basic  s   OIIIc222T]]1%%4	6 	6 	6 OIIIr1gcBBBMM!-	
 	
 	
 OIIItSk#FFFMM!*	
 	
 	
 OIIIr1gcBBBMM!0	
 	
 	
 	
 	
r   N)	rH   rI   rJ   __doc__r   r   r   r   r   rO   r   r   r   r   x  sn        --' ' 'b b b*k k kS S S
"
 "
 "
 "
 "
r   r   )z"1.0 + (1.0e-01) x + (1.0e-02) x**2z"1.2 + (1.2e-01) x + (1.2e-02) x**2z11.23 + 0.12 x + (1.23e-02) x**2 + (1.23e-03) x**3z51.235 + 0.123 x + (1.235e-02) x**2 + (1.235e-03) x**3zG1.2346 + 0.1235 x + 0.0123 x**2 + (1.2346e-03) x**3 + (1.2346e-04) x**4zL1.23457 + 0.12346 x + 0.01235 x**2 + (1.23457e-03) x**3 + (1.23457e-04) x**4za1.234568 + 0.123457 x + 0.012346 x**2 + 0.001235 x**3 + (1.234568e-04) x**4 + (1.234568e-05) x**5zg1.2345679 + 0.1234568 x + 0.0123457 x**2 + 0.0012346 x**3 + (1.2345679e-04) x**4 + (1.2345679e-05) x**5c                   f    e Zd ZdZ ej        dd          d             Zd Zd Zd Z	d	 Z
d
 ZdS )TestPrintOptionsz
    Test the output is properly configured via printoptions.
    The exponential notation is enabled automatically when the values 
    are too small or too large.
    r   Tr   c                 .    t          j        d           d S rS   r   r   s    r   rU   zTestPrintOptions.use_ascii  rV   r   c                     t          j        g d          }t          t          |          d           t	          d          5  t          t          |          d           d d d            d S # 1 swxY w Y   d S )Nr   g$I$I?gI$Ir?kAgm۶mAzC0.5 + 0.14285714 x + 14285714.28571429 x**2 + (1.42857143e+08) x**3r#   	precisionz40.5 + 0.143 x + 14285714.286 x**2 + (1.429e+08) x**3r   r,   r   r+   r   rh   s     r   test_strzTestPrintOptions.test_str  s    O<<<==SVV 7 	8 	8 	8 A&&& 	7 	7Q "6 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7s   A//A36A3c                    t          j        g d          }t          |                                d           t	          d          5  t          |                                d           d d d            d S # 1 swxY w Y   d S )Nr   zp$x \mapsto \text{0.5} + \text{0.14285714}\,x + \text{14285714.28571429}\,x^{2} + \text{(1.42857143e+08)}\,x^{3}$r#   r   za$x \mapsto \text{0.5} + \text{0.143}\,x + \text{14285714.286}\,x^{2} + \text{(1.429e+08)}\,x^{3}$)r   r,   r   r   r   rh   s     r   
test_latexzTestPrintOptions.test_latex  s    O<<<==Q^^%%/	0 	0 	0
 A&&& 	L 	L))KL L L	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	Ls   	#A99A= A=c                    t          j        dg          }t          t          |          d           t	          d          5  t          t          |          d           d d d            n# 1 swxY w Y   t	          dd          5  t          t          |          d           d d d            d S # 1 swxY w Y   d S )	Nr   z0.5fixed)	floatmodez
0.50000000r   )r   r   z0.5000r   rh   s     r   
test_fixedzTestPrintOptions.test_fixed  s4   OSE""SVVU###G,,, 	/ 	/Q...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ Gq999 	+ 	+Q***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+s$   A--A14A1	B44B8;B8c           	      @   t          t                    D ]\  }}t          |          5  t          j        d t          |dz  dz             D                       }t          |                              dd          |k    sJ 	 d d d            n# 1 swxY w Y   d S )Nr   c                      g | ]}d d| z  z  S )gރB?rx   rO   ).0is     r   
<listcomp>z7TestPrintOptions.test_switch_to_exp.<locals>.<listcomp>  s3     %= %= %=)* &0QB%6 %= %= %=r   r"   r#   ro    )	enumerateSWITCH_TO_EXPr   r   r,   ranger+   replace)r   r   sri   s       r   test_switch_to_expz#TestPrintOptions.test_switch_to_exp  s    m,, 	6 	6DAq*** 6 6O %= %=.3AqDFmm%= %= %= > >1vv~~dC00A555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6s   ABB	B	c                 X   t          j        t          t          g          }t	          |          dk    sJ |                                dk    sJ t          dd          5  t	          |          dk    sJ |                                dk    sJ 	 d d d            d S # 1 swxY w Y   d S )Nznan + inf xz&$x \mapsto \text{nan} + \text{inf}\,x$NANINF)nanstrinfstrzNAN + INF xz&$x \mapsto \text{NAN} + \text{INF}\,x$)r   r,   r   r   r+   r   r   rh   s     r   test_non_finitez TestPrintOptions.test_non_finite  s    OS#J''1vv&&&&~~#LLLLLu555 	: 	:q66]****>>##9: : : : :	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:s   !0BB#&B#N)rH   rI   rJ   r   rK   rL   rU   r   r   r   r   r   rO   r   r   r   r     s          V^'4000- - 10-7 7 7
L 
L 
L+ + +6 6 6: : : : :r   r   )(mathr   r   rK   
numpy.corer   r   r   numpy.polynomial
polynomialr   numpy.testingr   r	   	fractionsr
   decimalr   r   rQ   r`   r   r   rM   rN   r   r   r   r   r,   r4   r=   rA   rF   r8   r   r   r   r   r   rO   r   r   <module>r      s            2 2 2 2 2 2 2 2 2 2       / / / / / / / /            G G G G G G G GTK K K K K K K K\?( ?( ?( ?( ?( ?( ?( ?(D
5 
5 
5H H H )
UHHQNNHHQNN+6::: UAq((1a..!000 UGGFOOWWU^^Q/v>>> 
, 
 
 
 
 )
U;;;f%%%':;
UAq1a&>(((*BC,   	        2 	_/0	^89	\67	]9:	]78	]78+  & & &
/ / / / / / / /dR
 R
 R
 R
 R
 R
 R
 R
j38: 8: 8: 8: 8: 8: 8: 8: 8: 8:r   