
    h9                       S r SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
Jr  SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKr SSKJr  SSKrSSKJrJr   " S S5      rS rS	 r " S
 S5      rS r " S S5      r  " S S5      r! " S S\"5      r#\RH                  S.S jr%S r&S r'S r(S r)S`S jr*SaS jr+S r,SbS jr-S r.\,4S jr/ " S  S!5      r0ScS" jr1\Rd                  S4S# jr3 " S$ S%5      r4 " S& S'5      r5S( r6S) r7S* r8SS+.S, jr9SdS- jr:S.S/S0S1S2.r;\;Ry                  5        V Vs0 s H  u  pX_M	     snn r=S3 r>S4 r?S5 r@S6 rAS7 rBSeS8 jrCS9 rDS: rES; rFS< \D\D\E\FS=.rGS> rHS? rIS@ rJSA rKSfSB jrL\R                  SC 5       rN\R                  " \P\R                  " SD5      SE94SF jrRSG rSSH rTSI rUSJ rVSK rW\R                  SL 5       rX " SM SN\R                  R                  5      r[SO r\SP r]SQ r^SR r_SS r`ST raSU rbSV rcSW rd\R                  SfSX j5       rfSY rgSZ rhS[ riS\ rjS] rkS^ rlS_ rmg! \ a
    SSKJr   GNf = fs  snn f )gz
A collection of utility functions and classes.  Originally, many
(but not all) were from the Python Cookbook -- hence the name cbook.
    N)Path)VisibleDeprecationWarning)_api_c_internal_utilsc                   4    \ rS rSrSrS r\S 5       rS rSr	g)_ExceptionInfo#   a{  
A class to carry exception information around.

This is used to store and later raise exceptions. It's an alternative to
directly storing Exception instances that circumvents traceback-related
issues: caching tracebacks can keep user's objects in local namespaces
alive indefinitely, which can lead to very surprising memory issues for
users and result in incorrect tracebacks.
c                     Xl         X l        g N_cls_args)selfclsargss      B/var/www/html/env/lib/python3.13/site-packages/matplotlib/cbook.py__init___ExceptionInfo.__init__.   s    	
    c                 :    U " [        U5      /UR                  Q76 $ r   )typer   )r   excs     r   from_exception_ExceptionInfo.from_exception2   s    49(sxx((r   c                 4    U R                   " U R                  6 $ r   r   r   s    r   to_exception_ExceptionInfo.to_exception6   s    yy$**%%r   )r   r   N)
__name__
__module____qualname____firstlineno____doc__r   classmethodr   r   __static_attributes__ r   r   r   r   #   s%     ) )&r   r   c                     [         R                  R                  S5      =(       dk    [         R                  R                  S5      =(       dE    [         R                  R                  S5      =(       d    [         R                  R                  S5      n U (       a   U R                  R	                  5       (       a  g[         R                  R                  S5      nU(       aR  UR
                  S:X  a  SS	KJn  UR                  5       (       a  g
UR
                  S:X  a  UR                  5       (       a  g[         R                  R                  S5      nU(       a  UR                  5       (       a  g[         R                  R                  S5      nU(       a  UR                  R                  UR                  R                  R                  1n[         R                  " 5       R                  5        H3  nU(       d  M  UR                   U;   a    gUR"                  nU(       a  M'  M5     A[         R                  R                  S5      nU(       a  UR%                  5       (       a  g[&        R(                  " 5       (       d  gg)a  
Return the interactive framework whose event loop is currently running, if
any, or "headless" if no event loop can be started, or None.

Returns
-------
Optional[str]
    One of the following values: "qt", "gtk3", "gtk4", "wx", "tk",
    "macosx", "headless", ``None``.
zPyQt6.QtWidgetszPySide6.QtWidgetszPyQt5.QtWidgetszPySide2.QtWidgetsqtzgi.repository.Gtk   r   )GLibgtk4   gtk3wxtkintertkzmatplotlib.backends._macosxmacosxheadlessN)sysmodulesgetQApplicationinstanceMAJOR_VERSIONgi.repositoryr*   
main_depth
main_levelGetAppmainloop__code__Misc_current_framesvaluesf_codef_backevent_loop_is_runningr   display_is_valid)	QtWidgetsGtkr*   r.   r/   codesframer1   s           r   "_get_running_interactive_frameworkrJ   :   s    	)* 	0;;??./	0;;??,-	0 ;;??./	  Y++4466
++//-
.C
!*  !cnn&6&6		B	biikkkkooi(G!!**GLL,A,A,J,JK((*113E%<<5( % 4 [[__:;F&..00--//r   c                 N    [        5       S;   a  U e[        R                  " 5         g )N)r2   N)rJ   	traceback	print_exc)r   s    r   _exception_printerrN   l   s    )+/AA	r   c                   0    \ rS rSrSrS rS rS rS rSr	g)	
_StrongRefs   zM
Wrapper similar to a weakref, but keeping a strong reference to the object.
c                     Xl         g r   _obj)r   objs     r   r   _StrongRef.__init__x   s    	r   c                     U R                   $ r   rS   r   s    r   __call___StrongRef.__call__{   s    yyr   c                 b    [        U[        5      =(       a    U R                  UR                  :H  $ r   )
isinstancerP   rT   )r   others     r   __eq___StrongRef.__eq__~   s!    %,Hejj1HHr   c                 ,    [        U R                  5      $ r   )hashrT   r   s    r   __hash___StrongRef.__hash__   s    DIIr   rS   N)
r   r    r!   r"   r#   r   rX   r]   ra   r%   r&   r   r   rP   rP   s   s    Ir   rP   c                 f     [         R                  " X5      $ ! [         a    [        U 5      s $ f = f)zI
Return a `WeakMethod` wrapping *func* if possible, else a `_StrongRef`.
)weakref
WeakMethod	TypeErrorrP   )funccallbacks     r   _weak_or_strong_refri      s2     !!$11  $ s    00c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
_UnhashDict   z
A minimal dict-like class that also supports unhashable keys, storing them
in a list of key-value pairs.

This class only implements the interface needed for `CallbackRegistry`, and
tries to minimize the overhead for the hashable case.
c                 >    0 U l         / U l        U H	  u  p#X0U'   M     g r   _dict_pairs)r   pairskvs       r   r   _UnhashDict.__init__   s#    
DAG r   c                      X R                   U'   g ! [         aX    [        U R                  5       H   u  nu  pEXA:X  d  M  X4U R                  U'      g    U R                  R	                  X45         g f = fr   )ro   rf   	enumeraterp   append)r   keyvalueirr   rs   s         r   __setitem___UnhashDict.__setitem__   sg    	1#JJsO 	1&t{{3	6A8&)\DKKN 4
 ""C<0	1s    *A3A3A32A3c                      U R                   U   $ ! [         a     Of = fU R                   H  u  p#X!:X  d  M  Us  $    [        U5      er   )ro   rf   rp   KeyError)r   rx   rr   rs   s       r   __getitem___UnhashDict.__getitem__   sM    	::c?" 		KKDAx   sms    
c                     XR                   ;   a  U R                   R                  U5      $  U(       a  US   $ [        U5      e! [         a<    [        U R                  5       H   u  nu  pEXA:X  d  M  U R                  U	 Us  s $     N\f = fNr   )ro   poprf   rv   rp   r~   )r   rx   r   rz   rr   rs   s         r   r   _UnhashDict.pop   s    	jj zz~~c** ! 7Nsm  	&t{{3	6A8AH 4	s   )A *B
2B
B
	B
c              #   j   #    U R                    S h  vN   U R                   H	  u  pUv   M     g  N7fr   rn   r   rr   rs   s      r   __iter___UnhashDict.__iter__   s,     ::KKDAG   	s   313rn   N)r   r    r!   r"   r#   r   r{   r   r   r   r%   r&   r   r   rk   rk      s     	1r   rk   c                       \ rS rSrSr\4SS.S jjrS rS rS r	S	 r
\R                  S
.S jrS rS r\R"                  SS.S j5       rSrg)CallbackRegistry   aF  
Handle registering, processing, blocking, and disconnecting
for a set of signals and callbacks:

    >>> def oneat(x):
    ...     print('eat', x)
    >>> def ondrink(x):
    ...     print('drink', x)

    >>> from matplotlib.cbook import CallbackRegistry
    >>> callbacks = CallbackRegistry()

    >>> id_eat = callbacks.connect('eat', oneat)
    >>> id_drink = callbacks.connect('drink', ondrink)

    >>> callbacks.process('drink', 123)
    drink 123
    >>> callbacks.process('eat', 456)
    eat 456
    >>> callbacks.process('be merry', 456)   # nothing will be called

    >>> callbacks.disconnect(id_eat)
    >>> callbacks.process('eat', 456)        # nothing will be called

    >>> with callbacks.blocked(signal='drink'):
    ...     callbacks.process('drink', 123)  # nothing will be called
    >>> callbacks.process('drink', 123)
    drink 123

In practice, one should always disconnect all callbacks when they are
no longer needed to avoid dangling references (and thus memory leaks).
However, real code in Matplotlib rarely does so, and due to its design,
it is rather difficult to place this kind of code.  To get around this,
and prevent this class of memory leaks, we instead store weak references
to bound methods only, so when the destination object needs to die, the
CallbackRegistry won't keep it alive.

Parameters
----------
exception_handler : callable, optional
   If not None, *exception_handler* must be a function that takes an
   `Exception` as single parameter.  It gets called with any `Exception`
   raised by the callbacks during `CallbackRegistry.process`, and may
   either re-raise the exception or handle it in another manner.

   The default handler prints the exception (with `traceback.print_exc`) if
   an interactive event loop is running; it re-raises the exception if no
   interactive event loop is running.

signals : list, optional
    If not None, *signals* is a list of signals that this registry handles:
    attempting to `process` or to `connect` to a signal not in the list
    throws a `ValueError`.  The default, None, does not restrict the
    handled signals.
N)signalsc                    Uc  S O
[        U5      U l        Xl        0 U l        [        R
                  " 5       U l        [        / 5      U l        [        5       U l
        g r   )list_signalsexception_handler	callbacks	itertoolscount_cid_genrk   _func_cid_mapset_pickled_cids)r   r   r   s      r   r   CallbackRegistry.__init__  sD     'T']!2!)(_ Ur   c                 >   0 [        U 5      EU R                  R                  5        VVVVs0 s H@  u  pXR                  5        VVs0 s H  u  p4X0R                  ;   d  M  X4" 5       _M     snn_MB     snnnnS [	        U R
                  5      S.E$ s  snnf s  snnnnf )N)r   r   r   )varsr   itemsr   nextr   )r   sdcidproxys        r   __getstate__CallbackRegistry.__getstate__  s    

4j

 '+nn&:&:&<>&<da WWY <Yzs!$(:(:!: +c57lY < <&<> "T]]+

 
	
< >s   BB B+BBc                    UR                  S5      n[        U 5      R                  U5        U R                  R	                  5        VVVVs0 s HU  u  p4UUR	                  5        VVs0 s H1  u  pVU[        U[        R                  " U R                  U5      5      _M3     snn_MW     snnnnU l        [        S U R                  R	                  5        5       5      U l
        [        R                  " U5      U l        g s  snnf s  snnnnf )Nr   c              3   d   #    U  H&  u  pUR                  5         H  u  p4X4U4v   M     M(     g 7fr   )r   ).0r   r   r   r   s        r   	<genexpr>0CallbackRegistry.__setstate__.<locals>.<genexpr>   s5      )L.:3 ZAJ .s   .0)r   r   updater   r   ri   	functoolspartial_remove_proxyrk   r   r   r   r   )r   state	cid_countr   r   r   rg   s          r   __setstate__CallbackRegistry.__setstate__  s    IIj)	T
%  ,,.0 / !",!*IC (y/@/@ASASUV/WXX!*, ,.0 ) )L,,.)L L "	2,0s   D
'8C=D
=D
c                 z   U R                   b  [        R                  " U R                   US9  [        U[        R
                  " U R                  U5      5      n U R                  X4   $ ! [         aG    [        U R                  5      =o@R                  X4'   X0R                  R                  U0 5      U'   Us $ f = f)z?Register *func* to be called when signal *signal* is generated.signal)r   r   check_in_listri   r   r   r   r   r~   r   r   r   
setdefault)r   r   rg   r   r   s        r   connectCallbackRegistry.connect%  s    ==$t}}V<#D)*;*;D<N<NPV*WX	%%fm44 	6:4==6IIC$$V]39>NN%%fb1#6J	s   A) )AB:9B:c                 ^    U R                  X5      nU R                  R                  U5        U$ )zc
Like `.connect`, but the callback is kept when pickling/unpickling.

Currently internal-use only.
)r   r   add)r   r   rg   r   s       r   _connect_picklable#CallbackRegistry._connect_picklable1  s+     ll6(s#
r   )_is_finalizingc                   U" 5       (       a  g U R                   R                  X4S 5      nUb,  U R                  U   U	 U R                  R	                  U5        Og [        U R                  U   5      S:X  a  U R                  U	 g g r   )r   r   r   r   discardlen)r   r   r   r   r   s        r   r   CallbackRegistry._remove_proxy=  s|      $$f_d;?v&s+&&s+t~~f%&!+v& ,r   c                 n   U R                   R                  U5        U R                   H  u  p#U R                  X#4   U:X  d  M    O   gU R                  U   U   U:X  d   eU R                  U   U	 U R                  R	                  X#45        [        U R                  U   5      S:X  a  U R                  U	 gg)zs
Disconnect the callback registered with callback id *cid*.

No error is raised if such a callback does not exist.
Nr   )r   r   r   r   r   r   )r   r   r   r   s       r   
disconnectCallbackRegistry.disconnectJ  s     	""3'!//MF!!&-0C7 0 ~~f%c*e333NN6"3'/t~~f%&!+v& ,r   c                 h   U R                   b  [        R                  " U R                   US9  [        U R                  R                  U0 5      R                  5       5       H  nU" 5       nUc  M   U" U0 UD6  M     g! [         a*  nU R                  b  U R                  U5         SnAMK  e SnAff = f)z
Process signal *s*.

All of the functions registered to receive callbacks on *s* will be
called with ``*args`` and ``**kwargs``.
Nr   )	r   r   r   r   r   r5   rA   	Exceptionr   )r   r   r   kwargsrefrg   r   s          r   processCallbackRegistry.process\  s     ==$t}}Q7**1b188:;C5D$)&)	 < ! --9..s33	s   0A==
B1B,+B,,B1r   c             #      #    U R                   n Uc  0 U l         O"U Vs0 s H  o3U:w  d  M
  X2U   _M     snU l         Sv   X l         gs  snf ! X l         f = f7f)a  
Block callback signals from being processed.

A context manager to temporarily block/disable callback signals
from being processed by the registered listeners.

Parameters
----------
signal : str, optional
    The callback signal to block. The default is to block all signals.
N)r   )r   r   origrr   s       r   blockedCallbackRegistry.blockedr  s[      ~~		"~!# 7;!Jd6k*!!W*d!J!N "K "Ns1   AA 	A	AA AA AA)r   r   r   r   r   r   )r   r    r!   r"   r#   rN   r   r   r   r   r   r3   is_finalizingr   r   r   
contextlibcontextmanagerr   r%   r&   r   r   r   r      se    6x *< # #

3
 >A=N=N ''$,  $ " "r   r   c                   (    \ rS rSrSrSS jrS rSrg)silent_listi  a  
A list with a short ``repr()``.

This is meant to be used for a homogeneous list of artists, so that they
don't cause long, meaningless output.

Instead of ::

    [<matplotlib.lines.Line2D object at 0x7f5749fed3c8>,
     <matplotlib.lines.Line2D object at 0x7f5749fed4e0>,
     <matplotlib.lines.Line2D object at 0x7f5758016550>]

one will get ::

    <a list of 3 Line2D objects>

If ``self.type`` is None, the type name is obtained from the first item in
the list (if any).
Nc                 :    Xl         Ub  U R                  U5        g g r   )r   extend)r   r   seqs      r   r   silent_list.__init__  s    	?KK r   c                     U R                   c  [        U 5      S:w  aC  U R                   b  U R                   O[        U S   5      R                  nS[        U 5       SU S3$ g)Nr   z<a list of  z	 objects>z<an empty list>)r   r   r   )r   tps     r   __repr__silent_list.__repr__  sT    99 CIN"ii3d1g9O9OB T1RD	::$r   )r   r   )r   r    r!   r"   r#   r   r   r%   r&   r   r   r   r     s    (
%r   r   )warning_clsc                    U nU H<  nUR                  US 5      nUc  M  Uc  UnM!  [        R                  " SU S3U5        M>     U$ )N"z"" keyword argument will be ignored)r   r   warn_external)	local_varr   r   keysoutrx   	kwarg_vals          r   _local_over_kwdictr     sW     CJJsD)	 {""Qse+M#N#.0  Jr   c                     [        U 5      S:  a8  U S   U S   s=:X  a  S:X  a%  O  U $ U SS n S H  u  pU R                  X5      n M     U $ )z]
Remove latex formatting from mathtext.

Only handles fully math and fully non-math strings.
   r   $   )	)z\timesx)z\mathdefault )z\rmr   )z\calr   )z\ttr   )z\itr   )\r   ){r   )}r   )r   replace)r   texplains      r   
strip_mathr     s\     1v{qtqu++ H aG

JC 		#%A

 Hr   c                 @   Sn U R                  SU5      nU R                  SU5      nUS:  a  US:  a  U OU SU nUR                  5       $ SUs=::  a  U:  a  O  OU SU R                  5       $ U R                  SUS-   5      nUS:  a  [        SU < S35      eUS-   nM  )z+Strip everything from the first unquoted #.r   r   #Nr   zMissing closing quote in: zM. If you need a double-quote inside a string, use escaping: e.g. "the " char")findstrip
ValueError)r   pos	quote_poshash_poswithout_commentclosing_quote_poss         r   _strip_commentr     s    
C
FF3$	66#s#q=#+a<aQy\O"((**(&Y&Yh<%%'' !sIM : 1$ 0 6N NO O $a'C r   c                 .    [        [        U SS5      5      $ )zDReturn whether *obj* looks like a file object with a *write* method.writeN)callablegetattrrU   s    r   is_writable_file_liker    s    GC$/00r   c                 H     U R                  S5        g! [         a     gf = f)zZ
Return whether the given writable file-like object requires Unicode to be
written to it.
r   FT)r   rf   r   s    r   file_requires_unicoder    s+    
	   s    
!!Fc                    [        U [        R                  5      (       a  [        R                  " U 5      n [        U [        5      (       af  U R                  S5      (       a  [        R                  " X5      nO6U R                  S5      (       a  SSKnUR                  X5      nO
[        XUS9nSnO![        U S5      (       a  U nSnO[        S	5      eU(       a  XF4$ U$ )
a  
Convert a path to an open file handle or pass-through a file-like object.

Consider using `open_file_cm` instead, as it allows one to properly close
newly created file objects more easily.

Parameters
----------
fname : str or path-like or file-like
    If `str` or `os.PathLike`, the file is opened using the flags specified
    by *flag* and *encoding*.  If a file-like object, it is passed through.
flag : str, default: 'r'
    Passed as the *mode* argument to `open` when *fname* is `str` or
    `os.PathLike`; ignored if *fname* is file-like.
return_opened : bool, default: False
    If True, return both the file object and a boolean indicating whether
    this was a new file (that the caller needs to close).  If False, return
    only the new file.
encoding : str or None, default: None
    Passed as the *mode* argument to `open` when *fname* is `str` or
    `os.PathLike`; ignored if *fname* is file-like.

Returns
-------
fh : file-like
opened : bool
    *opened* is only returned if *return_opened* is True.
.gzz.bz2r   N)encodingTseekFz'fname must be a PathLike or file handle)r[   osPathLikefspathstrendswithgzipopenbz2BZ2Filehasattrr   )fnameflagreturn_openedr  fhr  openeds          r   to_filehandler    s    : %%%		% %>>%  5'B^^F## U)BeH5B			BCCzIr   c                 ^    [        XSU5      u  p4U(       a  U$ [        R                  " U5      $ )z8Pass through file objects and context-manage path-likes.T)r  r   nullcontext)path_or_filemoder  r  r  s        r   open_file_cmr  .  s*    |4BJB27Z33B77r   c                 f    [        U [        5      =(       d    [        R                  " U 5      (       + $ )z;Return whether the given object is a scalar or string like.)r[   r  npiterablevals    r   is_scalar_or_stringr$  4  s     c37r{{3'7#77r   c                 2   [        SU 5      nU(       az  UR                  R                  5       nUS:X  a  [        R                  " U5      $ US;   a  [
        R                  " U5      $ US;   a  UR	                  S5      $ UR	                  S5      $ [        U5      $ )a  
Return a sample data file.  *fname* is a path relative to the
:file:`mpl-data/sample_data` directory.  If *asfileobj* is `True`
return a file object, otherwise just a file path.

Sample data files are stored in the 'mpl-data/sample_data' directory within
the Matplotlib package.

If the filename ends in .gz, the file is implicitly ungzipped.  If the
filename ends with .npy or .npz, and *asfileobj* is `True`, the file is
loaded with `numpy.load`.
sample_datar  )z.npyz.npz)z.csvz.xrcz.txtrrb)_get_data_pathsuffixlowerr  r  r   loadr  )r  	asfileobjpathr*  s       r   get_sample_datar/  9  s     -/D""$U?99T?"''774= //99S>!99T?"4yr   c                  @    [        [        R                  " 5       /U Q76 $ )z
Return the `pathlib.Path` to a resource file provided by Matplotlib.

``*args`` specify a path relative to the base data path.
)r   
matplotlibget_data_path)r   s    r   r)  r)  U  s     
((*2T22r   c              #   t   #    U  H,  nU" U5      (       d  Uc  Uv   M  [        X!5       Sh  vN   M.     g N	7f)a  
Return a generator of flattened nested containers.

For example:

    >>> from matplotlib.cbook import flatten
    >>> l = (('John', ['Hunter']), (1, 23), [[([42, (5, 23)], )]])
    >>> print(list(flatten(l)))
    ['John', 'Hunter', 1, 23, 42, 5, 23]

By: Composite of Holger Krekel and Luther Blissett
From: https://code.activestate.com/recipes/121294-simple-generator-for-flattening-nested-containers/
and Recipe 1.12 in cookbook
N)flatten)r   scalarpitems      r   r4  r4  ^  s6      4==DLJt---	  .s   *86
8c                   N    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rSrg)_Stackit  zV
Stack of elements with a movable cursor.

Mimics home/back/forward in a web browser.
c                      SU l         / U l        g )Nr   _pos	_elementsr   s    r   r   _Stack.__init__{  s    	r   c                      SU l         / U l        g)zEmpty the stack.r   Nr:  r   s    r   clear_Stack.clear  s    	r   c                 Z    U R                   (       a  U R                   U R                     $ S$ )z$Return the current element, or None.Nr<  r;  r   s    r   rX   _Stack.__call__  s     ,0NNt~~dii(DDr   c                 ,    [        U R                  5      $ r   )r   r<  r   s    r   __len___Stack.__len__  s    4>>""r   c                      U R                   U   $ r   )r<  )r   inds     r   r   _Stack.__getitem__  s    ~~c""r   c                 x    [        U R                  S-   [        U R                  5      S-
  5      U l        U " 5       $ )z9Move the position forward and return the current element.r   )minr;  r   r<  r   s    r   forward_Stack.forward  s-    		As4>>':Q'>?	vr   c                 L    [        U R                  S-
  S5      U l        U " 5       $ )z6Move the position back and return the current element.r   r   )maxr;  r   s    r   back_Stack.back  s    		Aq)	vr   c                 z    U/U R                   U R                  S-   S& [        U R                   5      S-
  U l        U$ )z`
Push *o* to the stack after the current position, and return *o*.

Discard all later elements.
r   N)r<  r;  r   )r   os     r   push_Stack.push  s8     +,tyy1}~&'!+	r   c                 d    U R                   (       a  U R                  U R                   S   5      $ S$ )zS
Push the first element onto the top of the stack.

The first element is returned.
r   N)r<  rT  r   s    r   home_Stack.home  s'     04~~tyy*+G4Gr   rB  N)r   r    r!   r"   r#   r   r?  rX   rE  r   rL  rP  rT  rW  r%   r&   r   r   r8  r8  t  s6    
E##

Hr   r8  c                 d   [         R                  " U SUS9n U R                  R                  (       d7  U R	                  US9R                  U R                  R                  S5      5      n  [         R                  R                  [         R                  " U 5      ) U SS9nU$ ! [         a    U s $ f = f)NT)subokcopy)inplaceNF)r[  )r   arraydtypeisnativebyteswapviewnewbyteordermamasked_whereisfiniterf   )r   r[  xms      r   safe_masked_invalidrh    s    
$T*A77 JJtJ$))!''*>*>s*CDUU"++a. 115A I  s   *4B   B/.B/c                    ^ ^^^^^ SSK mU4S jmUU UUUU4S jmT  H#  nTR                  SU< S35        T" X30 / 5        M%     g)a  
Print loops of cyclic references in the given *objects*.

It is often useful to pass in ``gc.garbage`` to find the cycles that are
preventing some objects from being garbage collected.

Parameters
----------
objects
    A list of objects to find cycles in.
outstream
    The stream for output.
show_progress : bool
    If True, print the number of objects reached as they are found.
r   Nc                   > [        U 5       GH'  u  pXS-   [        U 5      -     nTR                  S[        U5      -  5        [	        U[
        5      (       aQ  UR                  5        H<  u  pEXSL a  TR                  SU< S35          OXCL d  M'  TR                  SU< 35          O}   Oz[	        U[        5      (       a$  TR                  SUR                  U5      -  5        OA[	        U[        5      (       a  TR                  S5        OTR                  [        U5      5        TR                  S5        GM*     TR                  S	5        g )
Nr   z	   %s -- []z[key] = z[%d]z	( tuple )z ->

)rv   r   r   r   r[   dictr   r   indextuplerepr)r.  rz   stepr   rx   r#  	outstreams         r   
print_path print_cycles.<locals>.print_path  s     GAQ#d)+,DOOK$t*45$%% $

HC{!!C7!5{!(3'(:; !- D$''D)9 9:D%((,T
+OOG$' '( 	r   c                 B  > T(       a  TR                  S[        U5      -  5        S U[        U 5      '   TR                  U 5      nU HU  nXQL a
  T	" U5        M  UTL d  [	        U[
        R                  5      (       a  M7  [        U5      U;  d  MH  T
" XQX#U /-   5        MW     g )Nz%d)r   r   idget_referentsr[   types	FrameType)rU   startallcurrent_path	referentsreferentgcobjectsrs  rt  recurseshow_progresss         r   r  print_cycles.<locals>.recurse  s    OOFSX-.BsG$$S)	!H  <(
 W$
8U__(M(M HS(cU.BC "r   zExamining: rm  )r  r   )r  rs  r  rU   r  rt  r  s   ``` @@@r   print_cyclesr    sF      .D D. +cWB/0"b! r   c                   R    \ rS rSrSrSS jrS rS rS rS r	S r
S	 rS
 rS rSrg)Grouperi  a  
A disjoint-set data structure.

Objects can be joined using :meth:`join`, tested for connectedness
using :meth:`joined`, and all disjoint sets can be retrieved by
using the object as an iterator.

The objects being joined must be hashable and weak-referenceable.

Examples
--------
>>> from matplotlib.cbook import Grouper
>>> class Foo:
...     def __init__(self, s):
...         self.s = s
...     def __repr__(self):
...         return self.s
...
>>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef']
>>> grp = Grouper()
>>> grp.join(a, b)
>>> grp.join(b, c)
>>> grp.join(d, e)
>>> list(grp)
[[a, b, c], [d, e]]
>>> grp.joined(a, b)
True
>>> grp.joined(a, c)
True
>>> grp.joined(a, d)
False
c           	      p   [         R                  " U Vs0 s H  o"[         R                  " U/5      _M     sn5      U l        [         R                  " 5       U l        U H6  nX R                  ;  d  M  [        U R                  5      U R                  U'   M8     [        U R                  5      U l        g s  snf r   )rd   WeakKeyDictionaryWeakSet_mapping	_orderingr   _next_order)r   initr   s      r   r   Grouper.__init__   s    11.23d$$d35 224A&$'$7q!  t~~. 4s   !B3c           	          0 [        U 5      EU R                  R                  5        VVs0 s H  u  pU[        U5      _M     snn0 U R                  ES.E$ s  snnf )N)r  r  )r   r  r   r   r  r   s      r   r   Grouper.__getstate__)  s\    
4j
 04}}/B/B/DE/DtqCF/DE+DNN+	
 	
 Fs   Ac           
      H   [        U 5      R                  U5        [        R                  " U R                  R                  5        VVs0 s H  u  p#U[        R                  " U5      _M     snn5      U l        [        R                  " U R                  5      U l        g s  snnf r   )r   r   rd   r  r  r   r  r  )r   r   rr   rs   s       r   r   Grouper.__setstate__1  st    T
% 11/3}}/B/B/DE/DtqQ""/DEG 224>>B Fs   #B
c                     XR                   ;   $ r   )r  r   r6  s     r   __contains__Grouper.__contains__8  s    }}$$r   c                 "   U R                   n X1   nU HF  n X5   nXdLd  M  [        U5      [        U5      :  a  XdpdUR                  U5        U H  nXCU'   M	     MH     g! [         aL    [        R                  " U/5      =oCU'   U R                  U R
                  U'   U =R                  S-  sl         Nf = f! [         aL    [        R                  " U/5      =ocU'   U R                  U R
                  U'   U =R                  S-  sl         Nf = f)zI
Join given arguments into the same set.  Accepts one or more arguments.
r   N)r  r~   rd   r  r  r  r   r   )r   ar   mappingset_aargset_belems           r   joinGrouper.join;  s    --	"JE
 C&
 !u:E
*#(5U#!D$)DM " 	  	"!(!!55EAJ $ 0 0DNN1!	"  &'.u'==&*&6&6s#  A% &s$   A B8AB54B58ADDc                     U R                   R                  U[        5       5      U R                   R                  U5      L $ )z7Return whether *a* and *b* are members of the same set.)r  r5   objectr   r  bs      r   joinedGrouper.joinedT  s/    !!!VX.$--2C2CA2FFGr   c                     U R                   R                  X15      R                  U5        U R                  R                  US5        g)z>Remove *a* from the grouper, doing nothing if it is not there.N)r  r   remover  r   r  s     r   r  Grouper.removeX  s5    !S!((+1d#r   c              #      #    U R                   R                  5        Vs0 s H  n[        U5      U_M     nnUR                  5        H"  n[        XR                  R
                  S9v   M$     gs  snf 7f)zq
Iterate over each of the disjoint sets as a list.

The iterator is invalid if interleaved with calls to join().
rx   N)r  rA   rw  sortedr  r   )r   groupunique_groupss      r   r   Grouper.__iter__]  sa      8<}}7K7K7MN7MeEE)7MN"))+ENN$>$>?? , Os   A3A.>A3c                 t    U R                   R                  X/5      n[        X R                  R                  S9$ )z:Return all of the items joined with *a*, including itself.r  )r  r5   r  r  )r   r  siblingss      r   get_siblingsGrouper.get_siblingsg  s-    ==$$Q,hNN$6$677r   )r  r  r  N)r&   )r   r    r!   r"   r#   r   r   r   r  r  r  r  r   r  r%   r&   r   r   r  r    s8    B/
C%*2H$
@8r   r  c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
GrouperViewim  z!Immutable view over a `.Grouper`.c                     Xl         g r   _grouper)r   groupers     r   r   GrouperView.__init__p  s    r   c                     XR                   ;   $ r   r  r  s     r   r  GrouperView.__contains__q  s    )>">r   c                 ,    [        U R                  5      $ r   )iterr  r   s    r   r   GrouperView.__iter__r  s    tDMM22r   c                 8    U R                   R                  X5      $ )z9
Return whether *a* and *b* are members of the same set.
)r  r  r  s      r   r  GrouperView.joinedt  s     }}##A))r   c                 8    U R                   R                  U5      $ )z<
Return all of the items joined with *a*, including itself.
)r  r  r  s     r   r  GrouperView.get_siblingsz  s     }}))!,,r   r  N)r   r    r!   r"   r#   r   r  r   r  r  r%   r&   r   r   r  r  m  s    +8>2*-r   r  c           
         U R                  [        U 5      S45      n[        R                  " [        U 5      5      U-  n[        R                  " [        U 5      S-
  U-  S-   5      n[        R                  " UR
                   Vs/ s H  n[        R                  " XCU5      PM     sn5      R                  [        U5      4U R                  SS -   5      $ s  snf )aM  
Resample an array with ``steps - 1`` points between original point pairs.

Along each column of *a*, ``(steps - 1)`` points are introduced between
each original values; the values are linearly interpolated.

Parameters
----------
a : array, shape (n, ...)
steps : int

Returns
-------
array
    shape ``((n - 1) * steps + 1, ...)``
r   r   N)reshaper   r   arangecolumn_stackTinterpshape)r  stepsfpsxpr   fps         r   simple_linear_interpolationr    s    " ))SVRL
!C	3q6	U	"B
		3q6A:&*+AOOCEEBEbRYYqb1EBCWc!fY,-/Bs   !Cc                     [        U 5      (       d  g[        U S   5      (       a  [        S5      e[        U S   5      n/ nS/[        U 5      -  n[        U 5       H  u  pE[	        U[
        5      (       d  [        R                  " U5      (       an  [        U5      U:X  a_  SX4'   [	        U[        R                  R                  5      (       a  UR                  S:  a  [        S5      eO[        R                  " U5      nUR                  U5        M     / n[        U5       H  u  pEX4   (       d  M  UR                  S:  a  M"  [	        U[        R                  R                  5      (       a<  UR                  [        R                  R                  U5      ) 5        UR                  nOUn [        R                  " U5      n[	        U[        R                   5      (       a  UR                  U5        M  M     [        U5      (       af  [        R$                  R'                  U5      nUR)                  5       S   n	[        U	5      U:  a%  [        U5       H  u  pEX4   (       d  M  XY   X$'   M     [        U5       HM  u  pEX4   (       d  M  [	        U[        R                  R                  5      (       d  M;  UR+                  5       X$'   MO     U$ ! ["         a     GM  f = f)a  
Find all masked and/or non-finite points in a set of arguments,
and return the arguments with only the unmasked points remaining.

Arguments can be in any of 5 categories:

1) 1-D masked arrays
2) 1-D ndarrays
3) ndarrays with more than one dimension
4) other non-string iterables
5) anything else

The first argument must be in one of the first four categories;
any argument with a length differing from that of the first
argument (and hence anything in category 5) then will be
passed through unchanged.

Masks are obtained from all arguments of the correct length
in categories 1, 2, and 4; a point is bad if masked in a masked
array or if it is a nan or inf.  No attempt is made to
extract a mask from categories 2, 3, and 4 if `numpy.isfinite`
does not yield a Boolean array.

All input arguments that are not passed unchanged are returned
as ndarrays after removing the points or rows corresponding to
masks in any of the arguments.

A vastly simpler version of this function was originally
written as a helper for Axes.scatter().

r&   r   !First argument must be a sequenceFTr   Masked arrays must be 1-D)r   r$  r   rv   r[   r  r   r!  rd  MaskedArrayndimasarrayrw   getmaskarraydatarf  ndarrayr   logical_andreducenonzerofilled)
r   nrecsmargsseqlistrz   r   masksxdmaskigoods
             r   delete_masked_pointsr    s-   @ t9947##<==QLEEgD	!G$!S!!bkk!nnQ5GJ!RUU..//66A:$%@AA  JJqMQ   E% ::vvz!RUU..//bee00334VV{{2dBJJ//LL& 0 ! 5zz~~$$U+q!u:!%(:: xEH ) % ::*Q(9(9::xxzEH ! L  s   )AK		
KKc                  *   [        U 5      (       d  g[        U S   5      (       a  [        S5      e[        U S   5      n/ nS/[        U 5      -  n/ n[        U 5       GH  u  pV[        U5      (       d  [        U5      U:w  a  UR	                  U5        M8  [        U[        R                  R                  5      (       a  UR                  S:  a  [        S5      e [        R                  " U5      nUR                  S:X  aa  [        U5      nSX5'   [        R                  R                  U5      (       a.  UR	                  [        R                  R                  U5      5        UR	                  U5        GM     [        U5      (       a]  [        R                   R#                  U5      n[        U5       H/  u  pVX5   (       d  M  [        R                  R%                  XgS	9X%'   M1     U$ ! [        [        4 a    [        R                  " U[        S9n GN"f = f)
a  
Find all masked and/or non-finite points in a set of arguments,
and return the arguments as masked arrays with a common mask.

Arguments can be in any of 5 categories:

1) 1-D masked arrays
2) 1-D ndarrays
3) ndarrays with more than one dimension
4) other non-string iterables
5) anything else

The first argument must be in one of the first four categories;
any argument with a length differing from that of the first
argument (and hence anything in category 5) then will be
passed through unchanged.

Masks are obtained from all arguments of the correct length
in categories 1, 2, and 4; a point is bad if masked in a masked
array or if it is a nan or inf.  No attempt is made to
extract a mask from categories 2 and 4 if `numpy.isfinite`
does not yield a Boolean array.  Category 3 is included to
support RGB or RGBA ndarrays, which are assumed to have only
valid values and which are passed through unchanged.

All input arguments that are not passed unchanged are returned
as masked arrays if any masked points are found, otherwise as
ndarrays.

r&   r   r  Fr   r  r_  Tr  )r   r$  r   rv   rw   r[   r   rd  r  r  
asanyarrayr   r  rh  	is_maskedr  
logical_orr  r^  )r   r  r  r  r  rz   r   r  s           r   _combine_masksr    s   > t9947##<==QLEEgD	!GE$q!!SVu_LLO!RUU..//AFFQJ !<==3MM!$
 vv{'*!
55??1%%LL!3!3A!67LLO#  $ 5zz}}##E*e$DAzz55;;q;4 % L .z: 3 MM!623s   G%%)HH)compressc           	         U Vs/ s H:  n[        U[        R                  R                  5      (       d  M.  UR                  PM<     nn[        R
                  " / UQUQ76 nUS[        U5       nU[        U5      S nU(       a  [        R                  R                  U5      nU (       a=  U Vs/ s H.  n[        R                  R                  X&S9R                  5       PM0     nnU$ U Vs/ s HP  n[        R                  R                  X&[        S9R                  [        R                  5      R                  5       PMR     nn U$ U Vs/ s H  n[        R                  " U5      PM     nnU$ s  snf s  snf s  snf s  snf )aC  
Broadcast inputs, combining all masked arrays.

Parameters
----------
*args : array-like
    The inputs to broadcast.
compress : bool, default: False
    Whether to compress the masked arrays. If False, the masked values
    are replaced by NaNs.

Returns
-------
list of array-like
    The broadcasted and masked inputs.
Nr  )r  r_  )r[   r   rd  r  r  broadcast_arraysr   r  r  r^  
compressedfloatr  nanravel)r  r   rr   r  bcastinputsr  s          r   _broadcast_with_masksr  '  sN   $ "FTZ2553D3D%EVQVVTEF...E:CIF#d)*E}}##E*%'%! eekk!k/::<%  ' M  &'%! eekk!ek<CCBFFKQQS%  'F M (..v!"((1+v.M# G'' /s   -E.E.-5E3*AE8
 E=c                   ^ SS jmU4S jn/ n[        U S5      n [        U 5      nUc  [        R                  " S5      nO[        U5      U:w  a  [	        S5      eUn[        [        X5      5       GH   u  n	u  p0 nUb  XS'   UnUR                  U5        [        U
5      S:X  a  [        R                  " / 5      US'   [        R                  US	'   [        R                  US
'   [        R                  US'   [        R                  US'   [        R                  US'   [        R                  US'   [        R                  US'   [        R                  US'   [        R                  US'   M  [        R                  R                  U
5      n
U
R                  U
R                  )    R                  5       n
[        R                   " U
5      US	'   [        R"                  " U
/ SQ5      u  pnX-
  US'   US   S:X  a	  U(       a  SnU" XUS   U5      u  US'   US'   [        R$                  " U5      (       a/  ['        U[(        5      (       d  [        R"                  " X5      u  nnO;[        R*                  " U5      (       a  XUS   -  -
  nXUS   -  -   nO[	        S5      eXU:*     n[        U5      S:X  d  [        R,                  " U5      U:  a  XS'   O[        R,                  " U5      US'   XU:     n[        U5      S:X  d  [        R.                  " U5      U:  a  XS'   O[        R.                  " U5      US'   [        R0                  " XUS   :     XUS   :     /5      US'   XUsUS'   US
'   US'   GM     U$ )av
  
Return a list of dictionaries of statistics used to draw a series of box
and whisker plots using `~.Axes.bxp`.

Parameters
----------
X : array-like
    Data that will be represented in the boxplots. Should have 2 or
    fewer dimensions.

whis : float or (float, float), default: 1.5
    The position of the whiskers.

    If a float, the lower whisker is at the lowest datum above
    ``Q1 - whis*(Q3-Q1)``, and the upper whisker at the highest datum below
    ``Q3 + whis*(Q3-Q1)``, where Q1 and Q3 are the first and third
    quartiles.  The default value of ``whis = 1.5`` corresponds to Tukey's
    original definition of boxplots.

    If a pair of floats, they indicate the percentiles at which to draw the
    whiskers (e.g., (5, 95)).  In particular, setting this to (0, 100)
    results in whiskers covering the whole range of the data.

    In the edge case where ``Q1 == Q3``, *whis* is automatically set to
    (0, 100) (cover the whole range of the data) if *autorange* is True.

    Beyond the whiskers, data are considered outliers and are plotted as
    individual points.

bootstrap : int, optional
    Number of times the confidence intervals around the median
    should be bootstrapped (percentile method).

labels : list of str, optional
    Labels for each dataset. Length must be compatible with
    dimensions of *X*.

autorange : bool, optional (False)
    When `True` and the data are distributed such that the 25th and 75th
    percentiles are equal, ``whis`` is set to (0, 100) such that the
    whisker ends are at the minimum and maximum of the data.

Returns
-------
list of dict
    A list of dictionaries containing the results for each column
    of data. Keys of each dictionary are the following:

    ========   ===================================
    Key        Value Description
    ========   ===================================
    label      tick label for the boxplot
    mean       arithmetic mean value
    med        50th percentile
    q1         first quartile (25th percentile)
    q3         third quartile (75th percentile)
    iqr        interquartile range
    cilo       lower notch around the median
    cihi       upper notch around the median
    whislo     end of the lower whisker
    whishi     end of the upper whisker
    fliers     outliers
    ========   ===================================

Notes
-----
Non-bootstrapping approach to confidence interval uses Gaussian-based
asymptotic approximation:

.. math::

    \mathrm{med} \pm 1.57 \times \frac{\mathrm{iqr}}{\sqrt{N}}

General approach from:
McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of
Boxplots", The American Statistician, 32:12-16.
c                     [        U 5      nSS/n[        R                  R                  X!U4S9nX   n[        R                  " USSS9n[        R
                  " Xc5      nU$ )Ng      @g     `X@)sizer   T)axisoverwrite_input)r   r   randomrandintmedian
percentile)r  r]  Mpercentilesbs_indexbsDataestimateCIs           r   _bootstrap_median(boxplot_stats.<locals>._bootstrap_median  s[    IDk99$$QV$499V!TB]]81	r   c                    > Ub  T" XS9nUS   nUS   nXV4$ [        U 5      nUSU-  [        R                  " U5      -  -
  nUSU-  [        R                  " U5      -  -   nXV4$ )N)r]  r   r   gQ?)r   r   sqrt)	r  mediqr	bootstrapr  	notch_min	notch_maxr]  r  s	           r   _compute_conf_interval-boxplot_stats.<locals>._compute_conf_interval  s|      #45B1I1I ##	 D	AdSj2771:55IdSj2771:55I##r   XNz-Dimensions of labels and X must be compatiblelabelr   fliersmeanr
  q1q3r  cilocihiwhislowhishi)   2   K   )r   d   z+whis must be a float or list of percentiles)i  )_reshape_2Dr   r   repeatr   rv   ziprw   r   r^  r  rd  r  r  r  r  r  r  r!  r[   r  isrealrO  rK  concatenate)r  whisr  labels	autoranger  bxpstatsncols
input_whisiir   r  statsr  r
  r  lovalhivalwiskhiwisklor  s                       @r   boxplot_statsr0  M  s   ^
$  H 	AsAFE~!!$'	V	HIIJ#CN3JQ "'N  	 q6Q; hhrlE(OFFE&M66E%L&&E$K&&E$K66E%LFFE&MFFE&M ffE(O ffE(O EEMM!FFAFF7O!!# 
f mmA|4 we<1D (>E%L)(
$fuV}
 ;;tZc%:%:==1LE5YYt__e,,Ee,,EJKK :v;!rvvf~2 (O ffVnE(O :v;!rvvf~2 (O ffVnE(O ..%/!"%/!"*
 h 24".dU5\5;[ 4^ Or   soliddasheddashdotdotted)-z--z-.:c           	      p   [         R                  " U [        S9n U R                  (       d  / $ [         R                  " U SS U SS :g  5      u  nUS-  nUR                  5       nU S   (       a  S/U-   nU S   (       a  UR                  [        U 5      5        [        [        USSS2   USSS2   5      5      $ )zj
Return a list of (ind0, ind1) such that ``mask[ind0:ind1].all()`` is
True and we cover all such regions.
r  Nr   r   r   r   )
r   r  boolr  r  tolistrw   r   r   r!  )r  idxs     r   contiguous_regionsr;    s    
 ::d$'D99	 ::d3Bi48+,DC1HC **,C AwcCiBx

3t9C!Hc!$Q$i())r   c                     [        U 5      n U R                  S5      U R                  S5      -
  nUS:  =(       a    US-  S:H  nU$ )z
Return whether the string *s* contains math expressions.

This is done by checking whether *s* contains an even number of
non-escaped dollar signs.
r   z\$r   r   )r  r   )r   dollar_counteven_dollarss      r   is_math_textr?  6  sF     	AA774=1775>1L 1$>)9Q)>Lr   c                     [        U S5      (       aA  [        R                  R                  U [        5      R                  [        R                  5      $ [        R                  " U [        5      $ )zh
Convert a sequence to a float array; if input was a masked array, masked
values are converted to nans.
r  )r  r   rd  r  r  r  r  r  s    r   _to_unmasked_float_arrayrA  C  sF    
 q&uu}}Q&--bff55zz!U##r   c                     [        U 5      n [        U S5      (       a*  [        U S5      (       a  [        U R                  5      S:  a  [        R
                  " U 5      $ U $ )z8Convert scalars to 1D arrays; pass-through arrays as is.r  r  r   )_unpack_to_numpyr  r   r  r   
atleast_1dr  s    r   	_check_1drE  N  sN     	A Aw6""L1}}Qr   c                 .   [        U 5      n [        U [        R                  5      (       a  U R                  n [        U 5      S:X  a  / /$ U R                  S:X  a   [        R                  " U S   5      S:X  a  U /$ U R                  S;   a(  U  Vs/ s H  n[        R                  " US5      PM     sn$ [        U S35      e[        U 5      S:X  a  / /$ / nSnU  H  n[        U[        5      (       d   [        U5        Sn[        R                  " U5      n[        R                  " U5      nUS:  a  [        U S35      eUR                  UR                  S5      5        M     U(       a  [        R                  " US5      /$ U$ s  snf ! [         a     Nf = f)ap  
Use Fortran ordering to convert ndarrays and lists of iterables to lists of
1D arrays.

Lists of iterables are converted by applying `numpy.asanyarray` to each of
their elements.  1D ndarrays are returned in a singleton list containing
them.  2D ndarrays are converted to the list of their *columns*.

*name* is used to generate the error message for invalid inputs.
r   r   )r   r   r   z  must have 2 or fewer dimensionsTF)rC  r[   r   r  r  r   r  r  r   r  r  rf   r  rw   )r  namer   resultis_1dxinds          r   r  r  ]  sl    	A !RZZ  CCq6Q;4KVVq[RWWQqT]a/3JVVv/01q!BJJq"%q11v%EFGG 1v{tFE "c""R ]]2WWR[6v%EFGGbjjn%   

62&'' ? 2   s   !F0F
FFc                    / n[        U S5      n Ub  [        U5      S:w  a  [        US5      nO/ /[        U 5      -  n[        U 5      [        U5      :w  a  [        S5      e[        X5       H  u  pV0 n[        R
                  " U5      n[        R                  " U5      n	[        R                  " USU-  5      n
[        R                  " XU5      nU" X[5      US'   XS'   [        R                  " U5      US'   [        R                  " U5      US	'   XS
'   XS'   [        R                  " U
5      US'   UR                  U5        M     U$ )a  
Return a list of dictionaries of data which can be used to draw a series
of violin plots.

See the ``Returns`` section below to view the required keys of the
dictionary.

Users can skip this function and pass a user-defined set of dictionaries
with the same keys to `~.axes.Axes.violinplot` instead of using Matplotlib
to do the calculations. See the *Returns* section below for the keys
that must be present in the dictionaries.

Parameters
----------
X : array-like
    Sample data that will be used to produce the gaussian kernel density
    estimates. Must have 2 or fewer dimensions.

method : callable
    The method used to calculate the kernel density estimate for each
    column of data. When called via ``method(v, coords)``, it should
    return a vector of the values of the KDE evaluated at the values
    specified in coords.

points : int, default: 100
    Defines the number of points to evaluate each of the gaussian kernel
    density estimates at.

quantiles : array-like, default: None
    Defines (if not None) a list of floats in interval [0, 1] for each
    column of data, which represents the quantiles that will be rendered
    for that column of data. Must have 2 or fewer dimensions. 1D array will
    be treated as a singleton list containing them.

Returns
-------
list of dict
    A list of dictionaries containing the results for each column of data.
    The dictionaries contain at least the following:

    - coords: A list of scalars containing the coordinates this particular
      kernel density estimate was evaluated at.
    - vals: A list of scalars containing the values of the kernel density
      estimate at each of the coordinates given in *coords*.
    - mean: The mean value for this column of data.
    - median: The median value for this column of data.
    - min: The minimum value for this column of data.
    - max: The maximum value for this column of data.
    - quantiles: The quantile values for this column of data.
r  r   	quantileszLList of violinplot statistics and quantiles values must have the same lengthr  valscoordsr  r  rK  rO  )r  r   r   r!  r   rK  rO  r  linspacer  r  rD  rw   )r  methodpointsrM  vpstatsr   qr+  min_valmax_valquantile_valrO  s               r   violin_statsrX    s5   j G 	AsA Y1!4	;7	 D3q6M	 1vY 6 7 	7 a# &&)&&)}}Qa0 Wv6q)f h 
f))A,hee]]<8k 	u- $0 Nr   c           	          [         R                  " S[        U5      -   [        S[        U 5      -  S-
  S5      45      nXSSSS24'   USSSS24   USSSS24'   XSS2SSS24'   USS2SSS24   USS2SSS24'   U$ )a  
Convert continuous line to pre-steps.

Given a set of ``N`` points, convert to ``2N - 1`` points, which when
connected linearly give a step function which changes values at the
beginning of the intervals.

Parameters
----------
x : array
    The x location of the steps. May be empty.

y1, ..., yp : array
    y arrays to be turned into steps; all must be the same length as ``x``.

Returns
-------
array
    The x and y values converted to steps in the same order as the input;
    can be unpacked as ``x_out, y1_out, ..., yp_out``.  If the input is
    length ``N``, each of these arrays will be length ``2N + 1``. For
    ``N=0``, the length will be 0.

Examples
--------
>>> x_s, y1_s, y2_s = pts_to_prestep(x, y1, y2)
r   r   r   Nr   zerosr   rO  r   r   r  s      r   pts_to_prestepr^    s    8 HHa#d)mSSVa%;<=E !QTT'N1a1f9%E!QTT'N!"add(OAB1HoE!"add(OLr   c           	          [         R                  " S[        U5      -   [        S[        U 5      -  S-
  S5      45      nXSSSS24'   USSSS24   USSSS24'   XSS2SSS24'   USS2SSS24   USS2SSS24'   U$ )a  
Convert continuous line to post-steps.

Given a set of ``N`` points convert to ``2N + 1`` points, which when
connected linearly give a step function which changes values at the end of
the intervals.

Parameters
----------
x : array
    The x location of the steps. May be empty.

y1, ..., yp : array
    y arrays to be turned into steps; all must be the same length as ``x``.

Returns
-------
array
    The x and y values converted to steps in the same order as the input;
    can be unpacked as ``x_out, y1_out, ..., yp_out``.  If the input is
    length ``N``, each of these arrays will be length ``2N + 1``. For
    ``N=0``, the length will be 0.

Examples
--------
>>> x_s, y1_s, y2_s = pts_to_poststep(x, y1, y2)
r   r   r   NrZ  r[  r]  s      r   pts_to_poststepr`  !  s    8 HHa#d)mSSVa%;<=E!QTT'N1add7^E!QTT'N!"add(OAB"QJ'E!"add(OLr   c                 D   [         R                  " S[        U5      -   S[        U 5      -  45      n[         R                  " U 5      n U SS U SS -   S-  =USSSS24'   USSSS24'   U SS USSS24'   U SS USSS24'   XSS2SSS24'   USS2SSS24   USS2SSS24'   U$ )a  
Convert continuous line to mid-steps.

Given a set of ``N`` points convert to ``2N`` points which when connected
linearly give a step function which changes values at the middle of the
intervals.

Parameters
----------
x : array
    The x location of the steps. May be empty.

y1, ..., yp : array
    y arrays to be turned into steps; all must be the same length as
    ``x``.

Returns
-------
array
    The x and y values converted to steps in the same order as the input;
    can be unpacked as ``x_out, y1_out, ..., yp_out``.  If the input is
    length ``N``, each of these arrays will be length ``2N``.

Examples
--------
>>> x_s, y1_s, y2_s = pts_to_midstep(x, y1, y2)
r   r   Nr   r   )r   r\  r   r  r]  s      r   pts_to_midsteprb  E  s    8 HHa#d)mQQZ01E
aA)*3B!AB%1(<<E!Qr!V)uQ1W~Ra5E!RaR%LbcFE!RS&M!"add(OAB1HoE!"add(OLr   c                     X4$ r   r&   )r   ys     r   <lambda>re  k  s    A6r   )defaultr  z	steps-prez
steps-postz	steps-midc                 "    U R                   R                  5       U R                  5       4$ ! [         a     Of = f [        U 5      n [        R
                  " U R                  S   [        S9U 4$ ! [        [        4 a     Of = f[        S5      e)a  
A helper function to create reasonable x values for the given *y*.

This is used for plotting (x, y) if x values are not explicitly given.

First try ``y.index`` (assuming *y* is a `pandas.Series`), if that
fails, use ``range(len(y))``.

This will be extended in the future to deal with more types of
labeled data.

Parameters
----------
y : float or array-like

Returns
-------
x, y : ndarray
   The x and y values to plot.
r   r  z5Input could not be cast to an at-least-1D NumPy array)
ro  to_numpyAttributeErrorrE  r   r  r  r  r   r   )rd  s    r   index_ofrj  r  s    *ww!1::<// 5aL
 yy51144	 &z2 
 L
MMs   ), 
99A0 0BBc                     [        U [        R                  R                  5      (       a   U S   $ [        [        U 5      5      $ ! [         a     Of = f[        S5      e)z
Return the first element in *obj*.

This is a type-independent way of obtaining the first element,
supporting both index access and the iterator protocol.
r   /matplotlib does not support generators as input)r[   collectionsabcIteratorrf   RuntimeErrorr   r  r  s    r   safe_first_elementrq    sY     #{//00
	q6M S	?  		LMMs   A 
AAc                    S n[        U [        R                  5      (       a  U S   $ [        U [        R                  R
                  5      (       a  [        S5      eU  H  nU" U5      (       d  M  Us  $    [        U 5      $ )a"  
Return the first finite element in *obj* if one is available and skip_nonfinite is
True. Otherwise, return the first element.

This is a method for internal use.

This is a type-independent way of obtaining the first finite element, supporting
both index access and the iterator protocol.
c                     U c  g [         R                  " U 5      $ ! [        [        4 a     Of = f [        R
                  " U 5      (       a  [        R                  " U 5      $ S$ ! [         a     gf = f)NFT)mathrf  rf   r   r   isscalarr"  s    r   safe_isfinite)_safe_first_finite.<locals>.safe_isfinite  sr    ;	==%%:& 	 		
	'){{3'7'72;;s#ATA 	 	s#    //0A& $A& &
A32A3r   rl  )r[   r   flatiterrm  rn  ro  rp  rq  )rU   rv  r#  s      r   _safe_first_finitery    sm    " #r{{##1v	C11	2	2LMMCS!!
  "#&&r   c                 n    [        U [        R                  R                  5      (       a  [	        U 5      $ U $ )zH
Convert dictview objects to list. Other inputs are returned unchanged.
)r[   rm  rn  MappingViewr   )r  s    r   sanitize_sequencer|    s.     %T;??+F+FGGDJ r   c                    SSK Jn  U c  0 $ Uc  0 nOB[        U[        5      (       a  [	        X5      (       d  [        X5      (       a  [        US0 5      nUR                  5        VVVs0 s H  u  p4U  H  nXS_M     M     nnnn0 n0 nU R                  5        H9  u  pUR                  X5      nX7;   a  [        SXs   < SU	< S35      eXU'   XU'   M;     U$ s  snnnf )a  
Helper function to normalize kwarg inputs.

Parameters
----------
kw : dict or None
    A dict of keyword arguments.  None is explicitly supported and treated
    as an empty dict, to support functions with an optional parameter of
    the form ``props=None``.

alias_mapping : dict or Artist subclass or Artist instance, optional
    A mapping between a canonical name to a list of aliases, in order of
    precedence from lowest to highest.

    If the canonical value is not in the list it is assumed to have the
    highest priority.

    If an Artist subclass or instance is passed, use its properties alias
    mapping.

Raises
------
TypeError
    To match what Python raises if invalid arguments/keyword arguments are
    passed to a callable.
r   )Artist
_alias_mapz	Got both z and z", which are aliases of one another)	matplotlib.artistr~  r[   r   
issubclassr   r   r5   rf   )kwalias_mappingr~  	canonical
alias_listaliasto_canonicalcanonical_to_seenretrr   rs   s              r   normalize_kwargsr    s   6 )	z	 
]D
)
)j.O.O..|R@ 2?1D1D1F-1F-	!+ $!+ 1F  - 
C
 $$Q*	)i(9(D'Gu e#EG H H'()$I  J-s   (Cc              #     #    [        U 5      n U R                  U R                  S-   5      nSnSn[        U5       H  n UR	                  S5          SSS5          O   [        SR                  U5      5      e Sv   UR                  5         g! , (       d  f       Mb  = f! [
         a    [        R                  " U5         M  f = f! UR                  5         f = f7f)aB  
Context manager for locking a path.

Usage::

    with _lock_path(path):
        ...

Another thread or process that attempts to lock the same path will wait
until this context manager is exited.

The lock is implemented by creating a temporary file in the parent
directory, so that directory must exist and be writable.
z.matplotlib-lockr  g?xbNzLock error: Matplotlib failed to acquire the following lock file:
    {}
This maybe due to another process holding this lock file.  If you are sure no
other Matplotlib process is running, remove this file and try again.)r   	with_namerG  ranger  FileExistsErrortimesleepTimeoutErrorformatunlink)r.  	lock_pathretries	sleeptime_s        r   
_lock_pathr    s       :Dtyy+==>IGI7^	"% &%   H IOI	 	 &% 	"JJy!	" 	sd   <CB BB C9C =C
B	B CB   C CCCCCzorderr  c                 $    U" [        U 5      5      $ )z
Get the topmost artist of a list.

In case of a tie, return the *last* of the tied artists, as it will be
drawn on top of the others. `max` returns the first maximum in case of
ties, so we need to iterate over the list in reverse order.
)reversed)artists_cached_maxs     r   _topmost_artistr  7  s     x())r   c                 8    [        U [        5      =(       a    X:H  $ )z
Return whether *obj* is a string equal to string *s*.

This helper solely exists to handle the case where *obj* is a numpy array,
because in such cases, a naive ``obj == s`` would yield an array, which
cannot be used in a boolean context.
)r[   r  rU   r   s     r   
_str_equalr  D  s     c3,CH,r   c                 V    [        U [        5      =(       a    U R                  5       U:H  $ )a  
Return whether *obj* is a string equal, when lowercased, to string *s*.

This helper solely exists to handle the case where *obj* is a numpy array,
because in such cases, a naive ``obj == s`` would yield an array, which
cannot be used in a boolean context.
)r[   r  r+  r  s     r   _str_lower_equalr  O  s!     c34CIIK1$44r   c                     [         R                  SS n[         R                  SSS2   n[         R                  " U SU4   XS4   U SU4   XS4   45      $ )a  
Get the elements on the perimeter of *arr*.

Parameters
----------
arr : ndarray, shape (M, N)
    The input array.

Returns
-------
ndarray, shape (2*(M - 1) + 2*(N - 1),)
    The elements on the perimeter of the array::

       [arr[0, 0], ..., arr[0, -1], ..., arr[-1, -1], ..., arr[-1, 0], ...]

Examples
--------
>>> i, j = np.ogrid[:3, :4]
>>> a = i*10 + j
>>> a
array([[ 0,  1,  2,  3],
       [10, 11, 12, 13],
       [20, 21, 22, 23]])
>>> _array_perimeter(a)
array([ 0,  1,  2,  3, 13, 23, 22, 21, 20, 10])
r   r   )r   s_r#  )arrrL  backwards      r   _array_perimeterr  Z  sg    : eeAbkGuuR"W~H>>AwJRKBLaK	  r   c                     / U R                   QUPn/ U R                  QU R                  U   PnXA   U-
  U-  S-   XA'   XQ   U-  XQ'   [        R                  R                  R                  U UUSS9$ )au  
Append an extra dimension containing sliding windows along *axis*.

All windows are of size *size* and begin with every *step* elements.

Parameters
----------
arr : ndarray, shape (N_1, ..., N_k)
    The input array
axis : int
    Axis along which the windows are extracted
size : int
    Size of the windows
step : int
    Stride between first elements of subsequent windows.

Returns
-------
ndarray, shape (N_1, ..., 1 + (N_axis-size)/step, ..., N_k, size)

Examples
--------
>>> i, j = np.ogrid[:3, :7]
>>> a = i*10 + j
>>> a
array([[ 0,  1,  2,  3,  4,  5,  6],
       [10, 11, 12, 13, 14, 15, 16],
       [20, 21, 22, 23, 24, 25, 26]])
>>> _unfold(a, axis=1, size=3, step=2)
array([[[ 0,  1,  2],
        [ 2,  3,  4],
        [ 4,  5,  6]],
       [[10, 11, 12],
        [12, 13, 14],
        [14, 15, 16]],
       [[20, 21, 22],
        [22, 23, 24],
        [24, 25, 26]]])
r   F)r  strides	writeable)r  r  r   libstride_tricks
as_strided)r  r  r  rr  	new_shapenew_stridess         r   _unfoldr    s    P ##))"T"I3CKK3T!23K -$6:IO#)D0K66**31:3>5: + < <r   c                    US:  a  US:  d   eU R                   S   S-
  U-  S:X  d   eU R                   S   S-
  U-  S:X  d   e[        U SSU2SS24   SX"5      n[        XSU2SS24   SX"5      SSSS24   n[        U SS2USU24   SX5      n[        U SS2SSU24   SX5      SSSS24   n[        R                  " X5XF4SS9R	                  SSX-   -  5      $ )a$  
Extract perimeters of patches from *arr*.

Extracted patches are of size (*rstride* + 1) x (*cstride* + 1) and
share perimeters with their neighbors. The ordering of the vertices matches
that returned by ``_array_perimeter``.

Parameters
----------
x : ndarray, shape (N, M)
    Input array
rstride : int
    Vertical (row) stride between corresponding elements of each patch
cstride : int
    Horizontal (column) stride between corresponding elements of each patch

Returns
-------
ndarray, shape (N/rstride * M/cstride, 2 * (rstride + cstride))
r   r   Nr   .r   r  )r  r  r   r#  r  )r   rstridecstridetopbottomrightlefts          r   _array_patch_perimetersr    s"   * Q;7Q;&&GGAJNg%***GGAJNg%***$ !KRK"$%q'
;CQ''+,aB3"9MFAcrc7+G++,aBE1QR"W_%q';C2IFDNNC5A>wr1 1235r   c              +     #    [        5       n0 nU H\  n[        XU5      nX@R                  ;   d  XRL a  XSU'   M(  [        [        U 5      U5      n[	        U[
        5      (       a  XSU'   MX  X#U'   M^      UR                  5        H  u  pG[        XU5        M     Sv   UR                  5        H"  u  pEXRL a  [        X5        M  [        XU5        M$     g! UR                  5        H"  u  pEXRL a  [        X5        M  [        XU5        M$     f = f7f)zJ
Temporarily set some attributes; restore original state at context exit.
N)	r  r   __dict__r   r[   propertyr   setattrdelattr)rU   r   sentinelorigsattrr   cls_origr#  s           r   _setattr_cmr    s     
 xHEs(+<<4#3 $K tCy$/H (H--"d 'd/ 2	)IDCs# (++-JD"4(	 (%++-JD"4(	 (s   A/D2)C 7D8D

Dc                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
_OrderedSeti  c                 8    [         R                  " 5       U l        g r   )rm  OrderedDict_odr   s    r   r   _OrderedSet.__init__  s    **,r   c                     XR                   ;   $ r   r  r   rx   s     r   r  _OrderedSet.__contains__  s    hhr   c                 ,    [        U R                  5      $ r   )r  r  r   s    r   r   _OrderedSet.__iter__  s    DHH~r   c                 ,    [        U R                  5      $ r   )r   r  r   s    r   rE  _OrderedSet.__len__  s    488}r   c                 Z    U R                   R                  US 5        S U R                   U'   g r   r  r   r  s     r   r   _OrderedSet.add  s!    S$r   c                 <    U R                   R                  US 5        g r   r  r  s     r   r   _OrderedSet.discard!  s    S$r   r  N)r   r    r!   r"   r   r  r   rE  r   r   r%   r&   r   r   r  r    s     - r   r  c                    [         R                  " U [        R                  S:X  a  / SQO/ SQSS9nUSSS24   nUS	   nUS
:g  n[         R                  " US5       H,  nXT   R                  [        5      S-  X4   S-  -   X4   -  XT'   M.     U$ )zK
Convert a premultiplied ARGB32 buffer to an unmultiplied RGBA8888 buffer.
littler   r   r   r,   )r   r   r,   r   r   r  .Nr   ).r   r      )r   taker3   	byteorderrollaxisastypeint)bufrgbargbalphar  channels         r   ._premultiplied_argb32_to_unmultiplied_rgba8888r  )  s     771|!MD sCRCx.CMEA:D;;sB']!!#&,u{a/??{ 	 ( Kr   c                 2   [         R                  S:X  a+  [        R                  " U / SQSS9nUSSS24   nUSSS24   nO*[        R                  " U / SQSS9nUSSS	24   nUSS	S24   nUR	                  5       S
:w  a  [        R
                  " X#S
-  USS9  U$ )zK
Convert an unmultiplied RGBA8888 buffer to a premultiplied ARGB32 buffer.
r  r  r   r  .Nr   )r,   r   r   r   r   r  unsafe)r   casting)r3   r  r   r  rK  multiply)rgba8888argb32rgb24alpha8s       r   ._unmultiplied_rgba8888_to_premultiplied_argb32r  ;  s     }} <a8sCRCx RS!<a8RaRsABw zz|t
ED=eXFMr   c                 J   U R                  SS9R                  5       u  nU R                  SS9R                  5       u  n[        U5      (       a>  [        U5      (       a.  USS/   u  p4USS/   u  pV[        XVS-   5      [        X4S-   5      4$ [        SS5      [        SS5      4$ )a  
Return the bounds of the nonzero region of a 2D array as a pair of slices.

``buf[_get_nonzero_slices(buf)]`` is the smallest sub-rectangle in *buf*
that encloses all non-zero entries in *buf*.  If *buf* is fully zero, then
``(slice(0, 0), slice(0, 0))`` is returned.
r   r  r   r   )anyr  r   slice)r  x_nzy_nzlr'  r  ts          r   _get_nonzero_slicesr  O  s     GGGO##%EDGGGO##%ED
4yySYYQG}QG}QAaQ//Q{E!QK''r   c                 `    [        U [        5      (       a  U $ SR                  S U  5       5      $ )zAPretty-format a subprocess command for printing/logging purposes.r   c              3   v   #    U  H/  n[         R                  " [        R                  " U5      5      v   M1     g 7fr   )shlexquoter
  r  )r   r  s     r   r   &_pformat_subprocess.<locals>.<genexpr>d  s$     I#%++biin55s   79)r[   r  r  )commands    r   _pformat_subprocessr  a  s/    !'3//G KIIIKr   c                 V   UR                  S[        U 5      5        [        R                  " U 4SS0UD6nUR                  (       a  UR
                  n[        U[        5      (       a  UR                  5       nUR                  n[        U[        5      (       a  UR                  5       n[        S[        U 5       SU SU 35      eUR
                  (       a  UR                  SUR
                  5        UR                  (       a  UR                  SUR                  5        UR
                  $ )	aR  
Run *command*, returning its stdout output if it succeeds.

If it fails (exits with nonzero return code), raise an exception whose text
includes the failed command and captured stdout and stderr output.

Regardless of the return code, the command is logged at DEBUG level on
*logger*.  In case of success, the output is likewise logged.
z%scapture_outputTzThe command
    z,
failed and generated the following output:
z
and the following error:
z
stdout:
%sz
stderr:
%s)debugr  
subprocessrun
returncodestdoutr[   bytesdecodestderrrp  )r  loggerr   procr  r	  s         r   _check_and_log_subprocessr  g  s     LL*734>>'A$A&ADfe$$]]_Ffe$$]]_F&w/0 1;h )h 	 {{]DKK0{{]DKK0;;r   c                  |     [         R                  " 5         g! [         a    [         R                  " S5         gf = f)zK
Perform OS-dependent setup when Matplotlib creates a new GUI application.
r1  N)r   -Win32_GetCurrentProcessExplicitAppUserModelIDOSError-Win32_SetCurrentProcessExplicitAppUserModelIDr&   r   r   _setup_new_guiappr    s3    GGI GG	s     ;;c                 `    U SU S3 R                  S5      R                  S5      =(       d    S$ )z
Format the number with at most the number of decimals given as precision.
Remove trailing zeros and possibly the decimal point.
.f0)rstrip)number	precisions     r   _format_approxr    s2    
 QykN#++C077<CCr   c           
      |   US:X  a&  U S:X  a  g[        [        R                  " U 5      5      n[        R                  " U 5      (       at  [        SU (       a6  [        R                  " [        R                  " [        U 5      5      5      S-   OS[        R                  " [        R                  " U5      5      -
  5      $ S$ )zs
Return the number of significant digits to %g-format *value*, assuming that
it is known with an error of *delta*.
r   r,   r   )absr   spacingrt  rf  rO  floorlog10)ry   deltas     r   _g_sig_digitsr     s    
 zA:  BJJu%& -1MM%,@,@ 	38DJJs5z*	+a	/a
**TZZ&
'	() H GHHr   c                    U (       a  U R                  5       (       a  U $ UR                  5       nUR                  S5      (       a  USS nUR                  S5      (       a  UR                  SS5      nUR	                  S5      (       a  USS n[
        R                  S:X  a  US	:X  a  S
nSSSS.R                  X"5      nU$ )z
Convert a Unicode key or X keysym to a Matplotlib key name.

The Unicode key is checked first; this avoids having to list most printable
keysyms such as ``EuroSign``.
kp_r,   Npage_page)_l_rrZ  darwinmetacmdenterpageuppagedown)returnpriorr   )isprintabler+  
startswithr   r  r3   platformr5   )unikeykeysymrx   s      r   _unikey_or_keysym_to_mplkeyr4    s     &$$&&
,,.C
~~e!"g
~~gkk'6*
||L!!#2h
||xC6M 
c#m	 
 Jr   c                 d   ^ ^^ [         R                  UUU 4S j5       nT R                  Ul        U$ )aL  
Return a function that creates picklable classes inheriting from a mixin.

After ::

    factory = _make_class_factory(FooMixin, fmt, attr_name)
    FooAxes = factory(Axes)

``Foo`` is a class that inherits from ``FooMixin`` and ``Axes`` and **is
picklable** (picklability is what differentiates this from a plain call to
`type`).  Its ``__name__`` is set to ``fmt.format(Axes.__name__)`` and the
base class is stored in the ``attr_name`` attribute, if not None.

Moreover, the return value of ``factory`` is memoized: calls with the same
``Axes`` class always return the same subclass.
c                    >^ [        U T5      (       a  U $ U m " UUUU4S jSTT5      nTR                  TR                  5      =Ul        Ul        Tb  [	        UTT5        U$ )Nc                   B   > \ rS rSr YR                  rU UUU4S jrSrg):_make_class_factory.<locals>.class_factory.<locals>.subclsi  c                 :   > [         TTTT4U R                  5       4$ r   )_picklable_class_constructorr   )r   	attr_name
base_classfmtmixin_classs    r   
__reduce__E_make_class_factory.<locals>.class_factory.<locals>.subcls.__reduce__  s(    4$c9jA))+- -r   r&   N)r   r    r!   r"   r?  r%   )r;  r<  r=  r>  s   r   subclsr8    s    $//J- -r   rA  )r  r  r   r!   r  )
axes_classrA  r<  r;  r=  r>  s     @r   class_factory*_make_class_factory.<locals>.class_factory  si     j+..  
	- 	-[* 	- 14

:;N;N0OO&- FIz2r   )r   cacher    )r>  r=  r;  rC  s   ``` r   _make_class_factoryrF    s1    & __ .  +55Mr   c                 L    [        XU5      nU" U5      nUR                  U5      $ )z(Internal helper for _make_class_factory.)rF  __new__)r>  r=  r;  r<  factoryr   s         r   r:  r:  	  s'    !+I>G
*
C;;sr   c                 r     [        U [        R                  S   R                  5      $ ! [         a     gf = f)z!Check if 'x' is a PyTorch Tensor.torchF)r[   r3   r4   Tensorr   r  s    r   _is_torch_arrayrM  		  s9     !S[[18899     &) 
66c                 r     [        U [        R                  S   R                  5      $ ! [         a     gf = f)zCheck if 'x' is a JAX Array.jaxF)r[   r3   r4   Arrayr   r  s    r   _is_jax_arrayrR  	  s9     !S[[/5566  rN  c                 |     [        U [        R                  S   R                  U 5      5      $ ! [         a     gf = f)z0Check if 'x' is a TensorFlow Tensor or Variable.
tensorflowF)r[   r3   r4   	is_tensorr   r  s    r   _is_tensorflow_arrayrV  !	  s>    
 !S[[6@@CDD  s   +. 
;;c                    [        U [        R                  5      (       a  U $ [        U S5      (       a  U R	                  5       $ [        U S5      (       a-  U R
                  n[        U[        R                  5      (       a  U$ [        U 5      (       d   [        U 5      (       d  [        U 5      (       a7  [        R                  " U 5      n[        U[        R                  5      (       a  U$ U $ )zDInternal helper to extract data from e.g. pandas and xarray objects.rh  rA   )
r[   r   r  r  rh  rA   rM  rR  rV  r  )r   xtmps     r   rC  rC  0	  s    !RZZ  q*zz|q(xx dBJJ''Kq]1--1Ea1H1H
 zz!} dBJJ''KHr   c                 \     X4-  $ ! [         [        4 a    U R                  U5      s $ f = f)a  
Apply *value* to the format string *fmt*.

This works both with unnamed %-style formatting and
unnamed {}-style formatting. %-style formatting has priority.
If *fmt* is %-style formattable that will be used. Otherwise,
{}-formatting is applied. Strings without formatting placeholders
are passed through as is.

Examples
--------
>>> _auto_format_str('%.2f m', 0.2)
'0.20 m'
>>> _auto_format_str('{} m', 0.2)
'0.2 m'
>>> _auto_format_str('const', 0.2)
'const'
>>> _auto_format_str('%d or {}', 0.2)
'0 or {}'
)rf   r   r  )r=  ry   s     r   _auto_format_strrZ  K	  s4    *!X~z" !zz%  !s    !++c                 r     [        U [        R                  S   R                  5      $ ! [         a     gf = f)z#Check if 'x' is a Pandas DataFrame.pandasF)r[   r3   r4   	DataFramer   r  s    r   _is_pandas_dataframer^  f	  s9     !S[[2<<==  rN  )r'  FN)r'  N)T)F)g      ?NNF)r  Nr   )nr#   rm  collections.abcr   r   r  r   rt  operatorr
  pathlibr   r  r  r3   r  rL   ry  rd   numpyr   numpy.exceptionsr   ImportErrorr1  r   r   r   rJ   rN   rP   ri   rk   r   r   r   MatplotlibDeprecationWarningr   r   r   r  r  r  r  r$  r/  r)  r4  r8  rh  r  r  r  r  r  r  r  r  r0  	ls_mapperr   ls_mapper_rr;  r?  rA  rE  r  rX  r^  r`  rb  STEP_LOOKUP_MAPrj  rq  ry  r|  r  r   r  r   rO  
attrgetterr  r  r  r  r  r  r  rn  
MutableSetr  r  r  r  r  r  r  r  r   r4  rE  rF  r:  rM  rR  rV  rC  rZ  r^  )rr   rs   s   00r   <module>rk     s  
         	    
     0:  .& &./d $ 4 4nC" C"L%$ %H 55.((1

1h88
83 - .,4H 4Hn %(JJe B"Jl8 l8^- -(/0JZ>B +0 #LFT J	 ) 12 1qt 12*4
$9x_D#L!H#L 2* .!0 .	0 NF($'N5p # #P %%cx/B/B8/LM
*-5$N/<d.5b () ()V +//,,  2$(($KBDH28 + +\		6!6	UJ  0//0z' 3s   H< 7I<II