Ë
    ÿÿæié/  ã                   óÖ   — d dl Zd dlmZmZ d dlmZmZ d„ Z	 G d„ d«      Z
 G d„ de«      Z G d	„ d
«      Z G d„ dej                  «      Z G d„ d«      Z G d„ d«      Z G d„ d«      Zy)é    N)ÚtickerÚ_api)ÚBboxÚ	Transformc                 ód  — g }| dd | dd z
  }t        d«      t        ddd«      fD �]  }| j                  |   \  }}|j                  |   \  }}|j                  |   \  }	}
|j                  |   \  }}|	||	kD  f|||k  ffD ]ª  \  }}g }|dd |dd z  j	                  «       \  }|D ]r  }||   |||   z
  ||   z  ||   z  z   }|
|cxk  r|k  sn Œ+||f|   }t        j                  t        j                  ||   ddd…   Ž «      }|j                  ||f«       Œt |j                  |«       Œ¬ �Œ	 |S )aá  
    Find the points where a polyline crosses a bbox, and the crossing angles.

    Parameters
    ----------
    xys : (N, 2) array
        The polyline coordinates.
    bbox : `.Bbox`
        The bounding box.

    Returns
    -------
    list of ((float, float), float)
        Four separate lists of crossings, for the left, right, bottom, and top
        sides of the bbox, respectively.  For each list, the entries are the
        ``((x, y), ccw_angle_in_degrees)`` of the crossing, where an angle of 0
        means that the polyline is moving to the right at the crossing point.

        The entries are computed by linearly interpolating at each crossing
        between the nearest points on either side of the bbox edges.
    é   Néÿÿÿÿ)	ÚsliceÚTÚminÚmaxÚnonzeroÚnpÚdegreesÚarctan2Úappend)ÚxysÚbboxÚ	crossingsÚdxysÚslÚusÚvsÚdusÚdvsÚuminÚvminÚumaxÚvmaxÚu0ÚinsideÚcrossÚidxsÚidxÚvÚcrossingÚthetas                        úx/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/mpl_toolkits/axisartist/grid_finder.pyÚ_find_line_box_crossingsr)      sf  € ð, €IØˆqˆrˆ7�S˜˜"�XÑ€DÜ�T‹{œE $¨¨bÓ1Ô2ˆØ—‘�r‘‰ˆˆBØ—6‘6˜"‘:‰ˆˆSØ—X‘X˜b‘\‰
ˆˆdØ—X‘X˜b‘\‰
ˆˆdØ  " t¡)Ð,¨t°R¸$±YÐ.?Ó@‰JˆB�ØˆEØ˜C˜R�[ 6¨!¨" :Ñ-×6Ñ6Ó8‰EˆDÛ�Ø�s‘G˜r B s¡G™|¨s°3©xÑ7¸#¸c¹(ÑBÑB�Ø˜qÔ( DÔ(ØØ ˜7 2™;�ÜŸ
™
¤2§:¡:¨t°C©y¹¸2¸©Ð#?Ó@�Ø—‘˜h¨Ð.Õ/ð ð ×Ñ˜UÕ#ò Að 3ð  Ðó    c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚExtremeFinderSimplezU
    A helper class to figure out the range of grid lines that need to be drawn.
    c                 ó    — || _         || _        y)zy
        Parameters
        ----------
        nx, ny : int
            The number of samples in each direction.
        N©ÚnxÚny)Úselfr/   r0   s      r(   Ú__init__zExtremeFinderSimple.__init__7   s   € ð ˆŒØˆ�r*   c                 ó¬  — t        j                  t        j                  ||| j                  «      t        j                  ||| j                  «      «      \  }} |t        j
                  |«      t        j
                  |«      «      \  }}	| j                  |j                  «       |j                  «       |	j                  «       |	j                  «       «      S )ai  
        Compute an approximation of the bounding box obtained by applying
        *transform_xy* to the box delimited by ``(x1, y1, x2, y2)``.

        The intended use is to have ``(x1, y1, x2, y2)`` in axes coordinates,
        and have *transform_xy* be the transform from axes coordinates to data
        coordinates; this method then returns the range of data coordinates
        that span the actual axes.

        The computation is done by sampling ``nx * ny`` equispaced points in
        the ``(x1, y1, x2, y2)`` box and finding the resulting points with
        extremal coordinates; then adding some padding to take into account the
        finite sampling.

        As each sampling step covers a relative range of *1/nx* or *1/ny*,
        the padding is computed by expanding the span covered by the extremal
        coordinates by these fractions.
        )	r   ÚmeshgridÚlinspacer/   r0   ÚravelÚ_add_padr   r   )
r1   Útransform_xyÚx1Úy1Úx2Úy2ÚxÚyÚxtÚyts
             r(   Ú__call__zExtremeFinderSimple.__call__A   s‹   € ô& �{‰{Ü�K‰K˜˜B §¡Ó(¬"¯+©+°b¸"¸d¿g¹gÓ*FóH‰ˆˆ1áœbŸh™h q›k¬2¯8©8°A«;Ó7‰ˆˆBØ�}‰}˜RŸV™V›X r§v¡v£x°·±³¸2¿6¹6»8ÓDÐDr*   c                 ón   — ||z
  | j                   z  }||z
  | j                  z  }||z
  ||z   ||z
  ||z   fS )z,Perform the padding mentioned in `__call__`.r.   )r1   Úx_minÚx_maxÚy_minÚy_maxÚdxÚdys          r(   r7   zExtremeFinderSimple._add_padY   sE   € à�e‰m˜tŸw™wÑ&ˆØ�e‰m˜tŸw™wÑ&ˆØ�r‰z˜5 2™: u¨r¡z°5¸2±:Ð=Ð=r*   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   rA   r7   © r*   r(   r,   r,   2   s   „ ñòòEó0>r*   r,   c                   ó6   ‡ — e Zd ZdZdxZZˆ fd„Zd„ Zd„ Zˆ xZ	S )Ú_User2DTransformz.A transform defined by two user-set functions.é   c                 ó>   •— t         ‰| �  «        || _        || _        y)zÞ
        Parameters
        ----------
        forward, backward : callable
            The forward and backward transforms, taking ``x`` and ``y`` as
            separate arguments and returning ``(tr_x, tr_y)``.
        N)Úsuperr2   Ú_forwardÚ	_backward)r1   ÚforwardÚbackwardÚ	__class__s      €r(   r2   z_User2DTransform.__init__e   s   ø€ ô 	‰ÑÔØˆŒØ!ˆ�r*   c                 ól   — t        j                   | j                  t        j                  |«      Ž «      S ©N)r   Ú	transposerS   )r1   Úvaluess     r(   Útransform_non_affinez%_User2DTransform.transform_non_affines   s%   € ä�|‰|˜M˜DŸM™M¬2¯<©<¸Ó+?Ð@ÓAÐAr*   c                 óN   —  t        | «      | j                  | j                  «      S rY   )ÚtyperT   rS   ©r1   s    r(   Úinvertedz_User2DTransform.invertedw   s   € àŒt�D‹z˜$Ÿ.™.¨$¯-©-Ó8Ð8r*   )
rI   rJ   rK   rL   Ú
input_dimsÚoutput_dimsr2   r\   r`   Ú__classcell__©rW   s   @r(   rO   rO   `   s    ø„ Ù8à Ð €J�ô"òBö9r*   rO   c                   óV   — e Zd ZdZ	 	 	 	 	 dd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	eZ
d	„ Zd
„ Zd„ Zy)Ú
GridFinderzŸ
    Internal helper for `~.grid_helper_curvelinear.GridHelperCurveLinear`, with
    the same constructor parameters; should not be directly instantiated.
    Nc                 óè   — |€t        dd«      }|€
t        «       }|€
t        «       }|€
t        «       }|€
t        «       }|| _        || _        || _        || _        || _        | j                  |«       y )Né   )	r,   ÚMaxNLocatorÚFormatterPrettyPrintÚextreme_finderÚgrid_locator1Úgrid_locator2Útick_formatter1Útick_formatter2Úset_transform)r1   Ú	transformrk   rl   rm   rn   ro   s          r(   r2   zGridFinder.__init__‚   s‚   € ð Ð!Ü0°°RÓ8ˆNØÐ Ü'›MˆMØÐ Ü'›MˆMØÐ"Ü2Ó4ˆOØÐ"Ü2Ó4ˆOØ,ˆÔØ*ˆÔØ*ˆÔØ.ˆÔØ.ˆÔØ×Ñ˜9Õ%r*   c                 óÈ   — t        j                  | j                  | j                  dœ|¬«      }t	        |t
        j                  «      r|j                  |«      S  ||||«      S )a™  
        Helper to support both standard formatters (inheriting from
        `.mticker.Formatter`) and axisartist-specific ones; should be called instead of
        directly calling ``self.tick_formatter1`` and ``self.tick_formatter2``.  This
        method should be considered as a temporary workaround which will be removed in
        the future at the same time as axisartist-specific formatters.
        )r   rP   )r$   )r   Úcheck_getitemrn   ro   Ú
isinstanceÚmtickerÚ	FormatterÚformat_ticks)r1   r$   Ú	directionÚfactorÚlevelsÚfmts         r(   Ú_format_tickszGridFinder._format_ticksš   s^   € ô × Ñ Ø×$Ñ$¨×)=Ñ)=Ñ>ÀCôIˆä,6°s¼G×<MÑ<MÔ,N�× Ñ  Ó(ð 	5Ù˜ F¨FÓ3ð	5r*   c           	      ó¼  — | j                  | j                  ||||«      }|\  }}}}	| j                  ||«      \  }
}}t        j                  |
«      }
| j                  ||	«      \  }}}t        j                  |«      }|
d| |z  }|d| |z  }| j                  ||||||	«      \  }}t        j                  ||||«      j                  dd«      }d|i}dd|
|||fdd||||ffD ]í  \  }}}}}}|D �cg c]  }|g‘Œ c}g g g g dœd	œx||<   }t        |||«      D ]a  \  \  }}} }!t        t        j                  ||g«      |«      }"t        g d¢|"«      D ]&  \  }#}$|$D ]  }%|d
   |#   j                  |!|%dœ«       Œ Œ( Œc |d
   D ]M  }#|d
   |#   D �&cg c]  }&|&d   ‘Œ	 }}&| j                  ||#||«      }'t        |d
   |#   |'«      D ]
  \  }&}(|(|&d<   Œ ŒO Œï |S c c}w c c}&w )z˜
        lon_values, lat_values : list of grid values. if integer is given,
                           rough number of grids in each direction.
        Ngp¾   ð?Úextremesr   ÚlonrP   Úlat)ÚleftÚrightÚbottomÚtop)ÚlinesÚticksr†   )ÚlevelÚlocr‡   Úlabel)rk   Úinv_transform_xyrl   r   Úasarrayrm   Ú_get_raw_grid_linesr   Úfrom_extentsÚexpandedÚzipr)   Úcolumn_stackr   r|   ))r1   r9   r:   r;   r<   r~   Úlon_minÚlon_maxÚlat_minÚlat_maxÚlon_levsÚlon_nÚ
lon_factorÚlat_levsÚlat_nÚ
lat_factorÚ
lon_valuesÚ
lat_valuesÚ	lon_linesÚ	lat_linesÚbbÚ	grid_infor$   Ú
lon_or_latÚlevsry   r[   r…   ÚlÚgiÚlxÚlyr%   r‡   Úall_crossingsÚsider   r&   ÚtickÚlabelsr‰   s)                                            r(   Úget_grid_infozGridFinder.get_grid_info§   sh  € ð ×&Ñ& t×'<Ñ'<¸bÀ"ÀbÈ"ÓMˆð
 .6Ñ*ˆ�˜' 7Ø&*×&8Ñ&8¸À'Ó&JÑ#ˆ�%˜Ü—:‘:˜hÓ'ˆØ&*×&8Ñ&8¸À'Ó&JÑ#ˆ�%˜Ü—:‘:˜hÓ'ˆà˜f˜uÐ%¨
Ñ2ˆ
Ø˜f˜uÐ%¨
Ñ2ˆ
à#×7Ñ7¸
Ø8BØ8?ÀØ8?Àó JÑˆ	�9ô
 ×Ñ˜r 2 r¨2Ó.×7Ñ7¸	À9ÓMˆð ˜ð
ˆ	ð �E˜8 Z°¸YÐGØ�E˜8 Z°¸YÐGó=
Ñ8ˆC�˜T 6¨6°5ñ
 (-Ó-¡u !˜1š# uÑ-Ø"$¨r¸RÈÑKñ*ð ˆI�jÑ! Bô '*¨%°¸Ö&>Ñ"‘��R˜!˜UÜ 8¼¿¹È"ÈbÈÓ9RÐTVÓ W�Ü'*Ú:¸Mö(K‘O�D˜)ã$-˜Ø˜7™ DÑ)×0Ñ0¸5ÈÑ1RÕSñ %.ñ(Kð '?ð ˜7œ�Ø24°W±+¸dÒ2CÓDÑ2C¨$˜˜W›Ð2C�ÐDØ×+Ñ+¨C°°v¸tÓD�Ü#& r¨'¡{°4Ñ'8¸&Ö#A‘K�D˜%Ø$)�D˜’Mñ $Bñ $ð=
ð( Ðùò .ùò Es   Ã0
GÆGc           
      óF  — t        j                  ||d«      }t        j                  ||d«      }|D �	cg c](  }	| j                  t        j                  ||	«      |«      ‘Œ* }
}	|D �cg c](  }| j                  |t        j                  ||«      «      ‘Œ* }}|
|fS c c}	w c c}w )Néd   )r   r5   r8   Ú	full_like)r1   r›   rœ   r‘   r’   r“   r”   Úlons_iÚlats_ir   r�   r€   rž   s                r(   rŒ   zGridFinder._get_raw_grid_linesÝ   s³   € ô —‘˜W g¨sÓ3ˆÜ—‘˜W g¨sÓ3ˆñ !+ó,Ù *˜ð ×&Ñ&¤r§|¡|°F¸CÓ'@À&ÕIØ *ð 	ð ,ñ !+ó,Ù *˜ð ×&Ñ& v¬r¯|©|¸FÀCÓ/HÕIØ *ð 	ð ,ð ˜)Ð#Ð#ùò,ùò,s   ³-BÁ&-Bc                 ó²   — t        |t        «      r|| _        y t        |«      dk(  r't	        t        t        |«      «      rt        |Ž | _        y t        d«      ‚)NrP   zF'aux_trans' must be either a Transform instance or a pair of callables)	rt   r   Ú_aux_transformÚlenÚallÚmapÚcallablerO   Ú	TypeError)r1   Ú	aux_transs     r(   rp   zGridFinder.set_transformë   sM   € Ü�i¤Ô+Ø"+ˆDÕÜ�‹^˜qÒ ¤S¬¬X°yÓ)AÔ%BÜ"2°IÐ">ˆDÕäð >ó ?ð ?r*   c                 ó   — | j                   S rY   )r²   r_   s    r(   Úget_transformzGridFinder.get_transformô   s   € Ø×"Ñ"Ð"r*   c                 óv   — | j                   j                  t        j                  ||g«      «      j                  S rY   )r²   rq   r   r�   r   ©r1   r=   r>   s      r(   r8   zGridFinder.transform_xyù   s,   € Ø×"Ñ"×,Ñ,¬R¯_©_¸aÀ¸VÓ-DÓE×GÑGÐGr*   c                 ó’   — | j                   j                  «       j                  t        j                  ||g«      «      j
                  S rY   )r²   r`   rq   r   r�   r   r¼   s      r(   rŠ   zGridFinder.inv_transform_xyü   s9   € Ø×"Ñ"×+Ñ+Ó-×7Ñ7Ü�O‰O˜Q ˜FÓ#ó%ß%&¡Qð	'r*   c                 ór   — |j                  «       D ]$  \  }}|dv rt        | ||«       Œt        d|›�«      ‚ y )N)rk   rl   rm   rn   ro   zUnknown update property )ÚitemsÚsetattrÚ
ValueError)r1   ÚkwargsÚkr%   s       r(   ÚupdatezGridFinder.update   sD   € Ø—L‘L–N‰DˆAˆqØð (ñ (ô
 ˜˜a Õ#ä Ð#;¸A¸5Ð!AÓBÐBñ #r*   )NNNNN)rI   rJ   rK   rL   r2   r|   r«   rŒ   rp   rº   Úupdate_transformr8   rŠ   rÄ   rM   r*   r(   rf   rf   |   sP   „ ñð !%Ø#Ø#Ø!%Ø!%ó&ò05ò4òl$ò?ò#ð %ÐòHò'ó	Cr*   rf   c                   ó4   ‡ — e Zd Z	 	 	 	 	 dˆ fd„	Zˆ fd„Zˆ xZS )ri   c                 óN   •— t         ‰| �  |||||¬«       | j                  «        y )N)ÚstepsÚintegerÚ	symmetricÚprune)rR   r2   Úcreate_dummy_axis)r1   ÚnbinsrÈ   ÚtrimrÉ   rÊ   rË   rW   s          €r(   r2   zMaxNLocator.__init__  s.   ø€ ô 	‰Ñ˜ e°WØ#,°Eð 	ô 	;à×ÑÕ r*   c                 óf   •— t         ‰| �  ||«      }t        j                  |«      t	        |«      dfS ©Nr   )rR   Útick_valuesr   Úarrayr³   )r1   Úv1Úv2ÚlocsrW   s       €r(   rA   zMaxNLocator.__call__  s-   ø€ Ü‰wÑ" 2 rÓ*ˆÜ�x‰x˜‹~œs 4›y¨!Ð+Ð+r*   )é
   NTFFN©rI   rJ   rK   r2   rA   rc   rd   s   @r(   ri   ri     s!   ø„ Ø'+ØØØ Øõ	!÷,ð ,r*   ri   c                   ó   — e Zd Zd„ Zd„ Zy)ÚFixedLocatorc                 ó   — || _         y rY   )Ú_locs)r1   rÕ   s     r(   r2   zFixedLocator.__init__  s	   € Øˆ�
r*   c                 óÀ   — t        ||g«      \  }}t        j                  | j                  D �cg c]  }||cxk  r|k  sŒn n|‘Œ c}«      }|t	        |«      dfS c c}w rÐ   )Úsortedr   rÒ   rÛ   r³   )r1   rÓ   rÔ   r£   rÕ   s        r(   rA   zFixedLocator.__call__   sV   € Ü˜˜R˜Ó!‰ˆˆBÜ�x‰x D§J¢JÓ@¡J˜q°"¸´-¸R¶-š JÑ@ÓAˆØ”S˜“Y Ð!Ð!ùò As
   ®A¿AN©rI   rJ   rK   r2   rA   rM   r*   r(   rÙ   rÙ     s   „ òó"r*   rÙ   c                   ó   — e Zd Zdd„Zd„ Zy)rj   c                 óp   — t        j                  |d¬«      | _        | j                  j                  «        y )NF)ÚuseMathTextÚ	useOffset)ru   ÚScalarFormatterÚ_fmtrÌ   )r1   rá   s     r(   r2   zFormatterPrettyPrint.__init__)  s)   € Ü×+Ñ+Ø#¨uô6ˆŒ	à�	‰	×#Ñ#Õ%r*   c                 ó8   — | j                   j                  |«      S rY   )rä   rw   )r1   rx   ry   r[   s       r(   rA   zFormatterPrettyPrint.__call__.  s   € Ø�y‰y×%Ñ% fÓ-Ð-r*   N)TrÞ   rM   r*   r(   rj   rj   (  s   „ ó&ó
.r*   rj   c                   ó&   ‡ — e Zd Zdˆ fd„	Zd„ Zˆ xZS )ÚDictFormatterc                 ó>   •— t         ‰| �  «        || _        || _        y)zq
        format_dict : dictionary for format strings to be used.
        formatter : fall-back formatter
        N)rR   r2   Ú_format_dictÚ_fallback_formatter)r1   Úformat_dictÚ	formatterrW   s      €r(   r2   zDictFormatter.__init__3  s    ø€ ô
 	‰ÑÔØ'ˆÔØ#,ˆÕ r*   c                 óÞ   — | j                   r| j                  |||«      }ndgt        |«      z  }t        ||«      D ��cg c]!  \  }}| j                  j	                  ||«      ‘Œ# c}}S c c}}w )zG
        factor is ignored if value is found in the dictionary
        Ú )rê   r³   r�   ré   Úget)r1   rx   ry   r[   Úfallback_stringsrÃ   r%   s          r(   rA   zDictFormatter.__call__<  s|   € ð ×#Ò#Ø#×7Ñ7Ø˜6 6ó +Ñð !#˜t¤c¨&£kÑ1Ðä Ð(8Ô9ô;Ù9‘D�A�qð ×!Ñ!×%Ñ% a¨Õ+Ø9ò;ð 	;ùó ;s   ¿&A)rY   r×   rd   s   @r(   rç   rç   2  s   ø„ õ-ö
;r*   rç   )Únumpyr   Ú
matplotlibr   ru   r   Úmatplotlib.transformsr   r   r)   r,   rO   rf   ri   rÙ   rj   rç   rM   r*   r(   Ú<module>rô      sj   ðÛ ç .ß 1ò(÷V+>ñ +>ô\9�yô 9÷8MCñ MCô`,�'×%Ñ%ô ,÷ "ñ "÷.ñ .÷;ò ;r*   