a
    RG5dA                     @   s\   d dl mZ d dlmZ d dlmZ d dlZdd Zdd Zd	d
 Z	dddZ
dddZdS )    )Float)Dummy)lambdifyNc                 C   s2   | du rdS t | trdS t|  o0t|  S )z)Check if a floating point number is validNF)
isinstancecomplexmathisinfisnan)x r   S/var/www/html/django/DPS/env/lib/python3.9/site-packages/sympy/plotting/textplot.pyis_valid   s
    
r   c                 C   s   t  }|| }|| d }t|D ]v}t| | r| | | | }	t|	sV|d qt|	| |d  |d  |  }
t|
}
||
 q"|d q"|S )zRescale the given array `y` to fit into the integer values
    between `0` and `H-1` for the values between ``mi`` and ``ma``.
       N   )listranger   appendr   roundint)yWHmimaZy_newnormoffsetr
   
normalizedZrescaledr   r   r   rescale   s    $r   c                    s    fddt  D S )Nc                    s$   g | ]} |  d    qS )r   r   ).0r
   numstartstopr   r   
<listcomp>)       zlinspace.<locals>.<listcomp>)r   )r!   r"   r    r   r   r   linspace(   s    r%   7      c                 c   sV  | j }t|dkr td||r,| nt }t|g| }t|}t|}t|||}t	 }|D ]:}	z|
||	 W qd tttfy   |
d Y qd0 qdt	tt|}
|
rt|
}t|
}||kr|rtdd| g\}}qd\}}nd\}}|| }tt|dd }|d9 }t||}t||}t|||||}t|||}d	}t|d ddD ]b}d
g| }t|D ]}|| |krx|dks||d  |d kr||d ks||d  |d krd||< nV|dks||d  |d kr&||d ks||d  |d kr&d||< nd||< qx|dkrTt|D ]}d||< qD|d|d |d fv rd||  |d| }nd
| }d|}||d kr|d
d}|d | V  q`d
|d  }|d|d  |d 7 }|d dkr|d||d   |d 7 }n"|d||d   |d d 7 }|d|d  7 }|V  dS )z#Generator for the lines of the plotr   z4The expression must have a single variable. (Got {})Nr   r   )r   
   r(       /\._z%g -z |)free_symbolslen
ValueErrorformatpopr   r   floatr%   r   r   	TypeErrorZeroDivisionErrorfilterr   maxminsortedr   floorlogr   r   r   rjustjoinreplaceljust)exprabr   r   freer
   fr   valZy_validr   r   Zy_range	precisionZy_binsmarginhsiprefixbottomr   r   r   textplot_str,   sz    



D
D


 "rQ   c                 C   s"   t | ||||D ]}t| qdS )a  
    Print a crude ASCII art plot of the SymPy expression 'expr' (which
    should contain a single symbol, e.g. x or something else) over the
    interval [a, b].

    Examples
    ========

    >>> from sympy import Symbol, sin
    >>> from sympy.plotting import textplot
    >>> t = Symbol('t')
    >>> textplot(sin(t)*t, 0, 15)
     14 |                                                  ...
        |                                                     .
        |                                                 .
        |                                                      .
        |                                                .
        |                            ...
        |                           /   .               .
        |                          /
        |                         /      .
        |                        .        .            .
    1.5 |----.......--------------------------------------------
        |....       \           .          .
        |            \         /                      .
        |             ..      /             .
        |               \    /                       .
        |                ....
        |                                    .
        |                                     .     .
        |
        |                                      .   .
    -11 |_______________________________________________________
         0                          7.5                        15
    N)rQ   print)rD   rE   rF   r   r   liner   r   r   textplot}   s    $rT   )r&   r'   )r&   r'   )sympy.core.numbersr   sympy.core.symbolr   Zsympy.utilities.lambdifyr   r   r   r   r%   rQ   rT   r   r   r   r   <module>   s   	
Q