o
    oh                     @   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|  ot|  S )z)Check if a floating point number is validNF)
isinstancecomplexmathisinfisnan)x r   k/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/plotting/textplot.pyis_valid   s
   
r   c                 C   s   g }|| }|| d }t |D ];}t| | rF| | | | }	t|	s*|d qt|	| |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   )ranger   appendr   roundint)yWHmimay_newnormoffsetr
   
normalized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>)   s   $ zlinspace.<locals>.<listcomp>)r   )r"   r#   r!   r   r    r   linspace(   s   r%   7      c                 c   sx   | j }t|dkrtd||r| nt }t|g| }t|tr-|j	dkr-|j
}t|tr:|j	dkr:|j
}t|}t|}t|||}g }|D ]}	z	|||	 W qL tttfyh   |d Y qLw ttt|}
|
rt|
}t|
}||kr|rtdd| g\}}n	d\}}nd\}}|| }tt|d }|d9 }t||}t||}t|||||}t|||}d}t|d ddD ]}d	g| }t|D ]W}|| |kr*|dks||d  |d kr||d ks||d  |d krd
||< q|dks||d  |d kr&||d ks!||d  |d kr&d||< qd||< q|dkr<t|D ]}d||< q4|d|d |d fv rVd||  |d| }nd	| }d|}||d krl|d	d}|d | V  qd	|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 {})r   Nr   )r   r(       /\._z%g -z |) free_symbolslen
ValueErrorformatpopr   r   r   r   imagrealfloatr%   r   	TypeErrorZeroDivisionErrorlistfilterr   maxminsortedr   floorlog10r   r   r   rjustjoinreplaceljust)exprabr   r   freer
   fr   valy_validr   r   y_range	precisiony_binsmarginhsiprefixbottomr   r   r   textplot_str,   s   






<
D


 "
rV   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)rV   print)rF   rG   rH   r   r   liner   r   r   textplot   s   $
rY   )r&   r'   )sympy.core.numbersr   sympy.core.symbolr   sympy.utilities.lambdifyr   r   r   r   r%   rV   rY   r   r   r   r   <module>   s    	
W