o
    §ƒðjã  ã                   @   s  d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZmZ edƒ\Z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d„ Z#dd„ Z$d d!„ Z%d"d#„ Z&d$d%„ Z'd&d'„ Z(d(S ))é    )ÚProduct)ÚSum)Ú
DerivativeÚFunction)ÚIntegerÚRationalÚFloatÚoo)ÚRel)Úsymbols)Úsin)ÚIntegral)ÚOrder)Ú
precedenceÚ
PRECEDENCEzx,yc                   C   s8   t tt ƒtd ksJ ‚t tt d ƒtd ksJ ‚d S )NÚAddé   ©r   ÚxÚyr   © r   r   ú¦/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/printing/tests/test_precedence.pyÚtest_Add   s    r   c                   C   ó   t ttƒƒtd ksJ ‚d S )NÚFunc)r   r   r   r   r   r   r   r   Útest_Function   ó   r   c                   C   ó   t tttƒƒtd ksJ ‚d S ©NÚAtom)r   r   r   r   r   r   r   r   r   Útest_Derivative   ó   r    c                   C   r   r   )r   r   r   r   r   r   r   r   r   Útest_Integral   r!   r"   c                   C   s6   t tt ƒtd ksJ ‚t t t ƒtd ksJ ‚d S )NÚMulr   r   r   r   r   r   Útest_Mul   s   r$   c                   C   sò   t tdƒƒtd ksJ ‚t tdƒƒtd ksJ ‚t tdƒƒtd ks$J ‚t tdƒƒtd ks0J ‚t tddƒƒtd	 ks=J ‚t td
dƒƒtd ksJJ ‚t tdƒƒtd ksVJ ‚t td
ƒƒtd ksbJ ‚t tƒtd kslJ ‚t t ƒtd kswJ ‚d S )Nr   r   r   éÿÿÿÿr   é
   é   é   r#   éûÿÿÿ)r   r   r   r   r   r	   r   r   r   r   Útest_Number$   s   r*   c                   C   r   r   )r   r   r   r   r   r   r   r   Ú
test_Order1   r   r+   c                   C   sP   t tt ƒtd ksJ ‚t tt  ƒtd ksJ ‚t tt  ƒtd ks&J ‚d S )NÚPowr   r   r   r   r   r   Útest_Pow5   s   r-   c                   C   ó(   t tttttd fƒƒtd ksJ ‚d S ©Nr   r   )r   r   r   r   r   r   r   r   r   Útest_Product;   ó   (r0   c                   C   s$   t ttt tdƒƒtd ksJ ‚d S )Nú<Ú
Relational)r   r
   r   r   r   r   r   r   r   Útest_Relational?   s   $r4   c                   C   r.   r/   )r   r   r   r   r   r   r   r   r   Útest_SumC   r1   r5   c                   C   s   t tƒtd ks
J ‚d S r   )r   r   r   r   r   r   r   Útest_SymbolG   s   r6   c                   C   s$  t tt@ ƒt ttB ƒksJ ‚t t ƒt tt@ ƒksJ ‚t tt ƒt ttB ƒks)J ‚t tt ƒt tt@ ƒks7J ‚t tt ƒt ttB ƒksEJ ‚t tt ƒt tt@ ƒksSJ ‚t t ƒt tt ƒks`J ‚t t ƒt tt ƒksmJ ‚t tt@ ƒtd ksyJ ‚t ttB ƒtd ks…J ‚t t ƒtd ks�J ‚d S )NÚAndÚOrÚNotr   r   r   r   r   Útest_And_OrK   s   r:   c                     sH   G dd„ dt ƒ‰G dd„ dt ƒ‰ ‡fdd„} ‡ fdd„}| ƒ  |ƒ  d	S )
a_  
    Test cases for custom functions with different precedence values,
    specifically handling:
    1. Functions with precedence < PRECEDENCE["Mul"] (50)
    2. Functions with precedence = Func (70)

    Key distinction:
    1. Lower precedence functions (45) need parentheses: -2*(x F y)
    2. Higher precedence functions (70) don't: -2*x F y
    c                   @   s    e Zd Zed d Zdd„ ZdS )zBtest_custom_function_precedence_comparison.<locals>.LowPrecedenceFr#   r'   c                 S   ó&   |  | jd ¡› d|  | jd ¡› �S ©Nr   z F r   ©Ú_printÚargs©ÚselfÚprinterr   r   r   Ú	_sympystri   ó   &zLtest_custom_function_precedence_comparison.<locals>.LowPrecedenceF._sympystrN©Ú__name__Ú
__module__Ú__qualname__r   r   rC   r   r   r   r   ÚLowPrecedenceFg   s    rI   c                   @   s   e Zd Zed Zdd„ ZdS )zCtest_custom_function_precedence_comparison.<locals>.HighPrecedenceFr   c                 S   r;   r<   r=   r@   r   r   r   rC   n   rD   zMtest_custom_function_precedence_comparison.<locals>.HighPrecedenceF._sympystrNrE   r   r   r   r   ÚHighPrecedenceFl   s    rJ   c                     ó@   dˆ t tƒ } t| ƒdksJ ‚dˆ t tƒ }t|ƒdksJ ‚d S )Nr(   z	2*(x F y)éþÿÿÿz
-2*(x F y)©r   r   Ústr©Úexpr1Úexpr2)rI   r   r   Útest_low_precedenceq   ó   zGtest_custom_function_precedence_comparison.<locals>.test_low_precedencec                     rK   )Nr(   z2*x F yrL   z-2*x F yrM   rO   )rJ   r   r   Útest_high_precedencex   rS   zHtest_custom_function_precedence_comparison.<locals>.test_high_precedenceN)r   )rR   rT   r   )rJ   rI   r   Ú*test_custom_function_precedence_comparison\   s   
rU   N))Úsympy.concrete.productsr   Úsympy.concrete.summationsr   Úsympy.core.functionr   r   Úsympy.core.numbersr   r   r   r	   Úsympy.core.relationalr
   Úsympy.core.symbolr   Úsympy.functionsr   Úsympy.integrals.integralsr   Úsympy.series.orderr   Úsympy.printing.precedencer   r   r   r   r   r   r    r"   r$   r*   r+   r-   r0   r4   r5   r6   r:   rU   r   r   r   r   Ú<module>   s2    