U
    L?h                     @   sx   d dl Z d dlmZmZmZmZmZmZmZm	Z	m
Z
mZ d dlmZ dd Zdd Zdd	 Zd
d Zdd Zdd ZdS )    N)

parse_exprstandard_transformationsconvert_xor#implicit_multiplication_applicationimplicit_multiplicationimplicit_applicationfunction_exponentiationsplit_symbolssplit_symbols_custom_token_splittable)raisesc                     s   ddddddddd	d
ddddd} t tf }|ttf | D ], t d}t|   |d}||ks<tq<dddg}|D ] tt fdd qxttfdd d S )Nz5*xza*b*cz3*sin(x)z(x+1)*(x+2)z(5*x**2)*sin(x)z2*sin(x)*cos(x)zpi*xzx*piE*xzEulerGamma*yzE*pizpi*(x+2)z(x+2)*pi	pi*sin(x))Z5xabcz3sin(x)z
(x+1)(x+2)z(5 x**2)sin(x)z2 sin(x) cos(x)zpi xzx pizE xzEulerGamma yzE piz
pi (x + 2)z
(x + 2) piz	pi sin(x)transformationssin xcos 2*x	sin cos xc                      s   t  dS Nr   r    casetransformations2r   n/var/www/html/venv/lib/python3.8/site-packages/sympy/parsing/tests/test_implicit_multiplication_application.py<lambda>-       z.test_implicit_multiplication.<locals>.<lambda>c                      s   t d dS N	sin**2(x)r   r   r   r   r   r   r   /   r   )	r   r   r	   r   r   AssertionErrorr   SyntaxError	TypeError)casesr   implicitnormalZapplicationr   r   r   test_implicit_multiplication   s>    


r'   c                     s   ddddddd} t tf }|tf | D ]4 t d}t|   |d}||ks*t||fq*d	d
dg}|D ] tt fdd qnttfdd d S )N	factorialsin(x)z	tan(y**3)zcos(2*x)Zcotzsin(cos(tan(x))))r(   r   ztan y**3r   z(cot)zsin cos tan xr   x yx sin x2xc                      s   t  dS r   r   r   r   r   r   r   E   r   z+test_implicit_application.<locals>.<lambda>c                      s   t d dS r   r   r   r    r   r   r   G   r   )r   r   r   r   r!   r   r"   r#   )r$   r   r%   r&   Zmultiplicationr   r   r   test_implicit_application2   s*    



r-   c                     s   dddd} t tf }|tf | D ], t d}t|   |d}||ks$tq$dddd	d
dg}|D ] tt fdd qftddtdidtdkstd S )Nz	sin(x)**2zexp(z)^yzsin(E^(x))**2)r   zexp^y(z)zsin**2(E^(x))r   r*   r+   r,   r   r   r   c                      s   t  dS r   r   r   r   r   r   r   [   r   z.test_function_exponentiation.<locals>.<lambda>zx**2x
local_dictr   )	r   r   r   r   r!   r   r"   sympySymbol)r$   r   r%   r&   Zother_implicitr   r   r   test_function_exponentiationJ   s.    

 r3   c                  C   s  t tf } d}|D ]}t|| dt|kstq| tf7 } dtji}dddd}| D ]"\}}t||| dt|ksXtqXd	d
 }t } | t|tf7 } td| dtdksttd| dtdksttd| dtdkst|D ]}t|| dt|kstqd S )N)alphabetagammadeltaepsilonzetaetathetaiotakappamunuxiomicronpirhosigmatauupsilonphichipsiomegar   er   zI*yzE*E)ZxeZIyeer/   c                 S   s   | dkrt | S dS )N)unsplittablenamesF)r   )symbolr   r   r   	can_split|   s    z(test_symbol_splitting.<locals>.can_splitrM   rN   xyx*y)	r   r	   r   r!   r   r1   Eitemsr
   )r   Zgreek_lettersletterr0   r$   r   expectedrP   r   r   r   test_symbol_splittinga   sH    









rW   c               "   C   s   ddddddddddd	d
dddddddddddddddddddddd!} t tf }|tf }| D ],}t||d}t| | |d}||ks`tq`d S ) Nz2*xrR   r)   z2*sin(x)zx*y*zzsin(2 * 3 * x)zsin(x) * (1 + cos(x))z(x + 2) * sin(x)zsin(sin(x))zsin(factorial(x))zsin(factorial2(x))r(   z
x * sin(x)zx * y * sin(x)z(x + 2) * (x+3)zx**2 + 2 * x * y + y**2rB   Nonez
ln(sin(x))z	sin(x**2)zSymbol("alpha")zSymbol("x_2")zsin(x**2)**2z	sin(x)**3ztan(3*x)zsin(3*E**(x))**2zsin(E**(3*x))**2zsin(3*x*E^x)**2r   )!r,   r*   rQ   r   z2sin xzx y zzsin(2 * 3x)zsin(x) (1 + cos(x))z(x + 2) sin(x)z(x + 2) sin xz
sin(sin x)zsin x!zsin x!!r(   r+   zxy sin xz
(x+2)(x+3)zx**2 + 2xy + y**2rB   rX   zln sin xr(   zsin x**2r4   Zx_2z
sin^2 x**2z	sin**3(x)z(factorial)ztan 3xzsin^2(3*E^(x))zsin**2(E^(3x))zsin^2 (3x*E^(x))zpi sin xr   )r   r   r   r   r!   )r$   r   r   r   r%   r&   r   r   r   test_all_implicit_steps   sP    #

rY   c                  C   sT   t d} ttf }td|d}|dks,ttd|d}|| | d d  ksPtd S )Nuzx.is_polynomial(x)r   Tz((exp(x) / (1 + exp(2x))).subs(exp(x), u)      )r1   r2   r   r   r   r!   )rZ   r   exprr   r   r   'test_no_methods_implicit_multiplication   s    
r^   )r1   Zsympy.parsing.sympy_parserr   r   r   r   r   r   r   r	   r
   r   Zsympy.testing.pytestr   r'   r-   r3   rW   rY   r^   r   r   r   r   <module>   s   0!.,