rL i8dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZ ddlmZddlZddlmZmZGddZdZd ZGd d Zd ZGd dZ GddZ!Gdde"Z#ejHddZ%dZ&dZ'dZ(dZ)d`dZ*dadZ+dZ,dbdZ-dZ.e,fdZ/Gd d!Z0dcd"Z1ejddfd#Z3Gd$d%Z4Gd&d'Z5d(Z6d)Z7d*Z8dd+d,Z9ddd-Z:d.d/d0d1d2Z;e;jyDcic]\}}|| c}}Z=d3Z>d4Z?d5Z@d6ZAd7ZBded8ZCd9ZDd:ZEd;ZFd<eDeDeEeFd=ZGd>ZHd?ZId@ZJdAZKdfdBZLejdCZNejePejdDEfdFZRdGZSdHZTdIZUdJZVdKZWejdLZXGdMdNejjZ[dOZ\dPZ]dQZ^dRZ_dSZ`dTZadUZbdVZcdWZdejdfdXZfdYZgdZZhd[Zid\Zjd]Zkd^Zld_Zmy#e$r ddlmZYwxYwcc}}w)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,eZdZdZdZedZdZy)_ExceptionInfoa 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 ||_||_yN_cls_args)selfclsargss V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/cbook.py__init__z_ExceptionInfo.__init__.s  c:|t|g|jSr )typer)rexcs rfrom_exceptionz_ExceptionInfo.from_exception2s49(sxx((rc4|j|jSr r rs r to_exceptionz_ExceptionInfo.to_exception6styy$**%%rN)__name__ __module__ __qualname____doc__r classmethodrrrrrr#s%))&rrcDtjjdxsatjjdxs@tjjdxstjjd}|r|jj rytjjd}|rF|j dk(rdd lm}|jry |j d k(r|jry tjjd }|r|jry tjjd}|r|jj|jjjh}tjjD]$}|s|j |vry|j"}|r&~tjjd}|r|j%ryt'j(syy)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``. zPyQt6.QtWidgetszPySide6.QtWidgetszPyQt5.QtWidgetszPySide2.QtWidgetsqtzgi.repository.Gtkr)GLibgtk4gtk3wxtkintertkzmatplotlib.backends._macosxmacosxheadlessN)sysmodulesget QApplicationinstance MAJOR_VERSION gi.repositoryr$ main_depth main_levelGetAppmainloop__code__Misc_current_framesvaluesf_codef_backevent_loop_is_runningrdisplay_is_valid) QtWidgetsGtkr$r(r)codesframer+s r"_get_running_interactive_frameworkrD:s )* 0 ;;??. / 0 ;;??, - 0 ;;??. /  Y++446 ++//- .C    ! *     !cnn&6  B biikkkooi(G!!**GLL,A,A,J,JK((*113 %E<<5(  %  [[__: ;F &..0  - - / rcHtdvr|tjy)N)r,N)rD traceback print_exc)rs r_exception_printerrHls)+/AA rc(eZdZdZdZdZdZdZy) _StrongRefzU Wrapper similar to a weakref, but keeping a strong reference to the object. c||_yr _obj)robjs rrz_StrongRef.__init__xs  rc|jSr rLrs r__call__z_StrongRef.__call__{s yyrcXt|txr|j|jk(Sr ) isinstancerJrM)rothers r__eq__z_StrongRef.__eq__~s!%,Hejj1HHrc,t|jSr )hashrMrs r__hash__z_StrongRef.__hash__sDIIrN)rrrrrrPrTrWr rrrJrJssIrrJcd tj||S#t$rt|cYSwxYw)zQ Return a `WeakMethod` wrapping *func* if possible, else a `_StrongRef`. )weakref WeakMethod TypeErrorrJ)funccallbacks r_weak_or_strong_refr^s4 !!$11  $ s //c.eZdZdZdZdZdZdZdZy) _UnhashDicta 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>i|_g|_|D] \}}|||< yr _dict_pairs)rpairskvs rrz_UnhashDict.__init__s,   DAqDG rc ||j|<y#t$rYt|jD]!\}\}}||k(s||f|j|<Yy|jj ||fYywxYwr )rcr[ enumeraterdappend)rkeyvalueirfrgs r __setitem__z_UnhashDict.__setitem__sv 1#DJJsO 1&t{{3 1 6Aq8&)5\DKKN 1  ""C<0  1s,A4A4A43A4c |j|S#t$rYnwxYw|jD]\}}||k(s |cSt|r )rcr[rdKeyError)rrkrfrgs r __getitem__z_UnhashDict.__getitem__sV ::c? "   KK DAqCx sms  c  ||jvr|jj|S |r|dSt |#t$r;t|jD] \}\}}||k(s|j|=|ccYSYUwxYwNr)rcpopr[rirdrp)rrkrrmrfrgs rrtz_UnhashDict.pops djj zz~~c**! 7Nsm &t{{3  6Aq8 AH  s(>,B+B>BBc#hK|jEd{|jD] \}}| y7wr rbrrfrgs r__iter__z_UnhashDict.__iter__s4::KK DAqG  s 202N) rrrrrrnrqrtrwr rrr`r`s  1 rr`ceZdZdZefdddZdZdZdZdZ e jd d Z d Z d Zej dd dZy)CallbackRegistrya 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|dn t||_||_i|_t j |_tg|_t|_ yr ) list_signalsexception_handler callbacks itertoolscount_cid_genr` _func_cid_mapset _pickled_cids)rr~rzs rrzCallbackRegistry.__init__sF 'T'] !2!) (_ Urc4it||jjDcic]=\}}||jDcic]\}}||jvr||c}}?c}}}}dt |j dScc}}wcc}}}}w)N)rrr)varsritemsrnextr)rsdcidproxys r __getstate__zCallbackRegistry.__getstate__ s  4j  '+nn&:&:&<>>"aQWWY"T]]+  <>sB  B (B B c |jd}t|j||jj Dcic]R\}}||j Dcic]0\}}|t |t j|j|2c}}Tc}}}}|_td|jj D|_ tj||_ ycc}}wcc}}}}w)Nrc3^K|]%\}}|jD] \}}||f|f'ywr )r).0rrrrs r z0CallbackRegistry.__setstate__.. sE)L1)L3=3Z )L )Ls+-)rtrupdaterrr^ functoolspartial _remove_proxyr`rrrr)rstate cid_countrrrr\s r __setstate__zCallbackRegistry.__setstate__sIIj)  T % ,,.001 !",C(y/@/@ASASUV/WXX, ,0))L,,.)LL" 2 ,0s C= '5C7C= 7C= c|j!tj|j|t|t j |j |} |j||fS#t$rJt|jx}|j||f<||jj|i|<|cYSwxYw)z?Register *func* to be called when signal *signal* is generated.signal) r}r check_in_listr^rrrrrprrr setdefault)rrr\rrs rconnectzCallbackRegistry.connect%s == $   t}}V <#D)*;*;DDNN % %fb 1# 6J sA**AB=<B=c`|j||}|jj||S)z{ Like `.connect`, but the callback is kept when pickling/unpickling. Currently internal-use only. )rradd)rrr\rs r_connect_picklablez#CallbackRegistry._connect_picklable1s- ll64( s# r)_is_finalizingc|ry|jj||fd}|,|j||=|jj |nyt |j|dk(r|j|=yyrs)rrtrrdiscardlen)rrrrrs rrzCallbackRegistry._remove_proxy=s{     $$fe_d; ?v&s+    & &s +  t~~f% &! +v& ,rcj|jj||jD]\}}|j||f|k(sny|j|||k(sJ|j||=|jj ||ft |j|dk(r|j|=yy)z Disconnect the callback registered with callback id *cid*. No error is raised if such a callback does not exist. Nr)rrrrrtr)rrrrs r disconnectzCallbackRegistry.disconnectJs ""3'!// MFE!!&%-0C7  ~~f%c*e333 NN6 "3 ' / t~~f% &! +v& ,rc^|j!tj|j|t|jj |ij D]}|}| ||i|y#t$r)}|j|j|nYd}~Fd}~wwxYw)z Process signal *s*. All of the functions registered to receive callbacks on *s* will be called with ``*args`` and ``**kwargs``. Nr) r}rrr|rr/r; Exceptionr~)rrrkwargsrefr\rs rprocesszCallbackRegistry.process\s == $   t}}Q 7**1b188:; C5D$)&) !--9..s34s/A:: B,B''B,rc#K|j} |i|_n|Dcic]}||k7s |||c}|_d||_ycc}w#||_wxYww)aV 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)rrorigrfs rblockedzCallbackRegistry.blockedrs^~~ "~!#7;!Ja6k!T!W*!J !DN"K"DNs0 AA AA A AA AA)rrrrrHrrrrrr- is_finalizingrrr contextlibcontextmanagerrr rrryryse6x*<##   3 >A=N=N ''$, $""rryceZdZdZddZdZy) silent_lista 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 :: [, , ] one will get :: If ``self.type`` is None, the type name is obtained from the first item in the list (if any). Nc:||_||j|yyr )rextend)rrseqs rrzsilent_list.__init__s ? KK  rc|jt|dk7rB|j |jnt|dj}dt|d|dSy)Nrz z)rrr)rtps r__repr__zsilent_list.__repr__sT 99 CIN"ii3d1g9O9OB T 1RD : :$rr )rrrrrrr rrrrs( %rr) warning_clsc|}|D]6}|j|d}|||}tjd|d|8|S)N"z"" keyword argument will be ignored)rtr warn_external) local_varrrkeysoutrk kwarg_vals r_local_over_kwdictrs\ C0JJsD)  {""Qse+M#N#.0 0 Jrct|dk\r6|d|dcxk(rdk(r%n|S|dd}dD]\}}|j||}|S)zi Remove latex formatting from mathtext. Only handles fully math and fully non-math strings. r$) )z\timesx)z \mathdefault)z\rmr)z\calr)z\ttr)z\itr)\r){r)}r)rreplace)rtexplains r strip_mathrse  1v{qtqu++ H aG  &JC #u%A & Hrc2d} |jd|}|jd|}|dkr|dkr|n|d|}|jSd|cxkr|krnn|d|jS|jd|dz}|dkrtd|d|dz})z+Strip everything from the first unquoted #.rr#NrzMissing closing quote in: zM. If you need a double-quote inside a string, use escaping: e.g. "the " char")findstrip ValueError)rpos quote_poshash_poswithout_commentclosing_quote_poss r_strip_commentrs C FF3$ 66#s# q=#+a>% 5$'B ^^F # UD)BeTH5B   BCC6z IrcVt||d|\}}|r|Stj|S)z8Pass through file objects and context-manage path-likes.T)rr nullcontext) path_or_filemoderrrs r open_file_cmr.s.|T4BJB27Z33B77rcRt|txstj| S)z;Return whether the given object is a scalar or string like.)rRrnpiterablevals ris_scalar_or_stringr4s c3  7r{{3'7#77rctd|}|rs|jj}|dk(rtj|S|dvrt j |S|dvr|j dS|j dSt|S)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.txtrrb)_get_data_pathsuffixlowerrrrloadr)r asfileobjpathr s rget_sample_datar9s - /D""$ U?99T? " ' '774= / /99S> !99T? "4yrc>ttjg|S)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)rs rr r Us  ((* 2T 22rc#dK|D]%}||s||t||Ed{'y7w)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)rscalarpitems rrr^s<. 4=DLJtW- - - . .s $0.0cFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) _Stackzb Stack of elements with a movable cursor. Mimics home/back/forward in a web browser. c d|_g|_y)Nr_pos _elementsrs rrz_Stack.__init__{s rc d|_g|_y)zEmpty the stack.rNrrs rclearz _Stack.clears rcP|jr|j|jSdS)z$Return the current element, or None.N)rrrs rrPz_Stack.__call__s ,0NNt~~dii(DDrc,t|jSr )rrrs r__len__z_Stack.__len__s4>>""rc |j|Sr )r)rinds rrqz_Stack.__getitem__s~~c""rcxt|jdzt|jdz |_|S)z9Move the position forward and return the current element.r)minrrrrs rforwardz_Stack.forwards- A s4>>':Q'>? v rcLt|jdz d|_|S)z6Move the position back and return the current element.rr)maxrrs rbackz _Stack.backs A q) v rcz|g|j|jdzdt|jdz |_|S)zx Push *o* to the stack after the current position, and return *o*. Discard all later elements. rN)rrr)ros rpushz _Stack.pushs8 +,tyy1}~&'!+ rcZ|jr|j|jdSdS)zk Push the first element onto the top of the stack. The first element is returned. rN)rr.rs rhomez _Stack.homes' 04~~tyy*+G4GrN) rrrrrr rPr#rqr(r+r.r0r rrrrts6  E##  Hrrcftj|d|}|jjs:|j |j |jj d} tjjtj||d}|S#t$r|cYSwxYw)NT)subokcopy)inplaceNF)r3) rarraydtypeisnativebyteswapview newbyteorderma masked_whereisfiniter[)rr3xms rsafe_masked_invalidr@s $T*A 77   JJtJ $ ) )!''*>*>s*C D UU  "++a. 115  A I s*6B"" B0/B0cddlfdfdD]"}jd|d||ig$y)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. rNcrt|D]\}}||dzt|z}jdt|zt |t rN|j D]:\}}||urjd|dn||us&jd|nrnpt |tr$jd|j|zn  ) rirrrrRdictrr|indextuplerepr)rrmsteprrkr outstreams r print_pathz print_cycles..print_paths   %GAtQ#d)+,D OOK$t*4 5$% $ HCd{!!C7! 5d{!(3'(:; D$'D)9 9:D%( ,T + OOG $' %( rc" rjdt|zd|t|<j|}|D]K}||ur  ||ust |t j r/t||vs= |||||gzMy)Nz%d )rrid get_referentsrRtypes FrameType) rNstartall current_path referentsreferentgcobjectsrKrLrecurse show_progresss rrYzprint_cycles..recurses  OOFSX- .BsG $$S) ! DH5 <( W$ 8U__(MHS(%lcU.BC Drz Examining: rE)rWr)rXrKrZrNrWrLrYs``` @@@r print_cyclesr[sM .DD."+cWB/0S"b!"rcHeZdZdZd dZdZdZdZdZdZ dZ d Z d Z y ) Groupera# 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 ^tj|Dcic]}|tj|gc}|_tj|_|D]3}||jvst |j|j|<5t |j|_ycc}wr )rYWeakKeyDictionaryWeakSet_mapping _orderingr _next_order)rinitrs rrzGrouper.__init__ s11.2 3Q$ $ 35  224 8A&$'$7q! 8t~~. 4sB*c it||jjDcic]\}}|t|c}}i|jdScc}}w)N)rarb)rrarrrbrvs rrzGrouper.__getstate__)sX 4j 04}}/B/B/DEtq!CFE+DNN+   FsAc >t|j|tj|jj Dcic]\}}|tj |c}}|_tj|j|_ycc}}wr )rrrYr_rarr`rb)rrrfrgs rrzGrouper.__setstate__1sp T % 11/3}}/B/B/D Etq!Q" " EG  224>>B Fs B c||jvSr )rarrs r __contains__zGrouper.__contains__8st}}$$rc|j} ||}|D]E} ||}||ust |t |kDr||}}|j||D]}|||< Gy#t$rLtj|gx}||<|j|j |<|xjdz c_YwxYw#t$rLtj|gx}||<|j|j |<|xjdz c_YwxYw)zY Join given arguments into the same set. Accepts one or more arguments. rN)rarprYr`rcrbrr)rarmappingset_aargset_belems rjoinz Grouper.join;s-- "AJE  *C &  E!u:E *#(%5E U#!*D$)GDM* *  "!(!!5 5EGAJ $ 0 0DNN1     !  " &'.u'== &*&6&6s#  A%  &s$AB6AB32B36AD  D c|jj|t|jj|uS)z7Return whether *a* and *b* are members of the same set.)rar/objectrrkbs rjoinedzGrouper.joinedTs/ !!!VX.$--2C2CA2FFGrc|jj||hj||jj|dy)z>Remove *a* from the grouper, doing nothing if it is not there.N)rartremoverbrrks rrxzGrouper.removeXs7 !aS!((+ 1d#rc#K|jjDcic]}t||}}|jD]%}t||jj 'ycc}ww)z Iterate over each of the disjoint sets as a list. The iterator is invalid if interleaved with calls to join(). rkN)rar;rNsortedrbrq)rgroup unique_groupss rrwzGrouper.__iter__]sh 8<}}7K7K7MNeEE)N N"))+ @EDNN$>$>? ? @OsA2A-AA2c~|jj||g}t||jjS)z:Return all of the items joined with *a*, including itself.r{)rar/r|rb)rrksiblingss r get_siblingszGrouper.get_siblingsgs1==$$Q,hDNN$6$677rN)r ) rrrrrrrrirqrvrxrwrr rrr]r]s8B/ C%*2H$ @8rr]c.eZdZdZdZdZdZdZdZy) GrouperViewz!Immutable view over a `.Grouper`.c||_yr _grouper)rgroupers rrzGrouperView.__init__psrc||jvSr rrhs rrizGrouperView.__contains__qs)>">rc,t|jSr )iterrrs rrwzGrouperView.__iter__rstDMM22rc:|jj||S)zI Return whether *a* and *b* are members of the same set. )rrvrts rrvzGrouperView.joinedts}}##Aq))rc8|jj|S)zL Return all of the items joined with *a*, including itself. )rrrys rrzGrouperView.get_siblingszs}}))!,,rN) rrrrrrirwrvrr rrrrms+8>2* -rrc |jt|df}tjt||z}tjt|dz |zdz}tj|j Dcgc]}tj |||c}jt|f|jddzScc}w)a} 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, ...)`` rrN)reshaperrarange column_stackTinterpshape)rkstepsfpsxprfps rsimple_linear_interpolationrs" ))SVRL !C 3q6 U "B 3q6A:&*+A OOCEEBbRYYq"b1B C Wc!fY, -/BsCc"t|syt|dr tdt|d}g}dgt|z}t|D]\}}t |t s{t j|rft||k(rXd||<t |t jjr|jdkDr tdt j|}|j|g}t|D]\}}||s |jdkDrt |t jjr<|jt jj||j}n|} t j|}t |t j r|j|t|rat j$j'|}|j)d} t| |kr!t|D]\}}||s || ||<t|D]C\}}||s t |t jjs1|j+||<E|S#t"$rYwxYw)ak 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 sequenceFTrMasked arrays must be 1-D)rrrrirRrrrr< MaskedArrayndimasarrayrj getmaskarraydatar>ndarrayr logical_andreducenonzerofilled) rnrecsmargsseqlistrmrmasksxdmaskigoods rdelete_masked_pointsrs.@ t947#<== QLE EgD !G$1!S!bkk!nQ5GAJ!RUU../66A:$%@AAJJqM Q E% 1 1:vvz!RUU../ bee00334VV {{2dBJJ/LL& 5z~~$$U+ q! u: !%( (11: xE!H (% "1 1:*Q(9(9:xxzE!H" L  sAJ J Jct|syt|dr tdt|d}g}dgt|z}g}t|D]\}}t|st||k7r|j |2t |t jjr|jdkDr td t j|}|jdk(r]t|}d||<t jj|r.|j t jj||j |t|r\t j j#|}t|D]/\}}||s t jj%|| ||<1|S#ttf$rt j|t}YwxYw) ax 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 rrFrrr7Tr)rrrrirjrRrr<rr asanyarrayrrsr@ is_maskedr logical_orrr6)rrrrrrmrrs r_combine_masksrs> t947#<== QLE EgD !G E$1 q !SVu_ LLO!RUU../AFFQJ !<== 3MM!$ vv{'*! 55??1%LL!3!3A!67 LLO#$ 5z}}##E*e$ 5DAqqz55;;qt;4a 5 L.z: 3MM!62 3sG*G/.G/)compressc|Dcgc]3}t|tjjs(|j5}}tj g||}|dt |}|t |d}|rtjj|}|r>|Dcgc]1}tjj||j3}}|S|Dcgc]S}tjj||tjtjjU}}|S|Dcgc]}tj|}}|Scc}wcc}wcc}wcc}w)aw 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)rr7)rRrr<rrbroadcast_arraysrrrr6 compressedfloatrnanravel)rrrfrbcastinputsrs r_broadcast_with_masksr'sF$" FZ2553D3D%EQVV FE F    . . .E :CI F #d)* E }}##E* %'eekk!$k/::<'F' M &'eekk!$ek<CCBFFKQQS'F' M(..!"((1+.. M# G''/s)EE6EAE!7E&cddfd}g}t|d}t|}|tjd}nt||k7r t d|}t t ||D]\} \} } i} | | | d<|}|j| t| dk(rtjg| d<tj| d <tj| d <tj| d <tj| d <tj| d <tj| d<tj| d<tj| d<tj| d<tjj| } | j| jj} tj | | d <tj"| gd\} }}|| z | d <| d dk(r|rd}|| || d |\| d<| d<tj$|r*t'|t(stj"| |\}}n7tj*|r| || d zz }||| d zz}n t d| | |k}t|dk(stj,||kr|| d<ntj,|| d<| | |k\}t|dk(stj.|| kDr| | d<ntj.|| d<tj0| | | dk| | | dkDg| d<| ||c| d <| d <| d <|S)aj 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. ct|}ddg}tjj|||f}||}tj|dd}tj ||}|S)Ng@g`X@)sizerT)axisoverwrite_input)rrrandomrandintmedian percentile)rr5M percentilesbs_indexbsDataestimateCIs r_bootstrap_medianz(boxplot_stats.._bootstrap_mediansa IDk 99$$QaV$4h99V!TB ]]8[ 1 rc|||}|d}|d}||fSt|}|d|ztj|z z }|d|ztj|z z}||fS)N)r5rrgQ?)rrsqrt) rmediqr bootstrapr notch_min notch_maxr5rs r_compute_conf_intervalz-boxplot_stats.._compute_conf_intervals  #495B1I1I)## D AdSj2771:55IdSj2771:55I)##rXNz-Dimensions of labels and X must be compatiblelabelrfliersmeanrq1q3rcilocihiwhislowhishi)2K)rdz+whis must be a float or list of percentiles)i) _reshape_2Drrrepeatrriziprjrr6rr<rrrrrrrrRrisrealr*r' concatenate)rwhisrlabels autorangerbxpstatsncols input_whisiirrstatsrrrlovalhivalwiskhiwisklors @r boxplot_statsrMs8^  $ H AsA FE ~!!$' V HIIJ#C6N3M=JQ  "E'N  q6Q; hhrlE(OFFE&M66E%L&&E$K&&E$K66E%LFFE&MFFE&M ffE(O ffE(O  EEMM!  FFAFF7O ! ! # f mmA|4 CBwe <1 D(> sE%L)( $f uV} ;;t Zc%:==D1LE5 YYt_e ,,Ee ,,EJK K1: v;! rvvf~2 E(O ffVnE(O1: v;! rvvf~2 E(O ffVnE(O.. a%/! " a%/! "*  h 24S".d U5\5;[M=^ Orsoliddasheddashdotdotted)-z--z-.:c Ttj|t}|jsgStj|dd|ddk7\}|dz }|j }|drdg|z}|dr|j t|tt|ddd|dddS)zv Return a list of (ind0, ind1) such that ``mask[ind0:ind1].all()`` is True and we cover all such regions. rNrrrr) rrboolrrtolistrjrr|r)ridxs rcontiguous_regionsrs ::d$ 'D 99  ::d3Bi48+ ,DC1HC **,C AwcCi Bx 3t9 C!Hc!$Q$i( ))rct|}|jd|jdz }|dkDxr|dzdk(}|S)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. rz\$rr)rr)r dollar_count even_dollarss r is_math_textr6sF AA774=1775>1L 1$>)9Q)>L rct|drAtjj|tj tj Stj|tS)zt Convert a sequence to a float array; if input was a masked array, masked values are converted to nans. r)rrr<rrrrrs r_to_unmasked_float_arrayrCsC q&uu}}Q&--bff55zz!U##rct|}t|dr$t|drt|jdkrt j |S|S)z8Convert scalars to 1D arrays; pass-through arrays as is.rrr)_unpack_to_numpyrrrr atleast_1drs r _check_1dr NsH A Aw 6" L1 }}Qrct|}t|tjr|j }t |dk(rggS|j dk(rtj |ddk(r|gS|j dvr$|Dcgc]}tj|dc}St|dt |dk(rggSg}d}|D]}}t|ts t|d}tj|}tj |}|dkDrt|d|j|jd|rtj|dgS|Scc}w#t$rYwxYw)a 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. rr)rrrz must have 2 or fewer dimensionsTF)r rRrr transposerrrrrrr[rrj)rnamerresultis_1dxinds rrr]si A!RZZ KKM q6Q;4K VVq[RWWQqT]a/3J VVv /01!BJJq"%1 1v%EFG G 1v{t F E&"c" R ]]2  WWR[ 6v%EFG G bjjn%&   62&'' ?2   sE& E++ E76E7cg}t|d}|t|dk7r t|d}nggt|z}t|t|k7r tdt||D]\}}i}t j |}t j |} t j|d|z} t j|| |} ||| |d<| |d<t j||d<t j||d <||d <| |d <t j| |d<|j||S) 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. rr quantileszLList of violinplot statistics and quantiles values must have the same lengthrvalscoordsrrr'r*) rrrrrr'r*rlinspacerrr rj) rmethodpointsrvpstatsrqrmin_valmax_val quantile_valrs r violin_statsrsHjG AsAY1!4 ;7 D3q6M  1vY67 7a#A&&)&&)}}Qa0 Wgv6q&)f  h f ))A,he e ]]<8k u-0 Nrc tjdt|ztdt|zdz df}||ddddf<|ddddf|ddddf<||dddddf<|dddddf|dddddf<|S)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) rrrNrzerosrr*rrrs rpts_to_prestepr%s8 HHa#d)mSSVa%;< =EE!QTT'N1a1f9%E!QTT'NE!"add(OAB1HoE!"add(O Lrc tjdt|ztdt|zdz df}||ddddf<|ddddf|ddddf<||dddddf<|dddddf|dddddf<|S)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) rrrNr!r"r$s rpts_to_poststepr'!s8 HHa#d)mSSVa%;< =EE!QTT'N1add7^E!QTT'NE!"add(OAB"QJ'E!"add(O LrcBtjdt|zdt|zf}tj|}|dd|ddzdz x|ddddf<|ddddf<|dd|dddf<|dd|dddf<||dddddf<|dddddf|dddddf<|S)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) rrNrr)rr#rrr$s rpts_to_midstepr)Es8 HHa#d)mQQZ0 1E aA)*3B!AB%1(<r,ks Aq6r)defaultrz steps-prez steps-postz steps-midc  |jj|jfS#t$rYnwxYw t|}t j |j dt|fS#ttf$r YtdwxYw)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. rrz5Input could not be cast to an at-least-1D NumPy array) rGto_numpyAttributeErrorr rrrrrr)r+s rindex_ofr1rs* ww!1::<//    5 aL yy51144 &z 2   L MM  s), 88 A11B  B ct|tjjr |dSt t|S#t$r Yt dwxYw)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)rR collectionsabcIteratorr[ RuntimeErrorrrrs rsafe_first_elementr8sV#{//0  q6M S ?  LMM s? AAcd}t|tjr|dSt|tjj r t d|D]}||s |cSt|S)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|y tj|S#ttf$rYnwxYw t j |rt j|SdS#t$rYywxYw)NFT)mathr>r[rrisscalarrs r safe_isfinitez)_safe_first_finite..safe_isfiniteso ; ==% %:&      '){{3'72;;s# AT A  s#,,)AA A('A(rr3)rRrflatiterr4r5r6r7r8)rNr=rs r_safe_first_finiter?si"#r{{#1v C11 2LMM CS!  "#&&rcdt|tjjr t |S|S)zP Convert dictview objects to list. Other inputs are returned unchanged. )rRr4r5 MappingViewr|)rs rsanitize_sequencerBs+%T;??+F+FGDJrcddlm}|iS|i}n5t|tr t ||s t||r t |di}|j Dcic]\}}|D]}||}}}}i}i}|j D]:\} } |j| | }||vrtd||d| d| ||<| ||<<|Scc}}}w)aA 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.artistrDrRr issubclassrrr/r[) kw alias_mappingrD canonical alias_listalias to_canonicalcanonical_to_seenretrfrgs rnormalize_kwargsrPs6) z  ]D )j.O  v . |R@ 2?1D1D1F--- :!+-9$-E-L- C 1 $$Q* ) )i(9)(D'Gu e#EGH H'()$I  J-sCc#Kt|}|j|jdz}d}d}t|D]} |j d5 dddntdj| d|jy#1swYnxYw_#t $rt j|YwxYw#|jwxYww)af 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-lockrg?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_namerrangerFileExistsErrortimesleep TimeoutErrorformatunlink)r lock_pathretries sleeptime_s r _lock_pathr_s :Dtyy+==>IGI 7^  "%    HIO I        " JJy ! " s^<C B BCB;8C:B;;C>CCzorderr{c$|t|S)a 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_artistre7s x( ))rc0t|txr||k(S)a 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. )rRrrNrs r _str_equalrhDs c3  ,C1H,rcLt|txr|j|k(S)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. )rRrr rgs r_str_lower_equalrjOs! c3  4CIIK1$44rctjdd}tjddd}tj|d|f||df|d|f||dffS)aZ 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]) rr)rs_r)arrr(backwards r_array_perimeterroZsk:eeAbkGuuR"W~H >> AwJ GRK BL HaK  rcg|j|}g|j|j|}|||z |zdz||<|||z||<tjjj |||dS)a 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]]]) rF)rstrides writeable)rrqrlib stride_tricks as_strided)rmrrrJ new_shape new_stridess r_unfoldrxsP##))"T"I3CKK3T!23K -$6:IdO#D)D0K 66   * *31:3>5: + <wr1' 1235rc+Kt}i}|D]W}t|||}||jvs||ur|||<(tt||}t |t r|||<S|||<Y |j D]\}}t|||d|j D]#\}}||ur t||t|||%y#|j D]#\}}||ur t||t|||%wxYww)zR Temporarily set some attributes; restore original state at context exit. N) rsr__dict__rrRpropertyrsetattrdelattr)rNrsentinelorigsattrrcls_origrs r _setattr_cmrs xH E'sD(+ 3<< 48#3E$KtCy$/H(H-"d 'd /'2 ) $ID# Cs # $ ++- )JD$xT"T4(  )%++- )JD$xT"T4(  )sA)D,)C 7D 8DDc0eZdZdZdZdZdZdZdZy) _OrderedSetc6tj|_yr )r4 OrderedDict_odrs rrz_OrderedSet.__init__s**,rc||jvSr )rrrks rriz_OrderedSet.__contains__sdhhrc,t|jSr )rrrs rrwz_OrderedSet.__iter__sDHH~rc,t|jSr )rrrs rr#z_OrderedSet.__len__s488}rcZ|jj|dd|j|<yr rrtrs rrz_OrderedSet.adds!  S$ rc<|jj|dyr rrs rrz_OrderedSet.discard!s  S$rN) rrrrrirwr#rrr rrrrs - rrctj|tjdk(rgdngdd}|dddf}|d }|d k7}tj|dD]/}||j t d z||dzz||z||<1|S) zS Convert a premultiplied ARGB32 buffer to an unmultiplied RGBA8888 buffer. littlerrrr&)rrr&rrrz.Nr).rr)rtaker- byteorderrollaxisastypeint)bufrgbargbalpharchannels r._premultiplied_argb32_to_unmultiplied_rgba8888r)s 77  1 |! MD sCRCx.C ME A:D;;sB' T] ! !# & ,uT{a/? ?T{    Krc<tjdk(r-tj|gdd}|dddf}|dddf}n,tj|gdd}|ddd f}|dd df}|j d k7rtj ||d z |d |S) zS Convert an unmultiplied RGBA8888 buffer to a premultiplied ARGB32 buffer. rrrrz.Nr)r&rrrrrunsafe)rcasting)r-rrrr'multiply)rgba8888argb32rgb24alpha8s r._unmultiplied_rgba8888_to_premultiplied_argb32r;s }} .ds!I#%++biin5Is24)rRrrq)commands r_pformat_subprocessras,!'3/GKIIIKrc "|jdt|tj|fddi|}|jru|j }t |tr|j}|j}t |tr|j}tdt|d|d||j r|jd|j |jr|jd|j|j S) aj 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%scapture_outputTzThe command z, failed and generated the following output: z and the following error: z stdout: %sz stderr: %s) debugr subprocessrun returncodestdoutrRbytesdecodestderrr7)rloggerrprocrrs r_check_and_log_subprocessrgs LL*734 >>' A$ A& AD  fe $]]_F fe $]]_F&w/01;h)h    {{ ]DKK0 {{ ]DKK0 ;;rcv tjy#t$rtjdYywxYw)zS Perform OS-dependent setup when Matplotlib creates a new GUI application. rN)r-Win32_GetCurrentProcessExplicitAppUserModelIDOSError-Win32_SetCurrentProcessExplicitAppUserModelIDr rr_setup_new_guiapprs3GGI GG  s 88cV|d|djdjdxsdS)z Format the number with at most the number of decimals given as precision. Remove trailing zeros and possibly the decimal point. .f0)rstrip)number precisions r_format_approxrs2 QykN # + +C 0 7 7 < CCrc Vtj|sy|dk(r$|dk(ryttj|}t d|r4tj tjt|dzndtj tj|z S)z Return the number of significant digits to %g-format *value*, assuming that it is known with an error of *delta*. rr&r)r;r>absrspacingr*floorlog10)rldeltas r _g_sig_digitsrs ==  z A:BJJu%&  38DJJs5z* +a /a **TZZ& ' ( ))rcL|r|jr|S|j}|jdr|dd}|jdr|jdd}|j dr|dd}t j dk(r|d k(rd }d d d dj||}|S)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&Npage_page)_l_rr!darwinmetacmdenterpageuppagedown)returnpriorr) isprintabler  startswithrrr-platformr/)unikeykeysymrks r_unikey_or_keysym_to_mplkeyrs&$$& ,,.C ~~e!"g ~~gkk'6* ||L!#2h ||xC6M  c#sm  Jrcbtjfd}j|_|S)ax 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. ct|r|S|Gfdd}jjx|_|_ t ||S)Nc8eZdZWjZfdZy):_make_class_factory..class_factory..subclsc:tf|jfSr )_picklable_class_constructorr)r attr_name base_classfmt mixin_classs r __reduce__zE_make_class_factory..class_factory..subcls.__reduce__s(4$c9jA))+--rN)rrrr)rrrrsrsubclsrs$//J - -rr)rGrYrrr) axes_classrrrrrs @r class_factoryz*_make_class_factory..class_factorysf j+ .   - -[* -14 :;N;N0OO&-  FIz 2 r)rcacher)rrrrs``` r_make_class_factoryrs1&__. +55M rcNt|||}||}|j|S)z(Internal helper for _make_class_factory.)r__new__)rrrrfactoryrs rrr s)!+sI>G * C ;;s rc tjjdj}t |t xr t ||S#t$rYywxYw)z'Return whether *x* is a PyTorch Tensor.torchF)r-r.r/Tensorr0rRrrrs r_is_torch_arrayr  sU[[__W % , , r4  "1b!# )A AAc tjjdj}t |t xr t ||S#t$rYywxYw)z"Return whether *x* is a JAX Array.jaxF)r-r.r/Arrayr0rRrr s r _is_jax_arrayr sU[[__U # ) ) r4  "1b!# r c tjjdj}t |t xr t ||S#t$rYywxYw)z#Check if *x* is a Pandas DataFrame.pandasF)r-r.r/ DataFramer0rRrr s r_is_pandas_dataframer# sU[[__X & 0 0 r4  "1b!# r c tjjdj} ||S#t$rYywxYw#t $rYywxYw)z6Return whether *x* is a TensorFlow Tensor or Variable. tensorflowF)r-r.r/ is_tensorr0r)rrs r_is_tensorflow_arrayr/ sW KKOOL1;; |  s)4A AA AAct|tjr|St|dr|j St|dr(|j }t|tjr|St |st|s t|r1tj|}t|tjr|S|S)zDInternal helper to extract data from e.g. pandas and xarray objects.r/r;) rRrrrr/r;r rrr)rxtmps rr r @ s!RZZ q*zz|q(xx dBJJ 'Kq]1-1Ea1H zz!} dBJJ 'K Hrc\ ||fzS#ttf$r|j|cYSwxYw)aA 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 {}' )r[rrY)rrls r_auto_format_strr[ s6*!eX~ z "!zz%  !s  ++)r FN)r N)T)F)g?NNF)rNr )nrr4collections.abcrrrrr;operatorrpathlibrrrr-rVrFrPrYnumpyrnumpy.exceptionsr ImportErrorrrrrrDrHrJr^r`ryr|rMatplotlibDeprecationWarningrrrrrrrrrr rrr@rr[r]rrrrrr ls_mapperr ls_mapper_rrrrr rrr%r'r)STEP_LOOKUP_MAPr1r8r?rBrPrr_rr* attrgetterrerhrjrorxrrr5 MutableSetrrrrrrrrrrrrrr rrrr r)rfrgs00rr(s       0:.&&./d$ 44nC"C"L%$%H55  .((1 1h8 8 83-.,4H4Hn %(JJeB"Jl8l8^--(/0JZ>B+0#LFT J ) 121q!t2 *4 $ 9x_D#L!H#L2* .!0 . 0 NF($'N5p ##P&I%%c/Bx/B/B8/LM *-5$N/