)Uc@s4dZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddljZddlmZddlZddlZddlZddlZddlZddlZej\ZZZZZ y(e j!e"j#Z$e$sXdZ$nWn e&e'e(fk r{dZ$nXdZ)ddvdYZ*de*fd YZ+d e*fd YZ,d e*fd YZ-de*fdYZ.de*fdYZ/ddwdYZ0de j1fdYZ2de2fdYZ3de2fdYZ4de5fdYZ6dZ7ddxdYZ8dZ9d Z:d!Z;d"Z<d#Z=d$Z>d%Z?d&e"d'Z@d(ZAd)ejBfd*YZCeDd+ZEdeE_FeAd,ZGd-dyd.YZHd/eIfd0YZJd1d2ZKd3dzd4YZLd5d6ZMd7d{d8YZNeNZOd9ZPd:d|d;YZQd<ZRd=ZSejTd>ZUiZVd?ZWd@dAdBdCZXdDZYdEdFZZddGZ[dHZ\dIZ]dJZ^dKZ_dLeIfdMYZ`dNeafdOYZbdPZce"dQZddRZedBdSZfdTZgdUZhdVZidWZjdXd}dYYZkejle"dZZmd[eafd\YZnd]Zod^Zpd_ZqeDd`Zrd~dddgZseIesZtetjugesD]ZvevdAevdBf^q8e"diZwdjZxdkddlZydmZzdnZ{doZ|dpZ}dqZ~drZedskr0e\dAdAdAgste\dAdAdBg ste\gste\dste\d s0tndS(su A collection of utility functions and classes. Many (but not all) from the Python Cookbook -- hence the name cbook i(t generatorsN(trefcCs'tdkrt|St|tSdS(N(tpreferredencodingtNonetunicode(ts((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt unicode_safe's t convertercBs/eZdZdddZdZdZRS(s[ Base class for handling string -> python type with support for missing values tNullcCs||_||_dS(N(tmissingt missingval(tselfR R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__init__1s cCs||jkr|jS|S(N(R R (R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__call__4scCs|j p||jkS(N(tstripR (R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt is_missing8sN(t__name__t __module__t__doc__RR R R(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR,s ttostrcBseZdZdddZRS(sconvert to string or NoneRtcCstj|d|d|dS(NR R (RR (R R R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR =s(RRRR (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR;st todatetimecBs)eZdZddddZdZRS(sconvert to a datetime or Nones%Y-%m-%dRcCs tj|||||_dS(s8use a :func:`time.strptime` format string for conversionN(RR tfmt(R RR R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR BscCs<|j|r|jStj||j}tj|d S(Ni(RR ttimetstrptimeRtdatetime(R Rttup((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR GsN(RRRRR R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR@sttodatecBs)eZdZddddZdZRS(sconvert to a date or Nones%Y-%m-%dRcCs tj|||||_dS(s8use a :func:`time.strptime` format string for conversionN(RR R(R RR R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR PscCs<|j|r|jStj||j}tj|d S(Ni(RR RRRRtdate(R RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR TsN(RRRRR R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRNsttofloatcBs&eZdZdddZdZRS(sconvert to a float or NoneRcCstj||||_dS(N(RR R (R R R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR [scCs |j|r|jSt|S(N(RR tfloat(R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR ^sN(RRRRR R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRYsttointcBs&eZdZdddZdZRS(sconvert to an int or NoneRcCstj||dS(N(RR (R R R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR escCs |j|r|jSt|S(N(RR tint(R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR hsN(RRRRR R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRcstCallbackRegistrycBsQeZdZdefdYZdZdZdZdZdZ RS(s] Handle registering and disconnecting for a set of signals and callbacks:: signals = 'eat', 'drink', 'be merry' def oneat(x): print 'eat', x def ondrink(x): print 'drink', x callbacks = CallbackRegistry(signals) ideat = callbacks.connect('eat', oneat) iddrink = callbacks.connect('drink', ondrink) #tmp = callbacks.connect('drunk', ondrink) # this will raise a ValueError callbacks.process('drink', 123) # will call oneat callbacks.process('eat', 456) # will call ondrink callbacks.process('be merry', 456) # nothing will be called callbacks.disconnect(ideat) # disconnect oneat callbacks.process('eat', 456) # nothing will be called 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. The Python stdlib weakref module can not create weak references to bound methods directly, so we need to create a proxy object to handle weak references to bound methods (or regular free functions). This technique was shared by Peter Parente on his `"Mindtrove" blog `_. tBoundMethodProxycBs2eZdZdZdZdZdZRS(s Our own proxy object which enables weak references to bound and unbound methods and arbitrary callables. Pulls information about the function, class, and instance out of a bound method. Stores a weak reference to the instance to support garbage collection. @organization: IBM Corporation @copyright: Copyright (c) 2005, 2006 IBM Corporation @license: The BSD License Minor bugfixes by Michael Droettboom cCsyOyt|j|_Wntk r5d|_nX|j|_|j|_Wn,t k r}d|_||_d|_nXdS(N( Rtim_selftinstt TypeErrorRtim_functfunctim_classtklasstAttributeError(R tcb((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s      cOss|jdk r*|jdkr*tn<|jdk r]tj|j|j|j}n |j}|||S(s Proxy for a call to the weak referenced object. Take arbitrary params to pass to the callable. Raises `ReferenceError`: When the weak reference refers to a dead object N(R$RtReferenceErrortnewtinstancemethodR'R)(R targstkwargstmtd((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s ! $ cCssyZ|jdkr1|j|jko0|jdkS|j|jkoX|j|jkSWntk rntSXdS(sm Compare the held function and instance with that held by another proxy. N(R$RR't ExceptiontFalse(R tother((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__eq__s , cCs|j| S(s, Inverse of __eq__. (R5(R R4((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__ne__s(RRRR R R5R6(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR"s    cCsGt||_tg|D]}|tf^q|_d|_dS(s(*signals* is a sequence of valid signalsiN(tsettsignalstdictt callbackst_cid(R R8R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s+cCsE||jkrAt|j}|jtd||fndS(s5make sure *s* is a valid signal or raise a ValueErrors)Unknown signal "%s"; valid signals are %sN(R8tlisttsortt ValueError(R RR8((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt _check_signals cCs|j||j|}xc|j|jD]N\}}|jdk rn|jdkrn|j||=q0||kr0|Sq0W|jd7_||j||j<|jS(si register *func* to be called when a signal *s* is generated func will be called iN(R?R"R:titemsR$RR;(R RR'tproxytcidtcallback((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytconnects  ! cCsJxC|jjD]2\}}y ||=Wntk r=qqXdSqWdS(sK disconnect the callback registered with callback id *cid* N(R:R@tKeyError(R RBt eventnamet callbackd((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt disconnects   cOst|j|x`|j|jD]K\}}|jdk r_|jdkr_|j||=q!|||q!WdS(s process signal *s*. All of the functions registered to receive callbacks on *s* will be called with *\*args* and *\*\*kwargs* N(R?R:R@R$R(R RR/R0RBRA((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytprocesss   !( RRRtobjectR"R R?RDRHRI(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR!ls'@    t SchedulercBs2eZdZejZdZdZdZRS(s4 Base class for timeout and idle scheduling icCsGtjj|tj|_t|_tjd7_tj|_dS(Ni( t threadingtThreadR RKtidR3t_stoppedtEventt _stopevent(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s   cCs1|jr dS|jj|jt|_dS(N(RORQR7tjointTrue(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytstops    ( RRRRLtLocktidlelockRNR RT(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRK s   tTimeoutcBs eZdZdZdZRS(s? Schedule recurring events with a wait time in seconds cCs#tj|||_||_dS(N(RKR twaitR'(R RXR'((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR $s  cCs`xY|jjs[|jj|jtjj|j|}tjj|sPqqWdS(N(RQtisSetRXRKRVtacquireR'trelease(R tb((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytrun)s  (RRRR R](((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRW s tIdlecBs&eZdZdZdZdZRS(s3 Schedule callbacks when scheduler is idle g?cCstj|||_dS(N(RKR R'(R R'((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR :s cCs`xY|jjs[|jjtjtjj|j|}tjj |sPqqWdS(N( RQRYRXR^twaittimeRKRVRZR'R[(R R\((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR]>s  (RRRR_R R](((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR^2s t silent_listcBs,eZdZddZdZdZRS(s override repr when returning a list of matplotlib artists to prevent long, meaningless output. This is meant to be used for a homogeneous list of a give type cCs)||_|dk r%|j|ndS(N(ttypeRtextend(R Ratseq((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR Ms  cCsdt||jfS(Ns(tlenRa(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__repr__QscCsdt||jfS(Ns(RdRa(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt__str__TsN(RRRRR ReRf(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR`Gs  cCs:d }|d d !}x |D]}|j|d }qW|S( s%remove latex formatting from mathtexts \mathdefaults\rms\cals\tts\its\t{t}iiR(s \mathdefaults\rms\cals\tts\its\RgRh(treplace(Rtremovetr((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt strip_mathWs   tBunchcBs eZdZdZdZRS(s Often we want to just collect a bunch of stuff together, naming each item of the bunch; a dictionary's OK for that, but a small do- nothing class is even handier, and prettier to use. Whenever you want to group a few variables: >>> point = Bunch(datum=2, squared=4, coord=12) >>> point.datum By: Alex Martelli From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 cKs|jj|dS(N(t__dict__tupdate(R tkwds((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR kscCsD|jj}ddjg|D]}d||j|f^qS(Ns Bunch(%s)s, s%s=%s(RntkeysRR(R Rqtk((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyReos(RRRR Re(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRm^s  cCs)tg|D]}|df^q jS(s'Return a list of unique elements of *x*i(R9Rq(txtval((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytuniquesscCsyt|WntSXtS(s return true if *obj* is iterable(RdR3RS(tobj((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytiterablews cCsot|ttfrtStj|rT|jdkrM|jjdkrMtSt Sny |dWnt SXtS(s(Return True if *obj* looks like a stringitSUR( t isinstancetstrRRStmat isMaskedArraytndimtdtypetkindR3(Rv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytis_string_like~s! cCsEt|stSt|r tSx|D]}t|s'tSq'WtS(s@ Returns true if *obj* is iterable and contains strings (RwR3RRS(Rvto((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytis_sequence_of_stringss    cCst|dot|jS(sCreturn true if *obj* looks like a file object with a *write* methodtwrite(thasattrtcallableR(Rv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytis_writable_file_likescCst| ot| S(s;return true if *obj* is not string like and is not iterable(RRw(Rv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt is_scalarscCsy |dWntSXtSdS(s(return true if *obj* looks like a numberiN(R3RS(Rv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt is_numlikes  trUcCst|r|jdrNddl}|jdd}|j||}nQ|jdr|jdd}ddl}|j||}nt||}t}n*t |dr|}t }n t d|r||fS|S( s *fname* can be a filename or a file handle. Support for gzipped files is automatic, if the filename ends in .gz. *flag* is a read/write flag for :func:`file` s.gziNtURs.bz2tseeks%fname must be a string or file handle( RtendswithtgzipRitopentbz2tBZ2FiletfileRSRR3R>(tfnametflagt return_openedRtfhRtopened((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt to_filehandles$       cCst|pt| S(N(RRw(Rt((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytis_scalar_or_stringstViewVCCachedServercBskeZdZdZdZdZdZdZdZdZ dZ d Z e d Z RS( s Urllib2 handler that takes care of caching files. The file cache.pck holds the directory of files that have been cached. cCs<||_||_|j|jtj||_dS(N(t cache_dirtbaseurlt read_cachetremove_stale_filesturllib2t build_openertopener(R RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s     cCsetjj|\}}tjj|j|}tjj|sRtj|ntjj||S(N(tostpathtsplitRRRtexiststmakedirs(R tfntreldirtfilenametdatadir((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt in_cache_dirs cCs|jd}tjj|s.i|_dSt|d}tj|}|jxT|j D]F\}\}}}tjj |sc|j|||f||sc3s4|]*\}}tfd|DVqdS(c3s$|]}tjj|VqdS(N(RRRR(RR(tdirpath(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pys sN(R7(RRt filenames((RsC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pys ss1ViewVCCachedServer: files listed in cache.pck: %stdebugs0ViewVCCachedServer: files in cache directory: %ss cache.pcks2ViewVCCachedServer:remove_stale_files: removing %stlevelN( R7RR@treducetunionRtwalkRt matplotlibtverbosetreportRRj(R tlistedtexistingR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRs   'cCsB|jd}t|d}tj|j|d|jdS(sJ Write the cache data structure into the cache directory. s cache.pcktwbiN(RRRtdumpRR(R RR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt write_cachescCs~|t|j}|j|}t|d}|j||j||jd|jdf|j|<|jdS(s? Store a received file in the cache directory. RtETags Last-ModifiedN( RdRRRRRtgetRR(R RtdatatheadersRtfullpathR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt cache_files  (cCsX|j}||jkrT|j|\}}}|jd||jd|n|S(sH Make the request conditional if we have a cached file. s If-None-MatchsIf-Modified-Since(t get_full_urlRt add_header(R treqRRtetagtlastmod((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt http_request#s  c Csj|j}|j|\}}}tjjd|dt|d} tj| ||} d| _| S(sU Read the file from the cache since the server has no newer version. s:ViewVCCachedServer: reading data file from cache file "%s"RRi0( RRRRRRRt addinfourltcode( R RtfpRtmsgthdrsRRRRthandle((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pythttp_error_304.s    cCstjjd|j|jfd|jdkr6|S|j}|j|j||jt j t j ||j|j}|j|_|j|_|SdS(s: Update the cache with the returned file. s,ViewVCCachedServer: received response %d: %sRiN( RRRRRtreadRRRRRtStringIO(R RtresponseRtresult((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt http_response;s    c Cs4ttdd}|dkr6ddl}|j}n|j||}d}tjjd|dy|j j |}Wn"tj k r}t |}nX|j j|} | dkrd||f} t| n| d}|r,tjj|djdkrd } nd } t || S|SdS(s. Check the cachedirectory for a sample_data file. If it does not exist, fetch it with urllib from the svn repo and store it in the cachedir. If asfileobj is True, a file object will be returned. Else the path to the file as a string will be returned. tquoteiNs unknown errors!ViewVCCachedServer: retrieving %sRs9file %s not in cache; received %s when trying to retrieveis.csvs.xrcs.txtRkR(s.csvs.xrcs.txt(tgetattrRRturllibRRRRRRRtURLErrorRzRRRERRtsplitexttlower( R Rt asfileobjRRRterrorRtetcachedRtmode((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytget_sample_dataMs0        "  (RRRR RRRRRRRRRSR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRs     cCstjdsItjd}tjj||}|rBt|dS|Sntj}|dkrtj }tjj|d}d}t ||}t_n|j|d|S(s\ Check the cachedirectory ~/.matplotlib/sample_data for a sample_data file. If it does not exist, fetch it with urllib from the mpl svn repo http://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/sample_data/ and store it in the cachedir. If asfileobj is True, a file object will be returned. Else the path to the file as a string will be returned To add a datafile to this directory, you need to check out sample_data from matplotlib svn:: svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/sample_data and svn add the data file you want to support. This is primarily intended for use in mpl examples that need custom data. To bypass all downloading, set the rc parameter examples.download to False and examples.directory to the directory where we should look. sexamples.downloadsexamples.directoryRt sample_datasKhttp://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/sample_data/RN( RtrcParamsRRRRRRtmyserverRt get_configdirR(RRt directoryRRt configdirtcachedirR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR}s      ccsHxA|D]9}||r!|Vqxt||D] }|Vq1WqWdS(si this generator flattens nested containers such as >>> l=( ('John', 'Hunter'), (1,23), [[[[42,(5,23)]]]]) so that >>> for i in flatten(l): print i, John Hunter 1 23 42 5 23 By: Composite of Holger Krekel and Luther Blissett From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294 and Recipe 1.12 in cookbook N(tflatten(Rctscalarptitemtsubitem((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRs   tSortercBs>eZdZdZdddZddZeZeZRS(sf Sort by attribute or item Example usage:: sort = Sorter() list = [(1, 2), (4, 8), (0, 3)] dict = [{'a': 3, 'b': 4}, {'a': 5, 'b': 2}, {'a': 0, 'b': 0}, {'a': 9, 'b': 9}] sort(list) # default sort sort(list, 1) # sort by index 1 sort(dict, 'a') # sort a list of dicts by key 'a' cCsA|jg|D]\}}||^q}|r=||(n|S(N(R=(R RtauxtinplacetjunktiR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt_helpers  # icCs|dkr:|r%|j|}n|}|j|Sgtt|D]}||||f^qM}|j|||SdS(N(RR=trangeRdR(R Rt itemindexRRRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytbyItems    3cCsKgtt|D]}t||||f^q}|j|||S(N(RRdRR(R Rt attributenameRRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt byAttributes8N( RRRRRRRR=R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRs   tXlatorcBs)eZdZdZdZdZRS(sm All-in-one multiple-string-substitution class Example usage:: text = "Larry Wall is the creator of Perl" adict = { "Larry Wall" : "Guido van Rossum", "creator" : "Benevolent Dictator for Life", "Perl" : "Python", } print multiple_replace(adict, text) xlat = Xlator(adict) print xlat.xlat(text) cCs(tjdjttj|jS(s= Build re object based on the keys of the current dictionary t|(tretcompileRRtmaptescapeRq(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt _make_regexscCs||jdS(s( Handler invoked for each regex *match* i(tgroup(R tmatch((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR scCs|jj||S(s. Translate *text*, returns the modified text. (Rtsub(R ttext((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytxlat s(RRRRR R (((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRs  icCsd}d}d}xp|jD]b}|jr|s@|}n|t|td}| sq||dkr||7}qqqW||d}|jdd}||d| S(s6 soundex module conforming to Odell-Russell algorithm t01230120022455012623010202RtAiit0(tuppertisalphatordRi(tnameRdtsoundex_digitstsndxtfctctd((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytsoundexs  RcBsVeZdZdZdZdZdZdZdZdZ dZ RS( s0 Null objects always and reliably "do nothing." cOsdS(N((R R/R0((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR 1scOs|S(N((R R/R0((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR 2scCsdS(NsNull()((R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRf3scCsdS(NsNull()((R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRe4scCsdS(Ni((R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt __nonzero__5scCs|S(N((R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt __getattr__7scCs|S(N((R Rtvalue((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt __setattr__8scCs|S(N((R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt __delattr__9s( RRRR R RfReRRRR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR.s       icCsytjj|stjj|}x_tdt|dD]A}tjj|| }tjj|sAtj||qAqAWnWn>tk r}|j t j kstjj | rqnXdS(s make directory *newdir* recursively, and set *mode*. Equivalent to :: > mkdir -p NEWDIR > chmod MODE NEWDIR iN( RRRRRRdRRRtOSErrorterrnotEEXISTtisdir(tnewdirRtpartsRtthispartterr((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytmkdirs>s %tGetRealpathAndStatcBseZdZdZRS(cCs i|_dS(N(t_cache(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR TscCs|jj|}|dkrtjj|}tjdkrH|}n!tj|}|j |j f}||f}||j|gt|D]-\}}||dD]}||f^q%q S(s return all possible pairs in sequence *x* Condensed by Alex Martelli from this thread_ on c.l.python .. _thread: http://groups.google.com/groups?q=all+pairs+group:*python*&hl=en&lr=&ie=UTF-8&selm=mailman.4028.1096403649.5135.python-list%40python.org&rnum=1 i(t enumerate(RsRRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytallpairsBstmaxdictcBs eZdZdZdZRS(s A dictionary with a maximum size; this doesn't override all the relevant methods to contrain size, just setitem, so use with caution cCs#tj|||_g|_dS(N(R9R tmaxsizet _killkeys(R Ry((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR Ts  cCsf||krOt||jkr<||jd=|jd=n|jj|ntj|||dS(Ni(RdRyRzR7R9t __setitem__(R Rrtv((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR{Xs   (RRRR R{(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRxNs tStackcBs}eZdZd dZdZdZdZdZdZ dZ dZ d Z d Z d Zd ZRS(s Implement a stack where elements can be pushed on and you can move back and forth. But no pop. Should mimic home / back / forward in a browser cCs|j||_dS(N(tcleart_default(R tdefault((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR is cCs(t|js|jS|j|jSdS(s#return the current element, or NoneN(Rdt _elementsRt_pos(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR mscCs |jjS(N(Rt__len__(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRrscCs|jj|S(N(Rt __getitem__(R R?((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRuscCs;t|j}|j|dkr4|jd7_n|S(s8move the position forward and return the current elementi(RdRR(R R<((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytforwardxscCs(|jdkr!|jd8_n|S(s5move the position back and return the current elementii(R(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytback~scCsD|j|jd |_|jj|t|jd|_|S(s push object onto stack at current position - all elements occurring later than the current position are discarded i(RRR7Rd(R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytpushscCs.t|jsdS|j|jd|S(s0push the first element onto the top of the stackNi(RdRR(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pythomescCst|jdkS(Ni(RdR(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytemptyscCsd|_g|_dS(sempty the stackiN(RR(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR~s cCs||jkrtdn|j}|jg}x7|D]/}||kra|j|q?|j|q?Wx|D]}|j|qyW|S(se raise *o* to the top of the stack and return *o*. *o* must be in the stack sUnknown element o(RR>R~R7R(R Rtoldtbubblestthiso((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytbubbles     cCsf||jkrtdn|j}|jx-|D]%}||krQq9q9|j|q9WdS(s!remove element *o* from the stacksUnknown element oN(RR>R~R(R RRR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRjs    N(RRRRR R RRRRRRRR~RRj(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR}bs          cCs+x$tt|D]}|jqWdS(s empty a listN(RqRdtpop(RcR((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytpopallscCs|r:gt|D]}t|r||f^q}nCgt|D]$}t|rG|j|f^qG}|j}g|D]'\}}|j|dkr|^qS(su return all attributes of *o* which match string in match. if case is True require an exact case match. i(tdirRRtfind(RRtcaseRtnamestorig((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytfinddirs 47 cCs/tg|jD]\}}||f^qS(sAreverse the dictionary -- may lose data if values are not unique!(R9R@(RRrR|((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt reverse_dictscCsddlm}m}tj}tjdkro|d|dtd|jj }t |dj }ntjj dr|d|dtd|jj }t |d j d }nTtjj d r|d |dtd|jj }t |d j d }n|S( s%return the memory consumed by processi(tPopentPIPEtsunos5sps -p %d -o osztshelltstdouttlinuxsps -p %d -o rss,szitdarwinsps -p %d -o rss,vszi(t subprocessRRRtgetpidR*R+RSRt readlinesR Rt startswithR(RRRtpidta2tmem((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt report_memorys s0In safezip, len(args[0])=%d but len(args[%d])=%dcGsst|d}xVt|dD]D\}}t||kr!tt||dt|fq!q!Wt|S(s-make sure *args* are equal len before zippingii(RdRvR>t _safezip_msgR;(R/tNxRR]((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytsafezips *cCs*yt||SWntk r%tSXdS(s;return issubclass(x, klass) and return False on a TypeErrorN(t issubclassR%R3(RsR)((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytissubclass_safes cCsNtj|}y&tjj|dt}|jWntk rI|SX|S(Ntcopy(tnpt asanyarrayR{tmasked_invalidR3t shrink_maskR%(Rstxm((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytsafe_masked_invalids t MemoryMonitorcBsSeZddZdZdZddZdddZddd d ZRS( i NcCs5||_tj|jftj|_|jdS(N(t_nmaxRtzerostint32t_memR~(R tnmax((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s cCsd|_t|_dS(Ni(t_nR3t _overflow(R ((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR~s cCsJt}|j|jkr=||j|j<|jd7_n t|_|S(Ni(RRRRRSR(R R((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s   icCs |j}t||}t||}td||}|d|d s ( RvRdRRzRaRyR9R@treprR<tindexttuple(RRtsteptnextR0Rt(t outstream(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt print_path=s$   csr jdt|nd|t|<j|}xw|D]o}||kre|qF|ksFt|rqFqFt||krF|||||gqFqFWdS(Ns%d (RRdRRNt get_referentsRy(RvROtallt current_patht referentstreferent(RtgctobjectsRRRVt show_progress(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyRVTs   sExamining: %r (RttypesRR(RRRRv((RRRRRRVRsC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt print_cycles-s ! tGroupercBsPeZdZgdZdZdZdZdZdZdZ RS(sf This class provides a lightweight way to group arbitrary objects together into disjoint sets when a full-blown graph data structure would be overkill. Objects can be joined using :meth:`join`, tested for connectedness using :meth:`joined`, and all disjoint sets can be retreived by using the object as an iterator. The objects being joined must be hashable and weak-referenceable. For example: >>> 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'] >>> g = Grouper() >>> g.join(a, b) >>> g.join(b, c) >>> g.join(d, e) >>> list(g) [[d, e], [a, b, c]] >>> g.joined(a, b) True >>> g.joined(a, c) True >>> g.joined(a, d) False cCs;i}|_x'|D]}t|g|t|R3RvRSR{tisMAR}RtasarrayR7t getmaskarrayRtisfiniteRytndarrayRt logical_andtnonzerottaketfilled( R/tnrecstmargstseqlistRRstmaskstxdtmasktigood((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytdelete_masked_pointssR !+      &c Csu|j|j}tjd|df}tjt|d}|d|d }tj|dk|}tj|dk|}t|t|kstt|dkrdS|stj|ddtj f|ddtj ffddS||}tj |}tjd|d f} |} tj| ddtj f| ddtj ffddS( s Find index ranges where *mask* is *False*. *mask* will be flattened if it is not already 1-D. Returns Nx2 :class:`numpy.ndarray` with each row the start and stop indices for slices of the compressed :class:`numpy.ndarray` corresponding to each of *N* uninterrupted runs of unmasked values. If optional argument *compressed* is *False*, it returns the start and stop indices into the original :class:`numpy.ndarray`, not the compressed :class:`numpy.ndarray`. Returns *None* if there are no unmasked values. Example:: y = ma.array(np.arange(5), mask = [0,0,1,0,0]) ii = unmasked_index_ranges(ma.getmaskarray(y)) # returns array [[0,2,] [2,4,]] y.compressed()[ii[1,0]:ii[1,1]] # returns array [3,4,] ii = unmasked_index_ranges(ma.getmaskarray(y), compressed=False) # returns array [[0, 2], [3, 5]] y.filled()[ii[1,0]:ii[1,1]] # returns array [3,4,] Prior to the transforms refactoring, this was used to support masked arrays in Line2D. iiiNR(i(i(i( treshapetsizeRt concatenateRRdtcompresstAssertionErrorRtnewaxistcumsum( R t compressedtmtindicestmdifRti1t seglengthst breakpointstic0tic1((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytunmasked_index_rangesSs !? t-tsolids--tdasheds-.tdashdott:tdottedcCs8tjdtddlj}|j|||d|S(s\ This function has been moved to matplotlib.mlab -- please import it from there saless_simple_linear_interpolation has been moved to matplotlib.mlab -- please import it from thereiNtextrap(twarningstwarntDeprecationWarningtmatplotlib.mlabtmlabt less_simple_linear_interpolation(RsRtxiR'R,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR-scCs8tjdtddlj}|jtttdt S(s\ This function has been moved to matplotlib.mlab -- please import it from there sIisvector has been moved to matplotlib.mlab -- please import it from thereiNR'( R(R)R*R+R,tisvectorRsRR.R'(tXR,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR/sg@cCs8tjdtddlj}|j|ddd|S(s\ This function has been moved to matplotlib.mlab -- please import it from there sOvector_lengths has been moved to matplotlib.mlab -- please import it from thereiNtPg@R(R(R)R*R+R,tvector_lengths(R0R1RR,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR2scCs,tjdtddlj}|j|S(s\ This function has been moved to matplotlib.mlab -- please import it from there sVdistances_along_curve has been moved to matplotlib.mlab -- please import it from thereiN(R(R)R*R+R,tdistances_along_curve(R0R,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR3scCs,tjdtddlj}|j|S(s\ This function has been moved to matplotlib.mlab -- please import it from there sLpath_length has been moved to matplotlib.mlab -- please import it from thereiN(R(R)R*R+R,t path_length(R0R,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR4scCs,tjdtddlj}|j|S(s\ This function has been moved to matplotlib.mlab -- please import it from there sRis_closed_polygon has been moved to matplotlib.mlab -- please import it from thereiN(R(R)R*R+R,tis_closed_polygon(R0R,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR5scCs;tjdtddlj}|j||||||S(s\ This function has been moved to matplotlib.mlab -- please import it from there sKquad2cubic has been moved to matplotlib.mlab -- please import it from thereiN(R(R)R*R+R,t quad2cubic(tq0xtq0ytq1xtq1ytq2xtq2yR,((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR6sc'sddfdY}g|D]}||^q }t}}xbtdg|D]}|j^qR}|rt|}|g|D]}||^qfVqEPqEdS(s This generator takes a bunch of iterables that are ordered by func It sends out ordered tuples: (func(row), [rows from all iterators matching func(row)]) It is used by :func:`matplotlib.mlab.recs_join` to join record arrays tmyitercs)eZdZfdZdZRS(cSs'||_d|_|_|jdS(N(titRR0Rtiternext(R R>((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s csPy(|jj|_|j|_Wn!tk rKd|_|_nXdS(N(R>RRR0t StopIterationR(R (R'(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR?s  cSsSd}||jkr+|j}|jn$|jrO||jkrOtdn|S(NsIterator has been left behind(RR0RR?R>(R R0tretval((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR s   (RRR R?R ((R'(sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyR=s N((RStfilterRR0R(R't iterablesR=R>titerstminvalstminkey((R'sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytalign_iteratorss  % 'cCsHt|}|jd|jd}|dkoA|ddk}|S(Nt$s\$ii(Rtcount(Rt dollar_countt even_dollars((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pyt is_math_texts t__main__RR\(((((((((R!R"(s--R#(s-.R$(R%R&(RR(RR\(Rt __future__RRRRR*RRltlocaleRLRRRR(tnumpyRtnumpy.maR{tweakrefRRRctrandomRR-Rt version_infotmajortminor1tminor2RttmptgetpreferredencodingR3RRRR>t ImportErrorR*RRRRRRRR!RMRKRWR^R<R`RlRmRuRwRRRRRRRt BaseHandlerRRSRRRRR9RRRR%R&tget_realpath_and_statR1R2R@RLRRMRPRSRfRiRkRpRsRtRuRwRxRJR}RRRRRRRRRRRRRRRR t _linestylest ls_mapperRotlsR-R/R2R3R4R5R6RGRLRR(((sC/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/cbook.pytsl                       )  3!    !   (   U      4Bw  L 3  .  *