
     h	                     j    d Z ddlmZmZ ddlmZ ddlZddlm	Z	 dd fd	Z
d
 Zd Zd Zd Zd Zd Zy)zDThis submodule contains tools for working with numpy.poly1d objects.    )divisionabsolute_import)combinationsN   )iscloseFc                      y)NT )rs    r/home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/svgpathtools/polytools.py<lambda>r      s        c                    t        j                  |       }|r0|D cg c]%  }t        |j                  d      s|j                  ' }}|D cg c]  } ||      s| }}g }t        t        |d            D ]&  \  }\  }}t        ||      s|j                  |       ( t        |      D cg c]  \  }}||vs| c}}S c c}w c c}w c c}}w )a{  
    Returns the roots of a polynomial with coefficients given in p.
      p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
    INPUT:
    p - Rank-1 array-like object of polynomial coefficients.
    realroots - a boolean.  If true, only real roots will be returned  and the
        condition function can be written assuming all roots are real.
    condition - a boolean-valued function.  Only roots satisfying this will be
        returned.  If realroots==True, these conditions should assume the roots
        are real.
    OUTPUT:
    A list containing the roots of the polynomial.
    NOTE:  This uses np.isclose and np.rootsr      )nprootsr   imagreal	enumerater   append)	p	realroots	conditionr   r
   
duplicatesidxr1r2s	            r   	polyrootsr      s     HHQKE!&=A'!&&!*<==.11Q.E.J"<q#9: #Xb"2r?c"# &e,F&#q:0EAFF >. Gs"   CCCC.C;Cc                      t        | dd       S )zReturns the real roots between 0 and 1 of the polynomial with
    coefficients given in p,
      p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
    p can also be a np.poly1d object.  See polyroots for more information.Tc                 "    d| cxk  xr dk  S c S )Nr   r   r	   )tvals    r   r   zpolyroots01.<locals>.<lambda>+   s    qD~A~ ~ r   )r   r   )r   )r   s    r   polyroots01r!   &   s    
 Q$2MNNr   c                 Z   t        | t        j                        rt        |t        j                        sJ |t        j                  dg      k7  sJ  ||      dk7  r | |       ||      z  S  | |      dk(  r)t        | j	                         |j	                         |      S t        d      )zLComputes the limit of the rational function (f/g)(t)
    as t approaches t0.r   zLimit does not exist.)
isinstancer   poly1drational_limitderiv
ValueError)fgt0s      r   r%   r%   .   s     a#
1bii(@@@		1#uzuQrU{	
2!aggiB77011r   c                     	 t        j                  | j                  j                        S # t        $ r | j                  cY S w xY wN)r   r$   coeffsr   AttributeErrorzs    r   r   r   ;   6    yy'' vv   (+ AAc                     	 t        j                  | j                  j                        S # t        $ r | j                  cY S w xY wr,   )r   r$   r-   r   r.   r/   s    r   r   r   B   r1   r2   c                 T    t        j                  | j                  j                        S zDeprecated.)r   r$   r-   r   polys    r   poly_real_partr8   I       99T[[%%&&r   c                 T    t        j                  | j                  j                        S r5   )r   r$   r-   r   r6   s    r   poly_imag_partr;   N   r9   r   )__doc__
__future__r   r   	itertoolsr   numpyr   	misctoolsr   r   r!   r%   r   r   r8   r;   r	   r   r   <module>rA      sD    J 1 "   !N G4O
2'
'r   