
    MZd9                     R    d dl mZ d dlmZ d dlmZ d dlZd Zd Zd Z	d
dZ
d
d	Zy)    )Float)Dummy)lambdifyNc                     | yt        | t              ryt        j                  |        xr t        j                  |        S )z)Check if a floating point number is validF)
isinstancecomplexmathisinfisnan)xs    9/usr/lib/python3/dist-packages/sympy/plotting/textplot.pyis_validr      s8    y!Wzz!}2TZZ]!22    c                 b   g }||z
  }||z   dz  }t        |      D ]  }t        | |         rp| |   |z
  |z  }	t        |	      s|j                  d       9t        |	|z  |dz  z   |dz
  z  |z        j	                         }
t        |
      }
|j                  |
       |j                  d        |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rescaleds              r   rescaler!      s     E7D2g]F1X 
AaD>A$-4/JJ'T" *Q,1"41!=a!?@FFHx=X&LL
 Lr   c                 \    t        |      D cg c]  }| || z
  |z  |dz
  z  z    c}S c c}w )Nr   )r   )startstopnumr   s       r   linspacer&   (   s1    :?*EQETE\Q&#a%00EEEs   )c              #   V  K   | j                   }t        |      dkD  rt        dj                  |            |r|j	                         n	t               }t        |g|       }t        |      }t        |      }t        |||      }g }|D ]  }		 |j                   ||	              t        t        t        |            }
|
r7t        |
      }t!        |
      }||k(  r!|rt#        dd|z  g      \  }}nd\  }}nd\  }}||z
  }t%        j&                  t%        j(                  |d            dz
  }|dz  }t+        ||      }t+        ||      }t-        |||||      }t        |||      }d	}t/        |dz
  dd      D ]  }d
g|z  }t/        |      D ]n  }||   |k(  s|dk(  s||dz
     |dz
  k(  r||dz
  k(  s||dz      |dz   k(  rd||<   ;|dk(  s||dz
     |dz   k(  r||dz
  k(  s||dz      |dz
  k(  rd||<   jd||<   p |dk(  rt/        |      D ]  }d||<   	 |d|dz  |dz
  fv rd||   z  j1                  |      d| }nd
|z  }dj3                  |      }||dz  k(  r|j5                  d
d      }|dz   |z     d
|dz   z  }|d|d   z  j7                  |dz        z  }|dz  dk(  r!|d||dz     z  j7                  |dz        z  }n#|d||dz     z  j7                  |dz  dz
        z  }|d|d   z  z  }| y# t        t        t        f$ r |j                  d       Y w xY ww)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   	TypeErrorZeroDivisionErrorlistfilterr   maxminsortedr	   floorlogr   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bottoms                         r   textplot_strrU   ,   s    D
4y1}BVD\ 	 
A!dAaAaA 	AqA
A 	HHQsV 6(A&'G\\8AbD	*BBB2gG

488GR01A5IOI	r9	B	r9	B1aR Ab"a F F1q5"b!  EAIq 	AtqyFaAh!a%/a1q5jAa!eHPQTUPUDUAaD1f!a%AE 1QU
aAhRSVWRWFWAaDAaD	 61X ! AqD!a%  VAY&--f5gv>FZFGGAJ19		#s#Atma/ 4 FQJF
tad{!!!Q$''F1uz4!AqD'>((A..4!AqD'>((Aa00
dQrUlF
Lw I'89 	HHTN	s2   BL)K="C5L)E%L)=%L&"L)%L&&L)c                 B    t        | ||||      D ]  }t        |        y)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)rU   print)rE   rF   rG   r   r   lines         r   textplotrY   }   s(    H T1aA. dr   )7      )sympy.core.numbersr   sympy.core.symbolr   sympy.utilities.lambdifyr   r	   r   r!   r&   rU   rY    r   r   <module>r`      s-    $ # - 3.FNb%r   