o
    3Ih                     @   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   d/home/air/sanwanet/gpt-api/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sJ t t td ksJ 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    