HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyo
�
�)�Uc
@ s�dZddlmZddlZddlZddlZddlZddlZddlZ	e	j
Z
ddlmZddl
jZddljZddlmZd�Zd�Zd�Zd	�Zed
�Zdd�Zd
�Zd�Zd�Zddeededed�Zejjdejd��ej ddeededed��Z!ej ddeededed��Z"ej ddeededed��Z#dZ$ej ddeededed��Z%d�Z&ddeede'e&e(d�Z)d�Z*d�Z+d �Z,d!�Z-d"�Z.d#�Z/dd$�Z0d%fd&��YZ1d'd(d)d*d+fd,�Z2d-�Z3dd.�Z4d/�Z5d0d0d'd'd'd1�Z6d2�Z7d3d4�Z8d5�Z9d6�Z:d7�Z;eed8�Z<d9�Z=d:fd;��YZ>d<�Z?d=d>d?�Z@d@eedee(e	jAdA�ZBddlZddlCZCeCjDdB�ZEdCZFdD�ZGdE�ZHdF�ZIdG�ZJdH�ZKddI�ZLeedJ�ZMddKedL�ZNdddM�ZOdNdO�ZPeCjDdP�dQ�ZQdR�ZRdS�ZSdT�ZTdU�ZUedV�ZVdW�ZWdX�ZXdY�ZYdZ�ZZd[ed\d]d^�Z[d_d'ed`�Z\d@dddaeedbee(dc�	Z]ddfde��YZ^dfe^fdg��YZ_dhe^fdi��YZ`dje`fdk��YZadle^fdm��YZbdne^fdo��YZcdpeafdq��YZddreafds��YZedteafdu��YZfdve^fdw��YZgdxegfdy��YZhiec�e	ji6eb�e	jj6eb�e	jk6eb�e	jl6ea�e	jm6ea�e	jn6e^�e	jo6e_�e	jp6Zqedz�Zrd{�Zsed|d|ed}�Ztdaedbee'd~�Zudd��Zve(ev_we(d��Zxd��Zyed��Zzd��Z{d��Z|d��Z}d��Z~d��Zd��Z�d��Z�dPed��Z�d��Z�d��Z�d��Z�dS(�sW


Numerical python functions written for compatability with MATLAB
commands with the same names.

MATLAB compatible functions
-------------------------------

:func:`cohere`
  Coherence (normalized cross spectral density)

:func:`csd`
  Cross spectral density uing Welch's average periodogram

:func:`detrend`
  Remove the mean or best fit line from an array

:func:`find`
  Return the indices where some condition is true;
         numpy.nonzero is similar but more general.

:func:`griddata`
  interpolate irregularly distributed data to a
             regular grid.

:func:`prctile`
  find the percentiles of a sequence

:func:`prepca`
  Principal Component Analysis

:func:`psd`
  Power spectral density uing Welch's average periodogram

:func:`rk4`
  A 4th order runge kutta integrator for 1D or ND systems

:func:`specgram`
  Spectrogram (power spectral density over segments of time)

Miscellaneous functions
-------------------------

Functions that don't exist in MATLAB, but are useful anyway:

:meth:`cohere_pairs`
    Coherence over all pairs.  This is not a MATLAB function, but we
    compute coherence a lot in my lab, and we compute it for a lot of
    pairs.  This function is optimized to do this efficiently by
    caching the direct FFTs.

:meth:`rk4`
    A 4th order Runge-Kutta ODE integrator in case you ever find
    yourself stranded without scipy (and the far superior
    scipy.integrate tools)

:meth:`contiguous_regions`
    return the indices of the regions spanned by some logical mask

:meth:`cross_from_below`
    return the indices where a 1D array crosses a threshold from below

:meth:`cross_from_above`
    return the indices where a 1D array crosses a threshold from above


record array helper functions
-------------------------------

A collection of helper methods for numpyrecord arrays

.. _htmlonly:

    See :ref:`misc-examples-index`

:meth:`rec2txt`
    pretty print a record array

:meth:`rec2csv`
    store record array in CSV file

:meth:`csv2rec`
    import record array from CSV file with type inspection

:meth:`rec_append_fields`
    adds  field(s)/array(s) to record array

:meth:`rec_drop_fields`
    drop fields from record array

:meth:`rec_join`
    join two record arrays on sequence of fields

:meth:`recs_join`
    a simple join of multiple recarrays using a single column as a key

:meth:`rec_groupby`
    summarize data by groups (similar to SQL GROUP BY)

:meth:`rec_summarize`
    helper code to filter rec array fields into new fields

For the rec viewer functions(e rec2csv), there are a bunch of Format
objects you can pass into the functions that will do things like color
negative values red, set percent formatting and scaling, etc.

Example usage::

    r = csv2rec('somefile.csv', checkrows=0)

    formatd = dict(
        weight = FormatFloat(2),
        change = FormatPercent(2),
        cost   = FormatThousands(2),
        )


    rec2excel(r, 'test.xls', formatd=formatd)
    rec2csv(r, 'test.csv', formatd=formatd)
    scroll = rec2gtk(r, formatd=formatd)

    win = gtk.Window()
    win.set_size_request(600,800)
    win.add(scroll)
    win.show_all()
    gtk.main()


Deprecated functions
---------------------

The following are deprecated; please import directly from numpy (with
care--function signatures may differ):


:meth:`load`
    load ASCII file - use numpy.loadtxt

:meth:`save`
    save ASCII file - use numpy.savetxt

i����(tdivisionN(tverbose(t	docstringcC s.tjtjtj|�tj|�|��S(N(tnptexptlinspacetlog(txmintxmaxtN((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlogspace�scC stjtj||��S(sreturn sqrt(x dot x)(Rtsqrttdot(tx((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt_norm�scC stjt|��|S(s+return x times the hanning window of len(x)(Rthanningtlen(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytwindow_hanning�scC s|S(s#No window function; simply return x((R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytwindow_none�scC s<|dks|dkr"t|�S|dkr8t|�SdS(Ntconstanttlinear(tNonetdetrend_meantdetrend_linear(R
tkey((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdetrend�s
icC stj|�}|dks6|dks6|jdkrG||j|�Std�g|j}tj||<||j|�|S(s0Return x minus its mean along the specified axisiiN(RtasarrayRtndimtmeantslicetnewaxis(R
taxistind((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdemean�s'
cC s||j�S(sReturn x minus the mean(x)(R(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�scC s|S(sReturn x: no detrending((R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdetrend_none�scC srtjt|�dtj�}tj||dd�}|d|d}|j�||j�}||||S(s2Return y minus best fit line; 'linear' detrending tdtypetbiasii(ii(ii(RtarangeRtfloat_tcovR(tyR
tCtbta((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�s
iitdefaultc
C s�||k}
tj|�}|
s3tj|�}nt|�|krst|�}tj||f�}d||)n|
r�t|�|kr�t|�}tj||f�}d||)n|dkr�|}n|	dkr�t}	n|dkr�tj|�s|dkr|}d}
n/|dkr=|dd}d}
ntd	��|	r\|
|}
ntj	|�rt|}n|tj
|f|j��}||}tjdt|�|d|�}t|�}tj
||ftj�}x�t|�D]�}||||||!}|||�}tjj|d
|�}|
rI|}nA||||||!}|||�}tjj|d
|�}tj|| �|| |dd�|f<q�W|dtj|�dj�9}|ddc!|
9+|	r|ddgc|<nd|||d}t|�|tj|�}tj|�rZ|dksf|dkr�tj||d|||d f�}tj||dd�dd�f|d|d�dd�ffd�}n|||fS(
NiR,ttwosidedg�?tonesidediig@s:sides must be one of: 'default', 'onesided', or 'twosided'tni����(sdefaultR.(RRRtresizeRtTruetiscomplexobjt
ValueErrortcbooktiterabletonesR#R%tzerostcomplex_trangetfftt	conjugatetabstsumtfloattconcatenate(R
R(tNFFTtFsRtwindowtnoverlaptpad_totsidest
scale_by_freqt	same_dataR/tnumFreqstscaling_factort
windowValststepR tPxytitthisXtfxtfytthisYtttfreqs((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt_spectral_helper�sh

		'		
	
#	/!')OtPSDs�

    Keyword arguments:

      *NFFT*: integer
          The number of data points used in each block for the FFT.
          Must be even; a power 2 is most efficient.  The default value is 256.

      *Fs*: scalar
          The sampling frequency (samples per time unit).  It is used
          to calculate the Fourier frequencies, freqs, in cycles per time
          unit. The default value is 2.

      *detrend*: callable
          The function applied to each segment before fft-ing,
          designed to remove the mean or linear trend.  Unlike in
          MATLAB, where the *detrend* parameter is a vector, in
          matplotlib is it a function.  The :mod:`~matplotlib.pylab`
          module defines :func:`~matplotlib.pylab.detrend_none`,
          :func:`~matplotlib.pylab.detrend_mean`, and
          :func:`~matplotlib.pylab.detrend_linear`, but you can use
          a custom function as well.

      *window*: callable or ndarray
          A function or a vector of length *NFFT*. To create window
          vectors see :func:`window_hanning`, :func:`window_none`,
          :func:`numpy.blackman`, :func:`numpy.hamming`,
          :func:`numpy.bartlett`, :func:`scipy.signal`,
          :func:`scipy.signal.get_window`, etc. The default is
          :func:`window_hanning`.  If a function is passed as the
          argument, it must take a data segment as an argument and
          return the windowed version of the segment.

      *noverlap*: integer
          The number of points of overlap between blocks.  The default value
          is 0 (no overlap).

      *pad_to*: integer
          The number of points to which the data segment is padded when
          performing the FFT.  This can be different from *NFFT*, which
          specifies the number of data points used.  While not increasing
          the actual resolution of the psd (the minimum distance between
          resolvable peaks), this can give more points in the plot,
          allowing for more detail. This corresponds to the *n* parameter
          in the call to fft(). The default is None, which sets *pad_to*
          equal to *NFFT*

      *sides*: [ 'default' | 'onesided' | 'twosided' ]
          Specifies which sides of the PSD to return.  Default gives the
          default behavior, which returns one-sided for real data and both
          for complex data.  'onesided' forces the return of a one-sided PSD,
          while 'twosided' forces two-sided.

      *scale_by_freq*: boolean
          Specifies whether the resulting density values should be scaled
          by the scaling frequency, which gives density in units of Hz^-1.
          This allows for integration over the returned frequency values.
          The default is True for MATLAB compatibility.
c	C s:t||||||||||�
\}	}
|	j|
fS(s�
    The power spectral density by Welch's average periodogram method.
    The vector *x* is divided into *NFFT* length blocks.  Each block
    is detrended by the function *detrend* and windowed by the function
    *window*.  *noverlap* gives the length of the overlap between blocks.
    The absolute(fft(block))**2 of each segment are averaged to compute
    *Pxx*, with a scaling to correct for power loss due to windowing.

    If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.

    *x*
        Array or sequence containing the data

    %(PSD)s

    Returns the tuple (*Pxx*, *freqs*).

    Refs:

        Bendat & Piersol -- Random Data: Analysis and Measurement
        Procedures, John Wiley & Sons (1986)

    (tcsdtreal(R
R@RARRBRCRDRERFtPxxRS((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytpsdjsc

C swt||||||||||	�
\}
}}t|
j�dkrm|
jddkrm|
jdd�}
n|
|fS(s
    The cross power spectral density by Welch's average periodogram
    method.  The vectors *x* and *y* are divided into *NFFT* length
    blocks.  Each block is detrended by the function *detrend* and
    windowed by the function *window*.  *noverlap* gives the length
    of the overlap between blocks.  The product of the direct FFTs
    of *x* and *y* are averaged over each segment to compute *Pxy*,
    with a scaling to correct for power loss due to windowing.

    If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
    padded to *NFFT*.

    *x*, *y*
        Array or sequence containing the data

    %(PSD)s

    Returns the tuple (*Pxy*, *freqs*).

    Refs:
        Bendat & Piersol -- Random Data: Analysis and Measurement
        Procedures, John Wiley & Sons (1986)
    iiR(RTRtshapeR(
R
R(R@RARRBRCRDRERFRLRSRR((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRV�s
(i�c	C sFt||||||||||�
\}	}
}|	j}	|	|
|fS(s�
    Compute a spectrogram of data in *x*.  Data are split into *NFFT*
    length segements and the PSD of each section is computed.  The
    windowing function *window* is applied to each segment, and the
    amount of overlap of each segment is specified with *noverlap*.

    If *x* is real (i.e. non-complex) only the spectrum of the positive
    frequencie is returned.  If *x* is complex then the complete
    spectrum is returned.

    %(PSD)s

    Returns a tuple (*Pxx*, *freqs*, *t*):

         - *Pxx*: 2-D array, columns are the periodograms of
           successive segments

         - *freqs*: 1-D array of frequencies corresponding to the rows
           in Pxx

         - *t*: 1-D array of times corresponding to midpoints of
           segments.

    .. seealso::

        :func:`psd`
            :func:`psd` differs in the default overlap; in returning
            the mean of the segment periodograms; and in not returning
            times.
    (RTRW(R
R@RARRBRCRDRERFRXRSRR((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytspecgram�s#	swCoherence is calculated by averaging over *NFFT*
length segments.  Your signal is too short for your choice of *NFFT*.
c
C s�t|�d|kr%tt��nt|||||||||	�	\}
}t|||||||||	�	\}}t||||||||||	�
\}
}tjtj|
�d|
|�}t|�f|_||fS(s�
    The coherence between *x* and *y*.  Coherence is the normalized
    cross spectral density:

    .. math::

        C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}

    *x*, *y*
        Array or sequence containing the data

    %(PSD)s

    The return value is the tuple (*Cxy*, *f*), where *f* are the
    frequencies of the coherence vector. For cohere, scaling the
    individual densities by the sampling frequency has no effect,
    since the factors cancel out.

    .. seealso::

        :func:`psd` and :func:`csd`
            For information about the methods used to compute
            :math:`P_{xy}`, :math:`P_{xx}` and :math:`P_{yy}`.
    i(	RR3t
_coh_errorRYRVRtdividetabsoluteRZ(R
R(R@RARRBRCRDRERFRXtftPyyRLtCxy((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcohere�s#cG sdS(N((targs((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdonothing_callback�sc
$C s�|j\}
}|
|kr^|}tj||f|j�}||d|
�dd�f<~n|j\}
}t�}
x.|D]&\}}|
j|�|
j|�q}Wt|
�}tj|�r�|}n|dd}tj	|�r�|}n|tj
||j��}td|
|d||�}t|�}i}i}i}t|�}tjj
|�d}x�|
D]�}|||d�tj||fdtj�}xf|D]^}||||||�|f}|||�}tjj|�| ||dd�f<q�W|||<|r5tj|�||<ntjtjt|�d�|�||<qqW~~~i}i}d} t|�}!x�|D]�\}}| d7} | ddkr�|| |!d�n|r�||||}"n||tj||�}"|dkrtj|"�}"n|"|}"t|"�d|||||||f<tj|"j|"j�|||f<q�W||tj|�}#|	r�|||#|fS|||#fSdS(	uI
    Call signature::

      Cxy, Phase, freqs = cohere_pairs( X, ij, ...)

    Compute the coherence and phase for all pairs *ij*, in *X*.

    *X* is a *numSamples* * *numCols* array

    *ij* is a list of tuples.  Each tuple is a pair of indexes into
    the columns of X for which you want to compute coherence.  For
    example, if *X* has 64 columns, and you want to compute all
    nonredundant pairs, define *ij* as::

      ij = []
      for i in range(64):
          for j in range(i+1,64):
              ij.append( (i,j) )

    *preferSpeedOverMemory* is an optional bool. Defaults to true. If
    False, limits the caching by only making one, rather than two,
    complex cache arrays. This is useful if memory becomes critical.
    Even when *preferSpeedOverMemory* is False, :func:`cohere_pairs`
    will still give significant performace gains over calling
    :func:`cohere` for each pair, and will use subtantially less
    memory than if *preferSpeedOverMemory* is True.  In my tests with
    a 43000,64 array over all nonredundant pairs,
    *preferSpeedOverMemory* = True delivered a 33% performance boost
    on a 1.7GHZ Athlon with 512MB RAM compared with
    *preferSpeedOverMemory* = False.  But both solutions were more
    than 10x faster than naively crunching all possible pairs through
    :func:`cohere`.

    Returns::

       (Cxy, Phase, freqs)

    where:

      - *Cxy*: dictionary of (*i*, *j*) tuples -> coherence vector for
        that pair.  I.e., ``Cxy[(i,j) = cohere(X[:,i], X[:,j])``.
        Number of dictionary keys is ``len(ij)``.

      - *Phase*: dictionary of phases of the cross spectral density at
        each frequency for each pair.  Keys are (*i*, *j*).

      - *freqs*: vector of frequencies, equal in length to either the
         coherence or phase vectors for any (*i*, *j*) key.

    Eg., to make a coherence Bode plot::

          subplot(211)
          plot( freqs, Cxy[(12,19)])
          subplot(212)
          plot( freqs, Phase[(12,19)])

    For a large number of pairs, :func:`cohere_pairs` can be much more
    efficient than just calling :func:`cohere` for each pair, because
    it caches most of the intensive computations.  If :math:`N` is the
    number of pairs, this function is :math:`O(N)` for most of the
    heavy lifting, whereas calling cohere for each pair is
    :math:`O(N^2)`.  However, because of the caching, it is also more
    memory intensive, making 2 additional complex arrays with
    approximately the same number of elements as *X*.

    See :file:`test/cohere_pairs_test.py` in the src tree for an
    example script that shows that this :func:`cohere_pairs` and
    :func:`cohere` give the same results for a given pair.

    .. seealso::

        :func:`psd`
            For information about the methods used to compute
            :math:`P_{xy}`, :math:`P_{xx}` and :math:`P_{yy}`.
    Niiis
Cacheing FFTsR#i
sComputing coherences(RZRR7R#tsettaddRR2R4R5R6R9tlinalgtnormR8R:R;R]RR<tarctan2timagRWR%($tXtijR@RARRBRCtpreferSpeedOverMemorytprogressCallbackt	returnPxxtnumRowstnumColsttmpt
allColumnsRMtjtNcolsRHRJR t	numSlicest	FFTSlicest
FFTConjSlicesRXtslicestnormValtiColtSlicestiSlicet	thisSliceRatPhasetcountR	RLRS((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcohere_pairssrQ	
		

"*
-	

*&cC s�tj||�\}}|jtj�}tj|tj|�d�}tj|t|��}|d|d}dtj|t	|��t	|�}|S(s�
    Return the entropy of the data in *y*.

    .. math::

      \sum p_i \log_2(p_i)

    where :math:`p_i` is the probability of observing *y* in the
    :math:`i^{th}` bin of *bins*.  *bins* can be a number of bins or a
    range of bins; see :func:`numpy.histogram`.

    Compare *S* with analytic calculation for a Gaussian::

      x = mu + sigma * randn(200000)
      Sanalytic = 0.5 * ( 1.0 + log(2*pi*sigma**2.0) )
    iig�(
Rt	histogramtastypeR&ttaketnonzeroR]RR=R(R(tbinsR/tptdeltatS((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytentropy�s'cG sI|\}}dtjdtj�|tjdd|||d�S(sCReturn the normal pdf evaluated at *x*; args provides *mu*, *sigma*g�?ig�(RRtpiR(R
Rctmutsigma((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytnormpdf�sc
C st|�}|ddkr,tdd�n|d|d}d||tj|d|dtj�}tjtj|d|t�tjd|dt�g�}|d|d}t|tjdt	|�|�}tj
j
tj||�|�jtj�}	tj|	|�S(s@Returm the levy pdf evaluated at *x* for params *gamma*, *alpha*iis%x must be an event length array; try
s/x = np.linspace(minx, maxx, N), where N is eveni(
RR3RR%R&R?tintRR^R�R:R�R�(
R
tgammatalphaR	tdxR_R tdftcfltpx((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlevypdf�s
-&.cC stjtj|��\}|S(s1Return the indices where ravel(condition) is true(RR�travel(t	conditiontres((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytfind�scC s>tj|�}t|�dkr.tjg�S|dkj�d}t|�dkritjt|��St|�t|�kr�tjg�Stjt|�df|j�}||dd+tj|�}|dkj�d}|dkj�d}||t	||�kj�dd}tj||||�}|S(s�
    Return the indices of the longest stretch of contiguous ones in *x*,
    assuming *x* is a vector of zeros and ones.  If there are two
    equally long stretches, pick the first.
    iiii����(
RR�RtarrayR�R%R7R#tdifftmax(R
R R(tdiftuptdnRM((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlongest_contiguous_ones�s 

"
(cC s
t|�S(s!alias for longest_contiguous_ones(R�(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlongest_ones�scC s�tjd�tjj|�\}}}|d|jd}|j�}||}t||kj��}|dd�|fj�}	tj	|	|�}
|
|	||fS(s�

    WARNING: this function is deprecated -- please see class PCA instead

    Compute the principal components of *P*.  *P* is a (*numVars*,
    *numObs*) array.  *frac* is the minimum fraction of variance that a
    component must contain to be included.

    Return value is a tuple of the form (*Pcomponents*, *Trans*,
    *fracVar*) where:

      - *Pcomponents* : a (numVars, numObs) array

      - *Trans* : the weights matrix, ie, *Pcomponents* = *Trans* *
         *P*

      - *fracVar* : the fraction of the variance accounted for by each
         component returned

    A similar function of the same name was in the MATLAB
    R13 Neural Network Toolbox but is not found in later versions;
    its successor seems to be called "processpcs".
    s4This function is deprecated -- see class PCA insteadiiN(
twarningstwarnRRgtsvdRZR=Rt	transposeR(tPtfractUtstvtvarEachttotVartfracVarR tTranstPcomponents((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytprepcas

tPCAcB s5eZd�Zdd�Zd�Zed��ZRS(c	C s�|j\}}||kr*td��n|||_|_|jdd�|_|jdd�|_|j|�}||_	t
jj|dt
�\}}}t
j||j�j}|dtt|��}||j�|_||_||_dS(s
        compute the SVD of a and store data for PCA.  Use project to
        project the data onto a reduced set of dimensions

        Inputs:

          *a*: a numobservations x numdims array

        Attrs:

          *a* a centered unit sigma version of input a

          *numrows*, *numcols*: the dimensions of a

          *mu* : a numdims array of means of a

          *sigma* : a numdims array of atandard deviation of a

          *fracs* : the proportion of variance of each of the principal components

          *Wt* : the weight vector for projecting a numdims point or array into PCA space

          *Y* : a projected into PCA space


        The factor loadings are in the Wt factor, ie the factor
        loadings for the 1st principal component are given by Wt[0]

        s5we assume data in a is organized with numrows>numcolsRit
full_matricesiN(RZtRuntimeErrortnumrowstnumcolsRR�tstdR�tcenterR+RRgR�tFalseRtTR>RR=tfracstWttY(	tselfR+R/tmR�R�tVhR�tvars((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt__init__&s	!	gcC s�tj|�}t|j�}|jd|jkrJtd|j��ntj|j|j|�j	�j	}|j
|k}|dkr�|dd�|f}n
||}|S(sWproject x onto the principle axes, dropping any axes where fraction of variance<minfraci����s#Expected an array with dims[-1]==%diN(RRRRZR�R3RR�R�R�R�(R�R
tminfractndimsR�tmasktYreduced((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytproject]s$
cC s||j|jS(s<center the data using the mean and sigma from training set a(R�R�(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�qscC s�tjddddddddd	d
ddd
dddddddg�}tjdddddddddddd d!d"d#d$d%d&d'd(g�}|d)|}d*|d+|}tj||||g�j}|S(,Nguy���?g��9��?gK�'z�j�?g�ypaz�?g��{b�?g��L��?g�Ҙ9�z�?g�H;Ey��?g�8��?g��l|�?g.Ta�w�?g/`v
�?gVt��n�?g{-��r�?gp�~�;�?g4��H��?g״ޱе�?g^�*�1�?g����?g-
F'��?g�)Ȯ8��gA
�ºq�g
���ѿg|G*�u.�?ge��@t�?gl#��gbV�D�?�?g���,#w�?g�_����?g�
� |�?g�q6>���g�	eD��g�T����g2E��5
�?g�"P�YM�?gzQ��ݿg��<��?gG.��Ҽ¿g�d���ֿg������?ii����i(RR�R�(tc0tc1tc2tc3R+((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
_get_colinearws(t__name__t
__module__R�R�R�tstaticmethodR�(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�%s	7	gg9@gI@g�R@gY@cC sd�}t}tj|�r't}ntj|�}tj|�j�}|j�|d|jdd}|j	tj
�}|d}|d}	|t|�k}
|r�|
r|d8}|d8}|	d7}	qn0||
cd8<||
cd8<|	|
cd7<||||||	�S(sS
    Return the percentiles of *x*.  *p* can either be a sequence of
    percentile values or a scalar.  If *p* is a sequence, the ith
    element of the return sequence is the *p*(i)-th percentile of *x*.
    If *p* is a scalar, the largest value of *x* less than or equal to
    the *p* percentage point in the sequence is returned.
    cS s||||S(ssReturns the point at the given fraction between a and b, where
        'fraction' must be between 0 and 1.
        ((R+R*tfraction((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt_interpolate�sgY@ii(R1R4R5R�RR�R�tsortRZR�R�R(R
R�R�tscalartpertvaluestidxstaitbiR�tcond((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytprctile�s*
		




cC s�tj|�s/tjd|dd|�}ntj|�}|j�dkst|j�dkst|j�dkr�td��nt||�}tj	||�S(s
    Return the rank for each element in *x*, return the rank
    0..len(*p*).  Eg if *p* = (25, 50, 75), the return value will be a
    len(*x*) array with values in [0,1,2,3] where 0 indicates the
    value is less than the 25th percentile, 1 indicates the value is
    >= the 25th and < 50th percentile, ... and 3 indicates the value
    is above the 75th percentile cutoff.

    *p* is either an array of percentiles in [0..100] or a scalar which
    indicates how many quantiles of data you want ranked.
    gY@iiids/percentiles should be in range 0..100, not 0..1(
R4R5RR%RR�tminR3R�tsearchsorted(R
R�tptiles((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytprctile_rank�s
 6cC s�tj|tj�}|rD||jdd�|jdd�}nR||jdd�dd�tjf}||jdd�dd�tjf}|S(s�
    Return the matrix *M* with each row having zero mean and unit std.

    If *dim* = 1 operate on columns instead of rows.  (*dim* is
    opposite to the numpy axis kwarg.)
    RiiN(RRR&RR�R(tMtdim((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
center_matrix�s)))c
C s}yt|�}Wn/tk
rAtjt|�ftj�}n"Xtjt|�|ftj�}||d<d}xtjt|�d�D]�}||}||d|}|d}||}tj|||��}	tj||||	||��}
tj||||
||��}tj||||||��}||d|	d|
d||||d<q�W|S(s�
    Integrate 1D or ND system of ODEs using 4-th order Runge-Kutta.
    This is a toy implementation which may be useful if you find
    yourself stranded on a system w/o scipy.  Otherwise use
    :func:`scipy.integrate`.

    *y0*
        initial state vector

    *t*
        sample times

    *derivs*
        returns the derivative of the system and has the
        signature ``dy = derivs(yi, ti)``


    Example 1 ::

        ## 2D system

        def derivs6(x,t):
            d1 =  x[0] + 2*x[1]
            d2 =  -3*x[0] + 4*x[1]
            return (d1, d2)
        dt = 0.0005
        t = arange(0.0, 2.0, dt)
        y0 = (1,2)
        yout = rk4(derivs6, y0, t)

    Example 2::

        ## 1D system
        alpha = 2
        def derivs(x,t):
            return -alpha*x + exp(-t)

        y0 = 1
        yout = rk4(derivs, y0, t)


    If you have access to scipy, you should probably be using the
    scipy.integrate tools rather than this function.
    iig@g@i(Rt	TypeErrorRR7R&R%R(
tderivsty0RRtNytyoutRMtthisttdttdt2tk1tk2tk3tk4((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrk4�s$.
"!
 


$$$2g�?cC s�||}||}|||}	|d|d|d|dd|	||||}
dtj||tjd|	d�}tj|
dd|	d�|S(s�
    Bivariate Gaussian distribution for equal shape *X*, *Y*.

    See `bivariate normal
    <http://mathworld.wolfram.com/BivariateNormalDistribution.html>`_
    at mathworld.
    ii(RR�RR(RkR�tsigmaxtsigmaytmuxtmuytsigmaxytXmutYmutrhotztdenom((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytbivariate_normal$s	

:*cC s1tj|j�\}}||||||fS(s.
    *Z* and *Cond* are *M* x *N* matrices.  *Z* are data and *Cond* is
    a boolean matrix where some condition is satisfied.  Return value
    is (*x*, *y*, *z*) where *x* and *y* are the indices into *Z* and
    *z* are the values of *Z* at those indices.  *x*, *y*, and *z* are
    1D arrays.
    (RtindicesRZ(tZtCondRkR�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
get_xyz_where5sg�������?cC s�tj||f�d}xmtt|||��D]Q}tjjd|d�}tjjd|d�}tjj�|||f<q4W|S(sT
    Return a *M* x *N* sparse matrix with *frac* elements randomly
    filled.
    gii(RR7R9R�trandomtrandinttrand(R�R	R�tdataRMR
R(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytget_sparse_matrix@s!cC s#||}tjtj||��S(s1
    Return the distance between two points.
    (RRR(R
R(td((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdistLs
c	C s�tj|tj�}tj|tj�}tj|tj�}||}||}tj||�}|dkr~t||�Stj||�}||kr�t||�S||}|||}t||�S(s�
    Get the distance of a point to a segment.

      *p*, *s0*, *s1* are *xy* sequences

    This algorithm from
    http://softsurfer.com/Archive/algorithm_0102/algorithm_0102.htm#Distance%20to%20Ray%20or%20Segment
    i(RRR&RR(	R�ts0ts1R�twR�R�R*tpb((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdist_point_to_segmentSs	




cC s�|\\}}\}}|\\}}\}}	|	|||||||}
|||||	|||}||||||||}|
dkr�tS||
}
||
}d|
ko�dkno�d|ko�dkSS(s�
    Return *True* if *s1* and *s2* intersect.
    *s1* and *s2* are defined as::

      s1: (x1, y1), (x2, y2)
      s2: (x3, y3), (x4, y4)
    igg�?(R�(Rts2tx1ty1tx2ty2tx3ty3tx4ty4tdentn1tn2tu1tu2((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytsegments_intersectns"""

cC s�tj|�r"|||�}n|||��}tjj|�}dtjd}|tjjt|��}|tj|�}tjj	|�j
S(s;
    Compute an FFT phase randomized surrogate of *x*.
    g@y�?(R4R5RR:R�R�RRRtifftRW(R
RRBR�R+tphase((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytfftsurr�scC s5tjdt�tjtjtj||����S(s�
    *x* is a very long trajectory from a map, and *fprime* returns the
    derivative of *x*.

    This function will be removed from matplotlib.

    Returns :
    .. math::

        \lambda = \frac{1}{n}\sum \ln|f^'(x_i)|

    .. seealso::

        Lyapunov Exponent
           Sec 10.5 Strogatz (1994) "Nonlinear Dynamics and Chaos".
           `Wikipedia article on Lyapunov Exponent
           <http://en.wikipedia.org/wiki/Lyapunov_exponent>`_.

    .. note::
        What the function here calculates may not be what you really want;
        *caveat emptor*.

        It also seems that this function's name is badly misspelled.
    s6This does not belong in matplotlib and will be removed(R�R�tDeprecationWarningRRRR^(R
tfprime((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	liaupunov�st
FIFOBuffercB sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s�
    A FIFO queue to hold incoming *x*, *y* data in a rotating buffer
    using numpy arrays under the hood.  It is assumed that you will
    call asarrays much less frequently than you add data to the queue
    -- otherwise another data structure will be faster.

    This can be used to support plots where data is added from a real
    time feed and the plot object wants to grab data from the buffer
    and plot it to screen less freqeuently than the incoming.

    If you set the *dataLim* attr to
    :class:`~matplotlib.transforms.BBox` (eg
    :attr:`matplotlib.Axes.dataLim`), the *dataLim* will be updated as
    new data come in.

    TODO: add a grow method that will extend nmax

    .. note::

      mlab seems like the wrong place for this class.
    cC s�tj|ftj�|_tj|ftj�|_tj|ftj�|_tj|ftj�|_d|_||_d|_
i|_dS(s-
        Buffer up to *nmax* points.
        iN(RR7R&t_xat_yat_xst_yst_indt_nmaxRtdataLimt	callbackd(R�tnmax((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR��s			cC s |jj|g�j|�dS(sk
        Call *func* every time *N* events are passed; *func* signature
        is ``func(fifo)``.
        N(R't
setdefaulttappend(R�tfuncR	((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytregister�scC s�|jdk	r=tj||fg�}|jj|d�n|j|j}||j|<||j|<xN|j	j
�D]=\}}|j|dkrwx|D]}||�q�WqwqwW|jd7_dS(s6
        Add scalar *x* and *y* to the queue.
        iiN(R&RRRtupdate_from_data_xyR$R%R"R#R'titems(R�R
R(txyR R	tfuncsR+((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRf�s


cC s?|jdkrdS|jd|j}|j||j|fS(sJ
        Get the last *x*, *y* or *None*.  *None* if no data set.
        iiN(NN(R$RR%R"R#(R�R ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlast�scC s�|j|jkr0|j|j |j|j fS|j|j}|j||j|j|*|j| |j|j|)|j||j|j|*|j| |j|j|)|j|jfS(sm
        Return *x* and *y* as arrays; their length will be the len of
        data added or *nmax*.
        (R$R%R"R#R R!(R�R ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytasarrays�scC s`|jdkrtd��n|j�\}}|jj||t�|jj||t�dS(sG
        Update the *datalim* in the current data in the fifo.
        s#You must first set the dataLim attrN(R&RR3R2tupdate_from_dataR1tupdate_numerix(R�R
R(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytupdate_datalim_to_currents
(	R�R�t__doc__R�R,RfR1R2R5(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�s	
				cC s<tj|fdtj�}d||(tj||dd�S(s5
    Compute the len(*n*) moving average of *x*.
    R#g�?tmodetvalid(RtemptyR&tconvolve(R
R/R((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmovavgss%.18et c	C s(tjdt�tj|�ra|jd�rOddl}|j|d�}q�t|d�}n$t	|d�ry|}nt
d��tj|�}d}|jd	kr�|j}t|�d	f|_nx?|D]7}|j|jg|D]}||^q��d
�q�W|dk	r$||_ndS(s�
    Save the data in *X* to file *fname* using *fmt* string to convert the
    data to strings.

    Deprecated.  Use numpy.savetxt.

    *fname* can be a filename or a file handle.  If the filename ends
    in '.gz', the file is automatically saved in compressed gzip
    format.  The :func:`load` function understands gzipped files
    transparently.

    Example usage::

      save('test.out', X)         # X is an array
      save('test1.out', (x,y,z))  # x,y,z equal sized 1D arrays
      save('test2.out', x)        # x is 1D
      save('test3.out', x, fmt='%1.4e')  # use exponential notation

    *delimiter* is used to separate the fields, eg. *delimiter* ','
    for comma-separated values.
    suse numpy.savetxts.gzi����NtwbRtseeks%fname must be a string or file handleis
(R�R�RR4tis_string_liketendswithtgziptopentfilethasattrR3RRRRRZRtwritetjoin(	tfnameRktfmtt	delimiterRAtfht	origShapetrowtval((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytsaves$		
5t#c stjdt�|dkr%i}ntj|�}g}	�dkrRd�}
n�fd�}
d}x0t|�D]"\}}
||kr�qtn|
j|d�dj�}
t	|
�s�qtn|dkrgt|
|
��D]\}}|j
|t�^q�}n|dk	rH|
|
�}g|D]}||||�^q%}n5gt|
|
��D]\}}|||�^q[}t	|�}|	j|�qtWt
j|	|�}	|	j\}}|dks�|dkr�t||�f|	_n|r�|	j�S|	SdS(s
    Load ASCII data from *fname* into an array and return the array.

    Deprecated: use numpy.loadtxt.

    The data must be regular, same number of values in every row

    *fname* can be a filename or a file handle.  Support for gzipped
    files is automatic, if the filename ends in '.gz'.

    matfile data is not supported; for that, use :mod:`scipy.io.mio`
    module.

    Example usage::

      X = load('test.dat')  # data in two columns
      t = X[:,0]
      y = X[:,1]

    Alternatively, you can do the same with "unpack"; see below::

      X = load('test.dat')    # a matrix of data
      x = load('test.dat')    # a single column of data

    - *comments*: the character used to indicate the start of a comment
      in the file

    - *delimiter* is a string-like character used to seperate values
      in the file. If *delimiter* is unspecified or *None*, any
      whitespace string is a separator.

    - *converters*, if not *None*, is a dictionary mapping column number to
      a function that will convert that column to a float (or the optional
      *dtype* if specified).  Eg, if column 0 is a date string::

        converters = {0:datestr2num}

    - *skiprows* is the number of rows from the top to skip.

    - *usecols*, if not *None*, is a sequence of integer column indexes to
      extract where 0 is the first column, eg ``usecols=[1,4,5]`` to extract
      just the 2nd, 5th and 6th columns

    - *unpack*, if *True*, will transpose the matrix allowing you to unpack
      into named arguments on the left hand side::

        t,y = load('test.dat', unpack=True) # for  two column data
        x,y,z = load('somefile.dat', usecols=[3,5,7], unpack=True)

    - *dtype*: the array will have this dtype.  default: ``numpy.float_``

    .. seealso::

        See :file:`examples/pylab_examples/load_converter.py` in the source tree
           Exercises many of these options.
    suse numpy.loadtxtR<cS s
|j�S(N(tsplit(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	splitfunc�sc s
|j��S(N(RP(R
(RI(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRQ�siiN(R�R�RRR4t
to_filehandlet	enumerateRPtstripRtgetR>R*RR�RZR�R�(RGtcommentsRIt
converterstskiprowstusecolstunpackR#RJRkRQtconverterseqRMtlineRtRMtvalsRLtthisLentrtc((RIsB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytloadQs@;	7*2
gg�������cC s?t|�tjkr.ttj|tt��Stj|�SdS(s�
    Compute exponentials which safely underflow to zero.

    Slow, but convenient to use. Note that numpy provides proper
    floating point exception handling with access to the underlying
    hardware.
    N(ttypeRtndarrayRtcliptexp_safe_MINtexp_safe_MAXtmath(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytexp_safe�s	cG stjt||��S(s�
    amap(function, sequence[, sequence, ...]) -> array.

    Works like :func:`map`, but it returns an array.  This is just a
    convenient shorthand for ``numpy.array(map(...))``.
    (RR�tmap(tfnRc((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytamap�scC s#tjtjtj|�d��S(sP
    Return the root mean square of all the elements of *a*, flattened out.
    i(RRRR^(R+((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrms_flatscC stjtj|��S(s�
    Return the *l1* norm of *a*, flattened out.

    Implemented as a separate function (not a call to :func:`norm` for speed).
    (RR=R^(R+((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytl1normscC s#tjtjtj|�d��S(s�
    Return the *l2* norm of *a*, flattened out.

    Implemented as a separate function (not a call to :func:`norm` for speed).
    i(RRR=R^(R+((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytl2normscC sH|dkr"tjtj|��Stjtj|�|�d|SdS(s
    norm(a,p=2) -> l-p norm of a.flat

    Return the l-p norm of *a*, considered as a flat array.  This is NOT a true
    matrix norm, since arrays of arbitrary rank are always flattened.

    *p* can be a number or the string 'Infinity' to get the L-infinity norm.
    tInfinityg�?N(RtamaxR^R=(R+R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	norm_flatscK s�|jdd�|ddk}|dkr?|d}d}n|dkrTd}ny&|d}||t||�}Wn/tk
r�tt|||��|}nXtj|�||S(s�
    frange([start,] stop[, step, keywords]) -> array of floats

    Return a numpy ndarray containing a progression of floats. Similar to
    :func:`numpy.arange`, but defaults to a closed interval.

    ``frange(x0, x1)`` returns ``[x0, x0+1, x0+2, ..., x1]``; *start*
    defaults to 0, and the endpoint *is included*. This behavior is
    different from that of :func:`range` and
    :func:`numpy.arange`. This is deliberate, since :func:`frange`
    will probably be more useful for generating lists of points for
    function evaluation, and endpoints are often desired in this
    use. The usual behavior of :func:`range` can be obtained by
    setting the keyword *closed* = 0, in this case, :func:`frange`
    basically becomes :func:numpy.arange`.

    When *step* is given, it specifies the increment (or
    decrement). All arguments can be floating point numbers.

    ``frange(x0,x1,d)`` returns ``[x0,x0+d,x0+2d,...,xfin]`` where
    *xfin* <= *x1*.

    :func:`frange` can also be called with the keyword *npts*. This
    sets the number of points the list should contain (and overrides
    the value *step* might have been given). :func:`numpy.arange`
    doesn't offer this option.

    Examples::

      >>> frange(3)
      array([ 0.,  1.,  2.,  3.])
      >>> frange(3,closed=0)
      array([ 0.,  1.,  2.])
      >>> frange(1,6,2)
      array([1, 3, 5])   or 1,3,5,7, depending on floating point vagueries
      >>> frange(1,6.5,npts=5)
      array([ 1.   ,  2.375,  3.75 ,  5.125,  6.5  ])
    tclosediigg�?tnptsN(R)RR>tKeyErrorR�troundRR%(txinitxfinR�tkwtendpointRs((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytfrange(s)
		

"tlcC s`|dk	r|}ntj|f||�}x+t|�D]}|f|}d||<q;W|S(s
    Returns the identity matrix of shape (*n*, *n*, ..., *n*) (rank *r*).

    For ranks higher than 2, this object is simply a multi-index Kronecker
    delta::

                            /  1  if i0=i1=...=iR,
        id[i0,i1,...,iR] = -|
                            \  0  otherwise.

    Optionally a *dtype* (or typecode) may be given (it defaults to 'l').

    Since rank defaults to 2, this function behaves in the default case (when
    only *n* is given) like ``numpy.identity(n)`` -- but surprisingly, it is
    much faster.
    iN(RRR7R9(R/trankR#ttypecodetidenRMtidx((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytidentityls	
cC s�d}||kr0|d|d|t|�Sttj|�tj|��}t|�|}t||�}||t||||t|d|��S(sF
    Return the representation of a *number* in any given *base*.
    t$0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZii(R�RgRtlongt	base_reprR�(tnumbertbasetpaddingtcharstmax_exponentt	max_powert
lead_digit((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR��s"icC s�ttj||gt|ddd��}ttj||dg�}|jd�s[dS||jd�}djtt|��j	dd�S(sO
    Return the binary representation of the input *number* as a
    string.

    This is more efficient than using :func:`base_repr` with base 2.

    Increase the value of max_length for very large numbers. Note that
    on 32-bit machines, 2**1023 is the largest integer power of 2
    which can be converted to a Python float.
    ii����iittL(
RitoperatortrshiftR9tmodR�tindexRFtreprtreplace(R�t
max_lengthtshiftstdigits((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytbinary_repr�s
g@cC sgyt|�d}Wn%ttfk
r;tj|�|SXd|krYtj|�|St|�SdS(s�
    Return the log(*x*) in base 2.

    This is a _slow_ function but which is guaranteed to return the correct
    integer value if the input is an integer exact power of 2.
    it1N(R�tAssertionErrorR�RgRR(R
tln2tbin_n((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytlog2�scC s.t|�d}d|kr dSt|�SdS(s�
    Returns the log base 2 of *n* if *n* is a power of 2, zero otherwise.

    Note the potential ambiguity if *n* == 1: 2**0 == 1, interpret accordingly.
    iR�iN(R�R(R/R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytispower2�scC s"tj|j�tj|j�kS(sZ
    Like the MATLAB function with the same name, returns *True*
    if the supplied numpy array or matrix *X* looks like a vector,
    meaning it has a one non-singleton axis (i.e., it can have
    multiple axes, but all must have length 1, except for one of
    them).

    If you just want to see if the array has 1 axis, use X.ndim == 1.
    (RtprodRZR�(Rk((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytisvector�s
cC sTtj|�rtSytj|�}Wn#tk
r:tStk
rKtSX|SdS(s':func:`numpy.isnan` for arbitrary typesN(R4R?R�RtisnantNotImplementedErrorR�(R
R*((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
safe_isnan�s

cC sTtj|�rtSytj|�}Wn#tk
r:tStk
rKtSX|SdS(s':func:`numpy.isinf` for arbitrary typesN(R4R?R�RtisinfR�R�(R
R*((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
safe_isinf�s

c
C s�tj|�retj|�ret|�retj|d�ret|�t|�krwtd�qwn|g}|g}ttj|�}|dkr�g|D]}|j	^q�}ntj|�s�|g}nt|�t|�krt|�dkr|t|�}qtd�ntj	|j	j
t||��}tj|j
d|�}x"|j	jD]}||||<q_Wx't||�D]\}}	|	||<q�W|S(s�
    Return a new record array with field names populated with data
    from arrays in *arrs*.  If appending a single field, then *names*,
    *arrs* and *dtypes* do not have to be lists. They can just be the
    values themselves.
    is-number of arrays do not match number of namesis-dtypes must be None, a single dtype or a listR#N(R4R?R5RR3RiRRRR#tdescrtziptrecarrayRZtfields(
trectnamestarrstdtypesR+tnewdtypetnewrectfieldtnametarr((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec_append_fields�s,		"cC s�t|�}t|�}tjg|jjD]%}||kr+||j|f^q+�}tj|jd|�}x|jD]}||||<q{W|S(sI
    Return a new numpy record array with fields in *names* dropped.
    R#(ReRRR#R�R�RZ(R�R�tNrR�R�R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec_drop_fields
s(cC s_tj|�r!|jd�}ng}x|D]}|j||�q.Wtjj|d|�S(sJ
    Return a new numpy record array with only fields listed in names
    t,R�(R4R?RPR*RR�t
fromarrays(R�R�tarraysR�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec_keep_fieldss
cC s3t�}xVt|�D]H\}}tg|D]}||^q,�}|j|g�j|�qW|j�}|j�g}	xn|D]f}t|�}||}
||
}|jg|D]\}}}
|||�^q��|	j|�q�Wt	|�\}}}t|�}|j|�t
jj|	d|�S(s�
    *r* is a numpy record array

    *groupby* is a sequence of record array attribute names that
    together form the grouping key.  eg ('date', 'productcode')

    *stats* is a sequence of (*attr*, *func*, *outname*) tuples which
    will call ``x = func(attr)`` and assign *x* to the record array
    output with attribute *outname*.  For example::

      stats = ( ('sales', len, 'numsales'), ('sales', np.mean, 'avgsale') )

    Return record array has *dtype* names for each attribute name in
    the the *groupby* argument, with the associated group values, and
    for each outname name in the *stats* argument, with the associated
    stat summary output.
    R�(
tdictRSttupleR)R*tkeysR�tlisttextendR�RR�tfromrecords(R_tgroupbytstatstrowdRMRLtattrRR�trowsR tthisrR+toutnametattrsR0toutnamesR�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec_groupby+s"	#



3
cC s�t|jj�}g|D]}||^q}xD|D]<\}}}|j|�|jtj|||���q6Wtjj|d|�S(sL
    *r* is a numpy record array

    *summaryfuncs* is a list of (*attr*, *func*, *outname*) tuples
    which will apply *func* to the the array *r*[attr] and assign the
    output to a new attribute name *outname*.  The returned record
    array is identical to *r*, with extra arrays for each element in
    *summaryfuncs*.

    R�(R�R#R�R*RRR�R�(R_tsummaryfuncsR�R�R�R�R+R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
rec_summarizeZs
$tinnerR�t2c)
 s;tj��r�f�nxX�D]P}|�jjkrMtd|��n|�jjkr"td|��q"q"W�fd�}tgt��D]\}	}
||
�|	f^q��}tgt��D]\}	}
||
�|	f^q��}t|j��}
t|j��}|
|@}t	j
g|D]}||^q.�}t	j
g|D]}||^qT�}t|�}d}}|dks�|dkr�|
j|�}t	j
g|D]}||^q��}t|�}n|dkr/|j|
�}t	j
g|D]}||^q�}t|�}n�fd�}g�D]}||�^qE}���fd�}���fd	�}g�jj
D]0}|d�kr�||d�|d
f^q�}g�jj
D]0}|d�kr�||d�|d
f^q�} t	j||| �}!t	j|||fd|!�}"|dk	r�x=|D]2}#|#|!jkrWtjd|#|!jf�qWqWWnx7|!jD],}|!|}$|$jdkr�d|"|<q�q�W|dkr-|dk	r-|"jjj�}%x6|j�D]%\}}&||%kr|&|"|<qqWnx}�jjD]o}'||'�}(|rk�|'||"|(|*n|dks�|dkr:|r:�|'||"|(|||+q:q:Wxw�jjD]i}'||'�}(|'�kr�|r��|'||"|(|*n|dkr�|r��|'||"|(|)q�q�W|"jd��|"S(s
    Join record arrays *r1* and *r2* on *key*; *key* is a tuple of
    field names -- if *key* is a string it is assumed to be a single
    attribute name. If *r1* and *r2* have equal values on all the keys
    in the *key* tuple, then their fields will be merged into a new
    record array containing the intersection of the fields of *r1* and
    *r2*.

    *r1* (also *r2*) must not have any duplicate keys.

    The *jointype* keyword can be 'inner', 'outer', 'leftouter'.  To
    do a rightouter join just reverse *r1* and *r2*.

    The *defaults* keyword is a dictionary filled with
    ``{column_name:default_value}`` pairs.

    The keywords *r1postfix* and *r2postfix* are postfixed to column names
    (other than keys) that are both in *r1* and *r2*.
    sr1 does not have key field %ssr2 does not have key field %sc s!tg�D]}||^q
�S(N(R�(RLR�(R(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmakekey�sitoutert	leftouterc s��j|}|jtjkr4||jddfS�j|}|j|jkrh||jddfS||jddfSdS(sGif name is a string key, use the larger size of r1 or r2 before mergingiiN(R#RbRtstring_R�tnum(R�tdt1R�(tr1(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytkey_desc�s

c s.|�ks|�jjkr"|S|�SdS(sU
        The column name in *newrec* that corresponds to the column in *r1*.
        N(R#R�(R�(Rt	r1postfixtr2(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmapped_r1field�sc s.|�ks|�jjkr"|S|�SdS(sU
        The column name in *newrec* that corresponds to the column in *r2*.
        N(R#R�(R�(RR�t	r2postfix(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmapped_r2field�siR#s6rec_join defaults key="%s" not in new dtype names "%s"R_RMR�torderN(R_RM(R4R?R#R�R3R�RSReR�RR�Rt
differenceR�R�RR�R�tkindR�R.R�()RR�R�tjointypetdefaultsR�R�R�R�RMRLtr1dtr2dtr1keystr2keystcommon_keystktr1indtr2indt
common_lentleft_lent	right_lent	left_keystleft_indt
right_keyst	right_indR�tkeydescR�R�tdesctr1desctr2descR�R�tthiskeyR�t
newrec_fieldsR�R�tnewfield((RR�R�R�R�sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec_joinpsz
77
&&
&&CC 
	
$R�c sbg}tjtj|�g|D]}t|�^q�}��fd�}	|dkr�x�|D])\}
}|j|
gt|	|��q_WnR|dkr�xC|D]8\}
}d|kr�|j|
gt|	|��q�q�Wn|dkrgtt	|��D]}d|^q}ndj
|gg|D]}
d�|
f^q,�}tjj
|d|�S(	s�
    Join a sequence of record arrays on single column key.

    This function only joins a single column of the multiple record arrays

    *key*
      is the column name that acts as a key

    *name*
      is the name of the column that we want to join

    *recs*
      is a list of record arrays to join

    *jointype*
      is a string 'inner' or 'outer'

    *missing*
      is what any missing field is replaced by

    *postfixes*
      if not None, a len recs sequence of postfixes

    returns a record array with columns [rowkey, name0, name1, ... namen-1].
    or if postfixes [PF0, PF1, ..., PFN-1] are supplied,
      [rowkey, namePF0, namePF1, ... namePFN-1].

    Example::

      r = recs_join("date", "close", recs=[r0, r1], missing=0.)

    c s|dkr�S|�SdS(N(R(R_(tmissingR�(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytextractsR�R�s%dR�s%s%sR�N(R4talign_iteratorsR�t
attrgettertiterR*RiRR9RRFRR�R�(RR�trecsR�R�t	postfixestresultsR_t
aligned_itersR�trowkeyRLRMtpostfixR�((R�R�sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	recs_join�s!4$',3R�R�c
$ sm�dkrt��n�dkr-i�nddl}
ddl}|
jj}tj|��dd"d��Y}
|dkr�|
���ntj	�d|�}��fd�}||���fd���fd	��d
��|
jj���|j
ddd���
�ttj
���td���td��
��d���fd
��	��	|j
ddd���	���	�
���
fd��idd6dd6dd6}������fd�}�dk}|r8x:|D]2}t|�r|dj|�rq�n|}Pq�Wtd�}|jd�g�t�}xt|�D]�\}}|j�j�jdd�}djg|D]}||kr�|^q��}t|�s�d|}n|j||�}|j|d�}|dkr�j|d|�n
�j|�|d||<q]Wn:tj��rrg�jd�D]}|j�^qW�n||�}|dkr�td��n�jd�tj	�d|�}||�|rx8|j�}t|�r�|dj|�r�q�nPq�ng}g}x�t|�D]�\}}t|�s=qn|dj|�rVqn|jgt |�|�D]\}} }!|| |!�^qo�|jgt �|�D]\} }!�| |!�^q��qW�j!�t|�s�dS|	rQtj"|�rQyddl#m$}"Wnt%k
r2t&d��qiX|"j'|d �d!|�}#ntj(j'|d ��}#|#S(#su
    Load data from comma/space/tab delimited file in *fname* into a
    numpy record array and return the record array.

    If *names* is *None*, a header row is required to automatically
    assign the recarray names.  The headers will be lower cased,
    spaces will be converted to underscores, and illegal attribute
    name characters removed.  If *names* is not *None*, it is a
    sequence of names to use for the column names.  In this case, it
    is assumed there is no header row.


    - *fname*: can be a filename or a file handle.  Support for gzipped
      files is automatic, if the filename ends in '.gz'

    - *comments*: the character used to indicate the start of a comment
      in the file

    - *skiprows*: is the number of rows from the top to skip

    - *checkrows*: is the number of rows to check to validate the column
      data type.  When set to zero all rows are validated.

    - *converterd*: if not *None*, is a dictionary mapping column number or
      munged column name to a converter function.

    - *names*: if not None, is a list of header names.  In this case, no
      header will be read from the file

    - *missingd* is a dictionary mapping munged column names to field values
      which signify that the field does not contain actual data and should
      be masked, e.g. '0000-00-00' or 'unused'

    - *missing*: a string whose value signals a missing field regardless of
      the column it appears in

    - *use_mrecords*: if True, return an mrecords.fromrecords record array if any of the data are missing

      If no rows are found, *None* is returned -- see :file:`examples/loadrec.py`
    i����NtFHcB sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(sC
        For space-delimited files, we want different behavior than
        comma or tab.  Generally, we want multiple spaces to be
        treated as a single separator, whereas with comma and tab we
        want multiple commas to return multiple (empty) fields.  The
        join/strip trick below effects this.
        cS s
||_dS(N(RJ(R�RJ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�gscS s|jj�dS(N(RJtclose(R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRjscS s|jj|�dS(N(RJR>(R�targ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>mscS sdj|j��S(NR<(RFRP(R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytfixpscS s|j|jj��S(N(RRJtnext(R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRtscs s&x|jD]}|j|�Vq
WdS(N(RJR(R�R\((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt__iter__ws(	R�R�R6R�RR>RRR(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR_s					R<RIc sD�r:x1t|�D] \}}|�dkrPqqWn�|fS(Ni(RS(treaderRMRL(RJRX(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytprocess_skiprowss
c s9|�ks-|�j|�ks-|dkr1tStSdS(s.Should the value val in column name be masked?R�N(RUR1R�(R�RM(R�tmissingd(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	ismissing�s-c s���fd�}|S(Nc s!�||�r�S�|�SdS(N((R�RM(R,R+R
(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytnewfunc�s((R+R,R(R
(R,R+sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytwith_default_value�scS s0|dkrtS|dkr tStd��dS(NR1R�sinvalid bool(R1R�R3(R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmybool�s
iR�c sR�|�}|jdks9|jdks9|jdkrHtd��n|j�S(Nis
not a date(thourtminutetsecondR3tdate(R
R(t
dateparser(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytmydate�s-c s{i��6��6��6��6��6}y|||�Wn6|�kr[td��qw�||||�SnX|SdS(Ns,Could not find a working conversion function(R3(R�titemR+tfuncmap(tget_funcR
Rtmydateparsertmyfloattmyinttmystr(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�s)treturn_treturntfile_RCtprint_tprintc sd}xt|�D]�\}}|dkrA�gt|�}n�rW|�krWPnx�tt�|��D]�\}\}}�j|�}|dkr��j|�}n|dkr�||}t|j��r��|||�}q�n�|d�}|||<qmWqW|S(Ni(RRSRR�RURT(RRWRMRLRtR�RR+(t	checkrowst
converterdRR
R�R(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytget_converters�s"(
is~!@#$%^&*()-=+~\|]}[{';: /?.>,<t"t_scolumn%ds_%dR�s)Could not find any valid data in CSV file(tmrecordss8numpy 1.05 or later is required for masked array supportR�R�(()RR�tdateutil.parsertdatetimetparsertparseR4RRtcsvRRR>RtnanR�tstrRt
startswithReRfRSRTtlowerR�RFRUR*R?RPR3R>RR�Rtanytnumpy.maR%tImportErrorR�R�R�($RGRVRXR RIR!R�R�R	tuse_mrecordstdateutilR't	parsedateRRRtitemdR"t
needheaderRLtheaderstdeletetseenRMRR`tcntR/RWR�trowmasksR+R�RMR%R_((R R!RRJRR
R�R	R
RRRRRR�RXRsB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcsv2rec%s�,	
		!


	.

+

><

t	FormatObjcB s#eZd�Zd�Zd�ZRS(cC s
|j|�S(N(ttoval(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyttostr)	scC s
t|�S(N(R,(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>,	scC s|S(N((R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytfromstr/	s(R�R�R?R>R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR=(	s		tFormatStringcB seZd�ZRS(cC st|�}|dd!S(Nii����(R�(R�R
RM((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR?3	s(R�R�R?(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRA2	stFormatFormatStrcB seZd�Zd�ZRS(cC s
||_dS(N(RH(R�RH((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�>	scC s$|dkrdS|j|j|�S(NR(RRHR>(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR?A	s(R�R�R�R?(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRB=	s	tFormatFloatcB s)eZddd�Zd�Zd�ZRS(ig�?cC s*tj|d|�||_||_dS(Ns%%1.%df(RBR�t	precisiontscale(R�RDRE((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�I	s	cC s |dk	r||j}n|S(N(RRE(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>N	scC st|�|jS(N(R>RE(R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR@S	s(R�R�R�R>R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRCH	s	t	FormatIntcB s#eZd�Zd�Zd�ZRS(cC sdt|�S(Ns%d(R�(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR?Y	scC s
t|�S(N(R�(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>\	scC s
t|�S(N(R�(R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR@_	s(R�R�R?R>R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRFW	s		t
FormatBoolcB seZd�Zd�ZRS(cC s
t|�S(N(R,(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>e	scC s
t|�S(N(tbool(R�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR@h	s(R�R�R>R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRGb	s	t
FormatPercentcB seZdd�ZRS(icC stj||dd�dS(NREgY@(RCR�(R�RD((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�l	s(R�R�R�(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRIk	stFormatThousandscB seZdd�ZRS(icC stj||dd�dS(NREg����MbP?(RCR�(R�RD((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�p	s(R�R�R�(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRJo	stFormatMillionscB seZdd�ZRS(icC stj||dd�dS(NREg���ư>(RCR�(R�RD((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�u	s(R�R�R�(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRKt	st
FormatDatecB s#eZd�Zd�Zd�ZRS(cC s
||_dS(N(RH(R�RH((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�z	scC s |dkrdS|j|j�S(NR(RtstrftimeRH(R�R
((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>}	scC s"ddl}|jj|�j�S(Ni����(R&R(R)R(R�R
R3((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR@�	s(R�R�R�R>R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRLy	s		tFormatDatetimecB seZdd�Zd�ZRS(s%Y-%m-%d %H:%M:%ScC stj||�dS(N(RLR�(R�RH((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR��	scC sddl}|jj|�S(Ni����(R&R(R)(R�R
R3((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR@�	s(R�R�R�R@(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRN�	scC s�|dkrt�}nxmt|jj�D]Y\}}|j|}|j|�}|dkrztj|jt��}n|||<q+W|S(s=build a formatd guaranteed to have a key for every dtype nameN(	RR�RSR#R�RUtdefaultformatdRbR=(R_tformatdRMR�R�tformat((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytget_formatd�	s
cC s7tj|�}t|t�r3d|_d|_n|S(Ng�?s%r(tcopytdeepcopyt
isinstanceRCRERH(RQ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcsvformat_factory�	s
	ic	 s�|dk	rt||�}ntj|�rF|gt|j�}nt�fd���fd�}|dkr�|jj}ngt|jj�D]/\}}||||j	|�||�^q�}g}	x�t
t|��D]�}||\}
}}|dkr$|	j|
||df�q�||d\}
}}|
dkrs|
dkrs|	j|
|�|df�q�|
dkr�|
dkr�|	j|
||�f�q�|	j|
||df�q�W�fd�}g}|jdjgt|�D]\}}|||	|�^q���xt|�D]q\}}|jdjgt|�D]\}}|||	|�^qM��|dkr(|dj
�|d<q(q(Wtjj|�}|S(s�
    Returns a textual representation of a record array.

    *r*: numpy recarray

    *header*: list of column headers

    *padding*: space between each column

    *precision*: number of decimal places to use for floats.
        Set to an integer to apply to all floats.  Set to a
        list of integers to apply precision individually.
        Precision for non-floats is simply ignored.

    *fields* : if not None, a list of field names to print.  fields
    can be a list of strings like ['field1', 'field2'] or a single
    comma separated string like 'field1,field2'

    Example::

      precision=[0,2,3]

    Output::

      ID    Price   Return
      ABC   12.54    0.234
      XYZ    6.32   -0.076
    c sKitd6tt6tt6}y|t|��Wn�|||�SX|S(N(R�RR>R,(Rtatypettdict(tget_type(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRY�	sc st|d�}|tjksL|tjksL|tjksL|tjkrutt|�|j�}d|�dfS|tj	ks�|tj
ks�|tjks�|tjks�|tj
ks�|tjkrtt|�tjtttt|����}d|�dfS|tjksj|tjksj|tjksjttd�r[|tjksj|tjkr�dt|�d�tt|�tjttt�fd�|����}d|��fSdtt|�tjtttt|�����dfS(	Nis%sis%dtfloat96s%.R_c s�|S(N((R
(RH(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt<lambda>�	s(RbRR,tstr_tstring0R�R�RtitemsizeR�tint16tint32tint64tint8tint_RiR>tfloat32tfloat64RDRZR&(tcolnametcolumnRDtntypetlength(R�(RHsB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytget_justify�	s<Z0Z9iic s�|\}}}}|dkr9|dt|�j|�S�|�tkr^|t|�}n%�|�tkr�|t|�}n|j|�SdS(NiR<(R,tljustR>R�trjust(Rtjust_pad_prec_spacertjusttpadtprectspacer(RY(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyRQ

sR�N(RR�R4t
is_numlikeRR#R�R�RSt__getitem__R9R*RFtrstriptostlinesep(R_theaderR�RDR�RjRMRftjustify_pad_prectjustify_pad_prec_spacerRnRoRptpjusttppadtpprecRQttextlRttcolitemRLttext((RYR�sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec2txt�	s:H BBcC s�|d	krt�}nd�}|jdkr?td��nt||�}g}x@t|jj�D],\}	}
|j|t	||
�j
��qgWtj|ddt
�\}}tj|d|�}
|jj}|r�|
j|�ng}x'|D]}
|j|j|
|��q�Wt}t|�rJ|d}t|d�}nx�|D]�}|r||j�|jj�}}ntgt|�}|
jgt||||�D]$\}}}}||||�^q��qQW|r�|j�nd	S(
s�
    Save the data from numpy recarray *r* into a
    comma-/space-/tab-delimited file.  The record array dtype names
    will be used for column headers.

    *fname*: can be a filename or a file handle.  Support for gzipped
      files is automatic, if the filename ends in '.gz'

    *withheader*: if withheader is False, do not write the attribute
      names in the first row

    for formatd type FormatFloat, we override the precision to store
    full precision floats in the CSV file


    .. seealso::

        :func:`csv2rec`
            For information about *missing* and *missingd*, which can
            be used to fill in masked values into your CSV file.
    c s�fd�}|S(Nc s|r
|S�|�SdS(N((RMR�tmval(R+(sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR>
s((R+R((R+sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt	with_mask=
sis0rec2csv only operates on 1 dimensional recarraysR=t
return_openedRIit
_fieldmaskN(RR�RR3RRRSR#R�R*RVR?R4RRR1R*twritertwriterowRUR�RRDRR�R�R(R_RGRIRPR�R	t
withheaderR�R0RMR�RJtopenedR�RwtmvalstismaskedRLtrowmaskR+RMR�R�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytrec2csv"
s:	$


	BtnncC s0y ddlm}m}t}Wn6tk
rXddlj}	ddlm}t}nXtj	s�|r|t
jd|�nt
jd|�tt_	n|j|jkr�t
d��n|jdkr�|jd	kr�t
d
��nt|�t|�kot|�kns$t
d��nt|d�r�|jjr�|j|jtk�}|j|jtk�}|j�}q�n|r�|d
kr�td��n|jd	kr�|ddd�f}|dd�df}n|jdd�|jdtj�|jtj�}|jtj�}|jtj�}|jtj�}
|jtj�}t|
d|
dd!�dks�t|d|dd!�dkr�td�ntj|jd|
jdftj�}|j||||
||�n|j|jkrt
d��n|jdkrA|jd	krAt
d
��n|jdkrktj||�\}}n|	j||�}
|d
kr�|
j |�}|||�}nI|dkr�|ddd�f|ddd�f}|dd�df|dd�df}tj!|j"�j#}tj!|j"�j#}|j$�|j�|ksl|j$�|j�|kr{td��n|
j%|�}||j�|j$�t&d|jd��|j�|j$�t&d|jd��f}ntd��tj'tj(|��r,tj)j*tj(|�|�}n|S(s�
    ``zi = griddata(x,y,z,xi,yi)`` fits a surface of the form *z* =
    *f*(*x*, *y*) to the data in the (usually) nonuniformly spaced
    vectors (*x*, *y*, *z*).  :func:`griddata` interpolates this
    surface at the points specified by (*xi*, *yi*) to produce
    *zi*. *xi* and *yi* must describe a regular grid, can be either 1D
    or 2D, but must be monotonically increasing.

    A masked array is returned if any grid points are outside convex
    hull defined by input data (no extrapolation is done).

    If interp keyword is set to '`nn`' (default),
    uses natural neighbor interpolation based on Delaunay
    triangulation.  By default, this algorithm is provided by the
    :mod:`matplotlib.delaunay` package, written by Robert Kern.  The
    triangulation algorithm in this package is known to fail on some
    nearly pathological cases. For this reason, a separate toolkit
    (:mod:`mpl_tookits.natgrid`) has been created that provides a more
    robust algorithm fof triangulation and interpolation.  This
    toolkit is based on the NCAR natgrid library, which contains code
    that is not redistributable under a BSD-compatible license.  When
    installed, this function will use the :mod:`mpl_toolkits.natgrid`
    algorithm, otherwise it will use the built-in
    :mod:`matplotlib.delaunay` package.

    If the interp keyword is set to '`linear`', then linear interpolation
    is used instead of natural neighbor. In this case, the output grid
    is assumed to be regular with a constant grid spacing in both the x and
    y directions. For regular grids with nonconstant grid spacing, you
    must use natural neighbor interpolation.  Linear interpolation is only valid if
    :mod:`matplotlib.delaunay` package is used - :mod:`mpl_tookits.natgrid`
    only provides natural neighbor interpolation.

    The natgrid matplotlib toolkit can be downloaded from
    http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792
    i����(t_natgridt__version__N(R�susing natgrid version %ssusing delaunay version %ss=inputs xi and yi must have same number of dimensions (1 or 2)iis"inputs xi and yi must be 1D or 2D.s5inputs x,y,z must all be 1D arrays of the same lengthR�R�sRonly natural neighor interpolation allowed when using natgrid toolkit in griddata.itexttnuls8output grid defined by xi,yi must be monotone increasingRsAoutput grid must have constant spacing when using interp='linear's�interp keyword must be one of 'linear' (for linear interpolation) or 'nn' (for natural neighbor interpolation). Default is 'nn'.(+tmpl_toolkits.natgridR�R�R1R1tmatplotlib.delaunaytdelaunayR�tgriddatat	_reportedRtreportRR�RRDR�tcompresst
compressedR3tsetitsetrRR+R�R>R�R9RZtnatgriddtmeshgridt
Triangulationtnn_interpolatortfinfoR#t
resolutionR�tlinear_interpolatortcomplexR/R�tmatmasked_where(R
R(R�txityitinterpR�R�t_use_natgridR�txotyotzottriR�tdytepsxtepsy((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyR�g
s�%


	.B)**8+2!c
C s�tj|�r|g}ntj|�}tj|�}tj|�}t|j�}t|�|d<tjtj|�}xt	|�D]\}}||k}tj
|�r�tj|�\}	||	d||<q�||dkr|r�|d||<q�q�||dkr+|r�|d||<q�q�tj||k�\}	t|	�}	||	|||	||	d||	||	d||	||<q�W|S(s�
    This function provides simple (but somewhat less so than
    :func:`cbook.simple_linear_interpolation`) linear interpolation.
    :func:`simple_linear_interpolation` will give a list of point
    between a start and an end, while this does true linear
    interpolation at an arbitrary set of points.

    This is very inefficient linear interpolation meant to be used
    only for a small number of points in relatively non-intensive use
    cases.  For real linear interpolation, use scipy.
    ii����i(
R4t	is_scalarRRR�RZRttileR+RSR/R�R�(
R
R(R�textrapR�R�tiitxxtbbtjj((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt less_simple_linear_interpolation�
s.FcC s�tj|tj�}tj|tj�}tj|jtj�}|d|d }|d|d }||}|d |d|d|d |d|d |dd+d|d|d|d|d<d|d|d|d|d<|S(s
    :func:`slopes` calculates the slope *y*'(*x*)

    The slope is estimated using the slope obtained from that of a
    parabola through any three consecutive points.

    This method should be superior to that described in the appendix
    of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
    W. Stineman (Creative Computing July 1980) in at least one aspect:

      Circles for interpolation demand a known aspect ratio between
      *x*- and *y*-values.  For many functions, however, the abscissa
      are given in different dimensions, so an aspect ratio is
      completely arbitrary.

    The parabola method gives very similar results to the circle
    method for most regular cases but behaves much better in special
    cases.

    Norbert Nemec, Institute of Theoretical Physics, University or
    Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de

    (inspired by a original implementation by Halldor Bjornsson,
    Icelandic Meteorological Office, March 2006 halldor at vedur.is)
    ii����g@ii����(RRR&R7RZ(R
R(typR�R�tdydx((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytslopes
s
9""c	C s�tj|tj�}tj|tj�}t|�}|dkrTt||�}ntj|tj�}tj|tj�}tj|jtj�}|d|d }|d|d }||}tj|dd!|�}	|j	|	�}
|j	|	�}|j	|	�}|j	|	d�}
||
||}|j	|	�|
||}|j	|	d�|
||
}||}||tj
tjtj|�tj
�dd|||
|||
|dd||f�}|S(s,
    Given data vectors *x* and *y*, the slope vector *yp* and a new
    abscissa vector *xi*, the function :func:`stineman_interp` uses
    Stineman interpolation to calculate a vector *yi* corresponding to
    *xi*.

    Here's an example that generates a coarse sine curve, then
    interpolates over a finer abscissa::

      x = linspace(0,2*pi,20);  y = sin(x); yp = cos(x)
      xi = linspace(0,2*pi,40);
      yi = stineman_interp(xi,x,y,yp);
      plot(x,y,'o',xi,yi)

    The interpolation method is described in the article A
    CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell
    W. Stineman. The article appeared in the July 1980 issue of
    Creative Computing with a note from the editor stating that while
    they were:

      not an academic journal but once in a while something serious
      and original comes in adding that this was
      "apparently a real solution" to a well known problem.

    For *yp* = *None*, the routine automatically determines the slopes
    using the :func:`slopes` routine.

    *x* is assumed to be sorted in increasing order.

    For values ``xi[j] < x[0]`` or ``xi[j] > x[-1]``, the routine
    tries an extrapolation.  The relevance of the data obtained from
    this, of course, is questionable...

    Original implementation by Halldor Bjornsson, Icelandic
    Meteorolocial Office, March 2006 halldor at vedur.is

    Completely reworked and optimized for Python by Norbert Nemec,
    Institute of Theoretical Physics, University or Regensburg, April
    2006 Norbert.Nemec at physik.uni-regensburg.de
    ii����igN(RRR&RRR�R7RZR�R�tchooseR�tsignR`(R�R
R(R�R	R�R�R�R�Rtsidxtxidxtyidxtxidxp1R�tdy1tdy2tdy1dy2((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytstineman_interp3s2+

+cC s"tjtj||��\}|S(s�
    *points* is a sequence of *x*, *y* points.
    *verts* is a sequence of *x*, *y* vertices of a polygon.

    Return value is a sequence of indices into points for the points
    that are inside the polygon.
    (RR�tnxutilstpoints_inside_poly(tpointstvertsR�((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytinside_poly�scC s�tj|�stj|�r't}nt}|j|�}|j|�}t|�}t|�}||jd|�}|jd|�}|||*|||*|ddd�||)||fS(s,
    Given a sequence of *xs* and *ys*, return the vertices of a
    polygon that has a horizontal base at *xmin* and an upper bound at
    the *ys*.  *xmin* is a scalar.

    Intended for use with :meth:`matplotlib.axes.Axes.fill`, eg::

      xv, yv = poly_below(0, x, y)
      ax.fill(xv, yv)
    iNi����(R�t
isMaskedArrayRRRR6(RtxstystnxtNxR�R
R(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
poly_below�s	

cC s�tj|�s-tj|�s-tj|�r6t}nt}t|�}tj|�sm||j|�}ntj|�s�||j|�}n|j||ddd�f�}|j||ddd�f�}||fS(sC
    Given a sequence of *x*, *ylower* and *yupper*, return the polygon
    that fills the regions between them.  *ylower* or *yupper* can be
    scalar or iterable.  If they are iterable, they must be equal in
    length to *x*.

    Return value is *x*, *y* arrays for use with
    :meth:`matplotlib.axes.Axes.fill`.
    Ni����(R�R�RRR4R5R6R?(R
tylowertyupperR�R�R(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytpoly_between�s
-	""cC stj|d|dk�S(s�
    Tests whether first and last object in a sequence are the same.  These are
    presumably coordinates on a polygonal curve, in which case this function
    tests if that curve is closed.
    ii����(Rtall(Rk((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytis_closed_polygon�scC s�d}g}xdt|�D]V\}}|dkr@|r@|}q|dk	r|r|j||f�d}qqW|dk	r�|j||df�n|S(s�
    return a list of (ind0, ind1) such that mask[ind0:ind1].all() is
    True and we cover all such regions

    TODO: this is a pure python implementation which probably has a much faster numpy impl
    iN(RRSR*(R�t	in_regiont
boundariesRMRM((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcontiguous_regions�s	
cC s\tj|�}|}tj|d |k|d|k@�d}t|�rT|dS|SdS(s�
    return the indices into *x* where *x* crosses some threshold from
    below, eg the i's where::

      x[i-1]<threshold and x[i]>=threshold

    Example code::

        import matplotlib.pyplot as plt

        t = np.arange(0.0, 2.0, 0.1)
        s = np.sin(2*np.pi*t)

        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.plot(t, s, '-o')
        ax.axhline(0.5)
        ax.axhline(-0.5)

        ind = cross_from_below(s, 0.5)
        ax.vlines(t[ind], -1, 1)

        ind = cross_from_above(s, -0.5)
        ax.vlines(t[ind], -1, 1)

        plt.show()

    .. seealso::

        :func:`cross_from_above` and :func:`contiguous_regions`

    i����iiN(RRR�R(R
t	thresholdR ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcross_from_below�s!+cC sVtj|�}tj|d |k|d|k@�d}t|�rN|dS|SdS(s�
    return the indices into *x* where *x* crosses some threshold from
    below, eg the i's where::

      x[i-1]>threshold and x[i]<=threshold

    .. seealso::

        :func:`cross_from_below` and :func:`contiguous_regions`

    i����iiN(RRR�R(R
R�R ((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytcross_from_aboves
+cC s.tj|�}tj||d|�d|S(s�
    Finds the length of a set of vectors in *n* dimensions.  This is
    like the :func:`numpy.norm` function for vectors, but has the ability to
    work over a particular axis of the supplied array or matrix.

    Computes ``(sum((x_i)^P))^(1/P)`` for each ``{x_i}`` being the
    elements of *X* along the given axis.  If *axis* is *None*,
    compute over all elements of *X*.
    Rg�?(RRR=(RkR�R((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytvector_lengths.s
cC s%tj|dd�}t|dd�S(s�
    Computes the distance between a set of successive points in *N* dimensions.

    Where *X* is an *M* x *N* array or matrix.  The distances between
    successive rows is computed.  Distance is the standard Euclidean
    distance.
    Rii(RR�R�(Rk((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytdistances_along_curve;scC s1t|�}tjtjd�tj|�f�S(s�
    Computes the distance travelled along a polygonal curve in *N* dimensions.

    Where *X* is an *M* x *N* array or matrix.  Returns an array of
    length *M* consisting of the distance along the curve at each point
    (i.e., the rows of *X*).
    i(R�RR?R7tcumsum(Rk((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pytpath_lengthFsc
C sf|d|||d||}}|d|||d||}}	||||||	||fS(s
    Converts a quadratic Bezier curve to a cubic approximation.

    The inputs are the *x* and *y* coordinates of the three control
    points of a quadratic curve, and the output is a tuple of *x* and
    *y* coordinates of the four control points of the cubic curve.
    g@g@g�?gUUUUUU�?gUUUUUU�?gUUUUUU�?gUUUUUU�?((
tq0xtq0ytq1xtq1ytq2xtq2ytc1xtc1ytc2xtc2y((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt
quad2cubicQs	%%(�R6t
__future__RR*R�RSRuR�tnumpyRR�t
matplotlibRtmatplotlib.nxutilsR�tmatplotlib.cbookR4RR
RRRRRR!RR"RRTtinterpdtupdatetdedenttdedent_interpdRYRVR[R\RbRdR1R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RRR	RRRRR;RNR&RaRgRReRfRhRkRlRmRnRqRzR�R�R�R�R�R�R�R�R�R�R�R�R�R�RR<R=RARBRCRFRGRIRJRKRLRNtbool_R_R`RaRdRetobject_R�RORRRVR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((sB/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/mlab.pyt<module>�s<										`9
)(		�						%e*		G					a	3�		
			D	
					"			/	~7�
	







	s	Du	)	)]							'