ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ ;Pc@sdZddlmZmZmZdefdYZdefdYZdeefdYZd Z d Z d dd YZ d e efdYZ de efdYZ dZgdgddZdgddZdZdZdS(s Support functions for RE simplification. This module is intended for use by the RE module. It is in a separate module to keep RE itself cleaner since the algorithm, 'rectangle selection', is a quite separate part that depends on some tricky heuristics. The primary entry function is chooserects(lines, gauges, trace) It chooses 'the best' rectangles from lines to base simplification on. A weight on atoms is given by gauges. The trace parameter is for debugging. pr() gives some example usages of chooserects. i(t immbitsett mutbitsett immbitrangetRectcBsDeZd ZdZdZdZd d Zd ZeZRS( twidthtlinestgainmemotlnost all_linest common_partcCs>||_||_|o't|dk s1ti|_dS(Ni(RRtlentAssertionErrorR(tselfRR((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt__init__s  cCsK||_tg|jD]}|t|^q|_|j|_dS(N(RRRtidRtget_common_partR (R tlnobyidRtline((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pytinit2s /cCs~|j}||@}||krO||_g|D]}|j|^q0|_nt|dkrzt|jd|_ndS(Nii(RRRR R(R Rtolnostlno((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt reducelines#s    &icCs7g}x*|j|@D]}|j|j|qW|S(N(RtappendR(R t pickednosRti((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt get_lines/scCs&d|j|jt|j|jfS(Ns0< dir = %d width = %d lnos = %s lines = %s >(tdirRtlistRR(R ((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt__str__5s(RRRRRR ( t__name__t __module__t __slots__R RRRRt__repr__(((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyRs    tLeftRectcBs)eZdZdZdZddZRS(icCs|jd|j S(Ni(RR(R ((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR?scCs8g}x+|j|D]}|j||jqW|S(N(RRR(R RtucR((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt get_uncommonsBs((RRRRRR#(((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR!<s t RightRectcBs)eZdZdZdZddZRS(icCs)|j }|dkrgS|jd|S(Ni(RR(R tlo((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyRKs  icCsTg}|j }|dkr%d}nx(|j|D]}|j|| q5W|S(Ni(RtNoneRR(R RR"thiR((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR#Qs   ((RRRRRR#(((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR$Hs cCsA|dkrt|Sd}x|D]}|||7}q#W|S(Ni(R&R (tgaugetlsttgaintx((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt sum_gaugeZs    cCsLxE|D]=}t||}t||}t||}|r|SqWdS(Ni(R,tcmp(txstystgaugesR(tgxtgytc((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyt cmp_gaugedds t InducedRectcBseZdZRS(cCs7||_|j|_|j|_||_||_dS(N(tsRRRR(R R6RR((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR ns     (RRR (((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR5mstInducedRightRectcBseZRS((RR(((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR7wstInducedLeftRectcBseZRS((RR(((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyR8zsc Cs~t|dkr"td|gStd|td|g}g}x1|ry|}g}x|D]}|j}xd}i}||jA}xI|jD]>} |t| kr|j| |gj| qd}qW|st|dkrPn|d|_}qtW|j||d7}xN|jD]@\} } t| dkr.|j || } |j| q.q.WqbWqIW|S(Nii( R R!R$RRRt setdefaultRtitemst __class__( Rtnewrectst donerectstoldrectstrRtis_donetdtposRtktvtnew_r((sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pytbrects6        tcsfd}fd}fd}d}ddkrwdntgtD]\}} t| |f^q} } t| xD]} | j| qWj|tt} t g}gx`| krw|} | j O|j | || dkrjt j n|| qWdkrt j nd krt j n|S( Nc sdkrtjn|j}t|dkr;dSg}x=D]5}|j|jkrfqHng}|j}|j@}t|t|kstx9t||D](\}}||kr|j|qqWt|t|krHt |} g|D]}|^q}|jdkr<t } nt } | ||| } dkrmtjn|j| qHqHW|rj |ndS(Ntinduceiitindap( tpdbt set_traceR#R RRR tzipRRR7R8textend( R?t uncommonstirsR6tpsstuncsRtuncRtpslnosR3tir(RtnewsRtrectsttrace(sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyRHs8         c sdkrtjn|j}g}xhD]`}||krGq/n|j|jkr_q/n|j}||@sxq/n|M}|sq/n|j}|sq/nxD]}||krqn|j|jkrqn|j@}||@rqn||@}|sqn||kr!qn|j} | s6qnt|| } | dkrZqndkrptjnPqW|j|j|q/Wt|dkrtjnj |dS(Ntoverlapitobreaki( RJRKRRR R4RtremoveR RM( R?trlnosttonewsR6tslnostscomttttlnosRttcomR3(R0RURRVRW(sD/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/RE_Rect.pyRXsZ                    csxr6dkr"tjnd}d=nd}xtD]~}|j}|suj|qInt|d}|j}|dk r|sPn|sqIn|r|j}|j}d}xD]} y|| } Wn-t k rt | |j } | || s&     K