U
    9%e(                     @   s   d dl mZmZmZmZmZmZ d dlmZ d dl	m
Z
 d dl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 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 )    )purestrstyleof	attrprintdotnodedotedgesdotprint)Basic)Expr)FloatInteger)S)Symbolsymbols)srepr)xc                   C   s   t tddkstt ttdtddks2tt tddksFtt tdddd	ks^tt ttdtdddd
kstt tddddkstd S )Nr   Symbol('x')      Basic(Integer(1), Integer(2))Float('2.0', precision=53)T)Z	with_args)r    )r   )z
Integer(1)
Integer(2))r   r   )r   r   AssertionErrorr   r   r
   r   r   r   \/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/printing/tests/test_dot.pytest_purestr   s    r   c                  C   sZ   t dddftddifg} tt td| dddks:tttd | dddksVtd S )Nblueellipsecolorshaper   blackr   )r   r	   r   r   r   r   )stylesr   r   r   test_styleof   s
    
 r"   c                   C   s   t ddddkstd S )Nr   r   r   z!"color"="blue", "shape"="ellipse")r   r   r   r   r   r   test_attrprint    s    r#   c                   C   sx   t tdddkstt td dddks<tt td ddt ttd  dddksXtt ttd  ddd	ksttd S )
NFrepeatz@"Symbol('x')" ["color"="black", "label"="x", "shape"="ellipse"];r   zS"Add(Integer(2), Symbol('x'))" ["color"="black", "label"="Add", "shape"="ellipse"];r   ze"Add(Symbol('x'), Pow(Symbol('x'), Integer(2)))" ["color"="black", "label"="Add", "shape"="ellipse"];Tzh"Add(Symbol('x'), Pow(Symbol('x'), Integer(2)))_()" ["color"="black", "label"="Add", "shape"="ellipse"];)r   r   r   r   r   r   r   test_dotnode$   s    
r&   c                   C   sD   t ttd ddddgks tt ttd ddddgks@td S )	Nr   Fr$   z/"Add(Integer(2), Symbol('x'))" -> "Integer(2)";z0"Add(Integer(2), Symbol('x'))" -> "Symbol('x')";Tz7"Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";z8"Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";)sortedr   r   r   r   r   r   r   test_dotedges4   s    
r(   c                      s  t td dd t fddttd ddD s6tt fdddd ttdtd fD D shtd	 ksttt ttd  dd t fd
dtttd  ddD stt fdddd ttdtd fD D std	 kstt ttd  dd t fddtttd  ddD s0tt fdddd ttd  fD D s`tt tt dd t fddttt ddD stt fddttddttddfD std	 kstd S )Nr   Fr$   c                 3   s   | ]}| kV  qd S Nr   .0etextr   r   	<genexpr>@   s     z test_dotprint.<locals>.<genexpr>c                 3   s   | ]}| kV  qd S r)   r   r+   nr-   r   r   r/   A   s    c                 S   s   g | ]}t |d dqS Fr$   r   r+   exprr   r   r   
<listcomp>B   s   z!test_dotprint.<locals>.<listcomp>Zdigraphc                 3   s   | ]}| kV  qd S r)   r   r*   r-   r   r   r/   G   s     c                 3   s   | ]}| kV  qd S r)   r   r0   r-   r   r   r/   H   s    c                 S   s   g | ]}t |d dqS r2   r3   r4   r   r   r   r6   I   s   Tc                 3   s   | ]}| kV  qd S r)   r   r*   r-   r   r   r/   N   s     c                 3   s   | ]}| kV  qd S r)   r   r0   r-   r   r   r/   O   s    c                 S   s   g | ]}t |d dqS )r   posr3   r4   r   r   r   r6   P   s   c                 3   s   | ]}| kV  qd S r)   r   r*   r-   r   r   r/   T   s     c                 3   s   | ]}| kV  qd S r)   r   r0   r-   r   r   r/   U   s    )r   r7   )r   )r   r   allr   r   r   r   r   r   r-   r   test_dotprint>   s:    &*,(r:   c                  C   s\   t dt d dd} tdt d | ks,ttt| ks<tt dt d } d| ksXtd S )N   r   r   )depthr<   )r   r   r   r   r-   r   r   r   test_dotprint_depthY   s
    r=   c                  C   s0   ddl m}  td}t| d||dks,td S )Nr   )MatrixSymbolr1   Xa  digraph{

# Graph style
"ordering"="out"
"rankdir"="TD"

#########
# Nodes #
#########

"MatrixSymbol(Str('X'), Symbol('n'), Symbol('n'))_()" ["color"="black", "label"="MatrixSymbol", "shape"="ellipse"];
"Str('X')_(0,)" ["color"="blue", "label"="X", "shape"="ellipse"];
"Symbol('n')_(1,)" ["color"="black", "label"="n", "shape"="ellipse"];
"Symbol('n')_(2,)" ["color"="black", "label"="n", "shape"="ellipse"];

#########
# Edges #
#########

"MatrixSymbol(Str('X'), Symbol('n'), Symbol('n'))_()" -> "Str('X')_(0,)";
"MatrixSymbol(Str('X'), Symbol('n'), Symbol('n'))_()" -> "Symbol('n')_(1,)";
"MatrixSymbol(Str('X'), Symbol('n'), Symbol('n'))_()" -> "Symbol('n')_(2,)";
})Z"sympy.matrices.expressions.matexprr>   r   r   r   )r>   r1   r   r   r   test_Matrix_and_non_basics`   s
    r@   c                  C   s,   t td td} d| kstd| ks(td S )Nr   )Z	labelfuncr   r   )r   r   r   r   r-   r   r   r   test_labelfunc}   s    rA   c                  C   sL   t ddd\} }t| | t||  ks,tt| | t||  ksHtd S )Nzx yF)Zcommutative)r   r   r   )r   yr   r   r   test_commutative   s    rC   N)!Zsympy.printing.dotr   r   r   r   r   r   Zsympy.core.basicr   Zsympy.core.exprr	   Zsympy.core.numbersr
   r   Zsympy.core.singletonr   Zsympy.core.symbolr   r   Zsympy.printing.reprr   Z	sympy.abcr   r   r"   r#   r&   r(   r:   r=   r@   rA   rC   r   r   r   r   <module>   s"    
