
 m[c           @` s  d  d l  m Z m Z m Z m Z d  d l Z d  d l m Z m Z d  d l	 Z	 d  d l
 Z
 d  d l m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z d  d l m Z d  d l m Z m Z m Z m  Z  e j! r6d  d l" m# Z$ n d  d	 l" m$ Z$ e j% e&  Z' e j(   d
 k rtd Z) Z* n d  Z) d   Z+ d e, f d     YZ- e-   Z. d e j/ e	 j0  f d     YZ1 d e1 f d     YZ2 d e2 f d     YZ3 e. j4 d  d e2 f d     Y Z5 d e, f d     YZ6 e. j4 d  d e6 e2 f d     Y Z7 e. j4 d  d e6 e3 f d     Y Z8 d  e6 f d!     YZ9 e. j4 d"  d# e9 e7 f d$     Y Z: e. j4 d%  d& e9 e8 f d'     Y Z; d( e, f d)     YZ< e< j=   e. j4 d*  d+ e< e2 f d,     Y Z> e. j4 d-  d. e< e3 f d/     Y Z? d0   Z@ d1   ZA e. j4 d2  d3 e3 f d4     Y ZB d5 e, f d6     YZC d7 eC f d8     YZD d9 eD f d:     YZE d; eD f d<     YZF d S(=   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   xranget   zip(   t   BytesIO(   t   DISPLAY_TEMPLATEt   INCLUDED_FRAMESt
   JS_INCLUDE(   t
   subprocess(   t   cbookt   rcParamst   rcParamsDefaultt
   rc_context(   t   encodestring(   t   encodebytesu   Windowsi   c         C` sc   d   } t  |  | |  | | } t  | | |  | | } | | | |  | | | |  f S(   u#  Compute figure size so that pixels are a multiple of n

    Parameters
    ----------
    w, h : float
        Size in inches

    dpi : float
        The dpi

    n : int
        The target multiple

    Returns
    -------
    wnew, hnew : float
        The new figure size in inches.
    c         S` s   t  |  |  | d k r t  t j |  t j  |  | d k r[ t j |  t j  }  q t  t j |  t j  |  | d k r t j |  t j  }  q n  |  S(   Ni    (   t   intt   npt	   nextaftert   inf(   t   xt   dpit   n(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   correct_roundoff\   s    )*(   R   (   t   wt   hR   R   R   t   wnewt   hnew(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   adjusted_figsizeF   s    	t   MovieWriterRegistryc           B` sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   u<   Registry of available writer classes by human readable name.c         C` s%   t    |  _ t    |  _ t |  _ d  S(   N(   t   dictt   availt   _registeredt   Falset   _dirty(   t   self(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   __init__l   s    c         C` s   t  |  _ d S(   u$   Sets a flag to re-setup the writers.N(   t   TrueR#   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt	   set_dirtyq   s    c         ` s      f d   } | S(   u   Decorator for registering a class under a name.

        Example use::

            @registry.register(name)
            class Foo:
                pass
        c         ` s-   |   j    <|  j   r) |   j   <n  |  S(   N(   R!   t   isAvailableR    (   t   writerClass(   t   nameR$   (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   wrapper~   s    (    (   R$   R*   R+   (    (   R*   R$   s3   lib/python2.7/site-packages/matplotlib/animation.pyt   registeru   s    	c         C` s   |  j  r |  j   n  d S(   u2   If dirty, reasks the writers if they are availableN(   R#   t   reset_available_writers(   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   ensure_not_dirty   s    	c         C` sR   i  |  _  x9 |  j j   D]( \ } } | j   r | |  j  | <q q Wt |  _ d S(   u3   Reset the available state of all registered writersN(   R    R!   t   itemsR(   R"   R#   (   R$   R*   R)   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR-      s
    	c         C` s   |  j    t |  j  S(   u%   Get a list of available MovieWriters.(   R.   t   listR    (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR0      s    
c         C` s   |  j    | |  j k S(   u   Check if given writer is available by name.

        Parameters
        ----------
        name : str

        Returns
        -------
        available : bool
        (   R.   R    (   R$   R*   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   is_available   s    
c         C` s^   |  j    |  j s" t d   n  y |  j | SWn& t k
 rY t d j |    n Xd  S(   Nu   No MovieWriters available!u(   Requested MovieWriter ({}) not available(   R.   R    t   RuntimeErrort   KeyErrort   format(   R$   R*   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   __getitem__   s    
	(   t   __name__t
   __module__t   __doc__R%   R'   R,   R.   R-   R0   R1   R5   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR   j   s   							t   AbstractMovieWriterc           B` sY   e  Z d  Z e j d d   Z e j d    Z e j d    Z e	 j
 d    Z RS(   u  
    Abstract base class for writing movies. Fundamentally, what a MovieWriter
    does is provide is a way to grab frames by calling grab_frame().

    setup() is called to start the process and finish() is called afterwards.

    This class is set up to provide for writing movie frame data to a pipe.
    saving() is provided as a context manager to facilitate this process as::

        with moviewriter.saving(fig, outfile='myfile.mp4', dpi=100):
            # Iterate over frames
            moviewriter.grab_frame(**savefig_kwargs)

    The use of the context manager ensures that setup() and finish() are
    performed as necessary.

    An instance of a concrete subclass of this class can be given as the
    ``writer`` argument of `Animation.save()`.
    c         C` s   d S(   u  
        Perform setup for writing the movie file.

        Parameters
        ----------
        fig: `matplotlib.figure.Figure` instance
            The figure object that contains the information for frames
        outfile: string
            The filename of the resulting movie file
        dpi: int, optional
            The DPI (or resolution) for the file.  This controls the size
            in pixels of the resulting movie file. Default is ``fig.dpi``.
        N(    (   R$   t   figt   outfileR   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   setup   s    c         K` s   d S(   u   
        Grab the image information from the figure and save as a movie frame.

        All keyword arguments in savefig_kwargs are passed on to the `savefig`
        command that saves the figure.
        N(    (   R$   t   savefig_kwargs(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt
   grab_frame   s    c         C` s   d S(   u,   Finish any processing for writing the movie.N(    (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   finish   s    c         o` s4   |  j  | | | | |  z	 |  VWd |  j   Xd S(   u   
        Context manager to facilitate writing the movie file.

        ``*args, **kw`` are any parameters that should be passed to `setup`.
        N(   R<   R?   (   R$   R:   R;   R   t   argst   kwargs(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   saving   s    	N(   R6   R7   R8   t   abct   abstractmethodt   NoneR<   R>   R?   t
   contextlibt   contextmanagerRB   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR9      s   	t   MovieWriterc           B` s   e  Z d  Z d d d d d d  Z e d    Z d   Z d d  Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z e d    Z e d    Z e d    Z RS(   u  Base class for writing movies.

    This class is set up to provide for writing movie frame data to a pipe.
    See examples for how to use these classes.

    Attributes
    ----------
    frame_format : str
        The format used in writing frame data, defaults to 'rgba'
    fig : `~matplotlib.figure.Figure`
        The figure to capture data from.
        This must be provided by the sub-classes.

    i   c         C` s   | |  _  d |  _ | d k r. t d |  _ n	 | |  _ | d k rS t d |  _ n	 | |  _ | d k r t t |  j  |  _ n	 | |  _ | d k r t	   |  _
 n	 | |  _
 d S(   u  MovieWriter

        Parameters
        ----------
        fps: int
            Framerate for movie.
        codec: string or None, optional
            The codec to use. If ``None`` (the default) the ``animation.codec``
            rcParam is used.
        bitrate: int or None, optional
            The bitrate for the saved movie file, which is one way to control
            the output file size and quality. The default value is ``None``,
            which uses the ``animation.bitrate`` rcParam.  A value of -1
            implies that the bitrate should be determined automatically by the
            underlying utility.
        extra_args: list of strings or None, optional
            A list of extra string arguments to be passed to the underlying
            movie utility. The default is ``None``, which passes the additional
            arguments in the ``animation.extra_args`` rcParam.
        metadata: Dict[str, str] or None
            A dictionary of keys and values for metadata to include in the
            output file. Some keys that may be of use include:
            title, artist, genre, subject, copyright, srcform, comment.
        u   rgbau   animation.codecu   animation.bitrateN(   t   fpst   frame_formatRE   R   t   codect   bitrateR0   t   args_keyt
   extra_argsR   t   metadata(   R$   RI   RK   RL   RN   RO   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%     s    					c         C` s9   |  j  j   \ } } t | |  j  t | |  j  f S(   u7   A tuple ``(width, height)`` in pixels of a movie frame.(   R:   t   get_size_inchesR   R   (   R$   R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt
   frame_size5  s    c         C` s   |  j  d k r |  j j   \ } } t | | |  j d  \ } } | | f | | f k s |  j j | | d t t j d | | | |  q n |  j j   \ } } t j	 d |  j
  | | f S(   Nu   h264i   t   forwardu>   figure size (inches) has been adjusted from %s x %s to %s x %su   frame size in pixels is %s x %s(   RK   R:   RP   R   R   t   set_size_inchesR&   t   _logt   infot   debugRQ   (   R$   t   wot   hoR   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _adjust_frame_size;  s    	c         C` s\   | |  _  | |  _ | d k r- |  j j } n  | |  _ |  j   \ |  _ |  _ |  j   d S(   u  
        Perform setup for writing the movie file.

        Parameters
        ----------
        fig : matplotlib.figure.Figure
            The figure object that contains the information for frames
        outfile : string
            The filename of the resulting movie file
        dpi : int, optional
            The DPI (or resolution) for the file.  This controls the size
            in pixels of the resulting movie file. Default is fig.dpi.
        N(   R;   R:   RE   R   RY   t   _wt   _ht   _run(   R$   R:   R;   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR<   H  s    			c         C` s\   |  j    } t j } t j d |  t j | d t d | d | d t j d t |  _ d  S(   Nu$   MovieWriter.run: running command: %st   shellt   stdoutt   stderrt   stdint   creationflags(	   t   _argsR
   t   PIPERT   RU   t   PopenR"   t   subprocess_creation_flagst   _proc(   R$   t   commandt   output(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR\   a  s    		c         C` s   |  j    d S(   u,   Finish any processing for writing the movie.N(   t   cleanup(   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR?   m  s    c         K` s   t  j d  yH |  j j |  j |  j  |  j j |  j   d |  j d |  j	 | Wn` t
 t f k
 r } |  j j   \ } } t  j d | | f  t d j | | |    n Xd S(   u   
        Grab the image information from the figure and save as a movie frame.

        All keyword arguments in savefig_kwargs are passed on to the `savefig`
        command that saves the figure.
        u'   MovieWriter.grab_frame: Grabbing frame.R4   R   u(   MovieWriter -- Error running proc:
%s
%su}   Error saving animation to file (cause: {0}) Stdout: {1} StdError: {2}. It may help to re-run with logging level set to DEBUG.N(   RT   RV   R:   RS   RZ   R[   t   savefigt   _frame_sinkRJ   R   R2   t   IOErrorRf   t   communicateRU   R4   (   R$   R=   t   et   outt   err(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR>   q  s    		c         C` s
   |  j  j S(   u4   Returns the place to which frames should be written.(   Rf   R`   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRk     s    c         C` s
   t  d  S(   u9   Assemble list of utility-specific command-line arguments.u)   args needs to be implemented by subclass.(   t   NotImplementedError(   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRb     s    c         C` sI   |  j  j   \ } } |  j   j   t j d |  t j d |  d S(   u>   Clean-up and collect the process used to write the movie file.u!   MovieWriter -- Command stdout:
%su!   MovieWriter -- Command stderr:
%sN(   Rf   Rm   Rk   t   closeRT   RV   (   R$   Ro   Rp   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRi     s    c         C` s   t  t |  j  S(   u   
        Returns the binary path to the commandline tool used by a specific
        subclass. This is a class method so that the tool can be looked for
        before making a particular MovieWriter subclass available.
        (   t   strR   t   exec_key(   t   cls(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   bin_path  s    c      
   C` sm   |  j    } | s t Sy> t j | d t d t j d t j d t } |  j |  SWn t k
 rh t SXd S(   uw   
        Check to see if a MovieWriter subclass is actually available by
        running the commandline tool.
        R]   R^   R_   Ra   N(   Rv   R"   R
   Rd   Rc   Re   t   _handle_subprocesst   OSError(   Ru   Rv   t   p(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR(     s    			c         C` s   | j    t S(   N(   Rm   R&   (   Ru   t   process(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRw     s    
N(   R6   R7   R8   RE   R%   t   propertyRQ   RY   R<   R\   R?   R>   Rk   Rb   Ri   t   classmethodRv   R(   Rw   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRH      s   0								t   FileMovieWriterc           B` sw   e  Z d  Z d   Z d d e d  Z e d    Z e j	 d    Z d   Z
 d   Z d   Z d	   Z d
   Z RS(   ux   `MovieWriter` for writing to individual files and stitching at the end.

    This must be sub-classed to be useful.
    c         O` s$   t  j |  | |  t d |  _ d  S(   Nu   animation.frame_format(   RH   R%   R   RJ   (   R$   R@   RA   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%     s    u   _tmpc         C` st   | |  _  | |  _ | d k r- |  j  j } n  | |  _ |  j   | |  _ | |  _ d |  _ t   |  _	 d |  _
 d S(   u6  Perform setup for writing the movie file.

        Parameters
        ----------
        fig : matplotlib.figure.Figure
            The figure to grab the rendered frames from.
        outfile : str
            The filename of the resulting movie file.
        dpi : number, optional
            The dpi of the output file. This, with the figure size,
            controls the size in pixels of the resulting movie file.
            Default is fig.dpi.
        frame_prefix : str, optional
            The filename prefix to use for temporary files.  Defaults to
            ``'_tmp'``.
        clear_temp : bool, optional
            If the temporary files should be deleted after stitching
            the final result.  Setting this to ``False`` can be useful for
            debugging.  Defaults to ``True``.

        i    u
   %s%%07d.%sN(   R:   R;   RE   R   RY   t
   clear_tempt   temp_prefixt   _frame_counterR0   t   _temp_namest   fname_format_str(   R$   R:   R;   R   t   frame_prefixR~   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR<     s    			
			c         C` s   |  j  S(   u   
        Format (png, jpeg, etc.) to use for saving the frames, which can be
        decided by the individual subclasses.
        (   t   _frame_format(   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRJ     s    c         C` s/   | |  j  k r | |  _ n |  j  d |  _ d  S(   Ni    (   t   supported_formatsR   (   R$   RJ   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRJ     s    c         C` s   |  j  |  j |  j f S(   N(   R   R   RJ   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _base_temp_name  s    c         C` sU   |  j    |  j } |  j j |  t j d |  j |  |  j d 7_ t | d  S(   Nu7   FileMovieWriter.frame_sink: saving frame %d to fname=%si   u   wb(   R   R   R   t   appendRT   RV   t   open(   R$   t   fname(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRk     s    	c         K` s   t  j d  y> |  j   , } |  j j | d |  j d |  j | Wd QXWn@ t k
 r |  j j	   \ } } t  j
 d | | f    n Xd S(   u   
        Grab the image information from the figure and save as a movie frame.
        All keyword arguments in savefig_kwargs are passed on to the `savefig`
        command that saves the figure.
        u'   MovieWriter.grab_frame: Grabbing frame.R4   R   Nu(   MovieWriter -- Error running proc:
%s
%s(   RT   RV   Rk   R:   Rj   RJ   R   R2   Rf   Rm   RU   (   R$   R=   t   myframesinkRo   Rp   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR>     s    	c         C` s   |  j    t j |   |  j j r yn g  |  j j D] } | j   ^ q3 } g  |  j j D] } | j   ^ qX } t j	 d |  t j	 d |  Wn t
 k
 r } n Xt d j |  j j    n  d  S(   Nu   MovieWriter.finish: stdout: %su   MovieWriter.finish: stderr: %su%   Error creating movie, return code: {}(   R\   RH   R?   Rf   t
   returncodet   _stdout_bufft   decodet   _stderr_buffRT   RU   t	   ExceptionR2   R4   (   R$   t   sR^   R_   Rn   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR?   "  s    
%%	c         C` sQ   t  j |   |  j rM t j d |  j  x! |  j D] } t j |  q3 Wn  d  S(   Nu)   MovieWriter: clearing temporary fnames=%s(   RH   Ri   R~   RT   RV   R   t   ost   remove(   R$   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRi   5  s    		
N(   R6   R7   R8   R%   RE   R&   R<   R{   RJ   t   setterR   Rk   R>   R?   Ri   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR}     s   	#				u   pillowt   PillowWriterc           B` s>   e  Z e d     Z d   Z d d  Z d   Z d   Z RS(   c         C` s)   y d d  l  } Wn t k
 r$ t SXt S(   Ni    (   t   PILt   ImportErrorR"   R&   (   Ru   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR(   B  s
    c         O` s?   | j  d  d  k r" d | d <n  t t |   j | |   d  S(   Nu
   extra_args(    (   t   getRE   t   superR   R%   (   R$   R@   RA   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%   J  s    c         C` s(   g  |  _  | |  _ | |  _ | |  _ d  S(   N(   t   _framest   _outfilet   _dpit   _fig(   R$   R:   R;   R   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR<   O  s    			c         K` s   d d l  m } t   } |  j j | t | d d  |  j j j   } |  j j	 | j
 d t | j  t | j  f | j     d  S(   Ni    (   t   ImageR4   u   rgbau   RGBA(   R   R   R   R   Rj   R   t   canvast   get_rendererR   R   t	   frombytesR   t   widtht   heightt   getvalue(   R$   R=   R   t   buft   renderer(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR>   U  s    	c      
   C` sA   |  j  d j |  j d t d |  j  d d t d |  j  d  S(   Ni    t   save_allt   append_imagesi   t   durationi  (   R   t   saveR   R&   R   RI   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR?   a  s    N(	   R6   R7   R|   R(   R%   RE   R<   R>   R?   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR   @  s
   		t
   FFMpegBasec           B` s8   e  Z d  Z d Z d Z e d    Z e d    Z RS(   u   Mixin class for FFMpeg output.

    To be useful this must be multiply-inherited from with a
    `MovieWriterBase` sub-class.
    u   animation.ffmpeg_pathu   animation.ffmpeg_argsc         C` s   d |  j  g } |  j  d k rC d |  j k rC | j d d g  n  |  j d k ro | j d d |  j g  n  |  j r | j |  j  n  x= t j |  j  D]) \ } } | j d d	 | | f g  q W| d
 |  j g S(   Nu   -vcodecu   h264u   -pix_fmtu   yuv420pi    u   -bu   %dku	   -metadatau   %s=%su   -y(   RK   RN   t   extendRL   t   sixt	   iteritemsRO   R;   (   R$   R@   t   kt   v(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   output_argss  s    	!c         C` s,   | j    \ } } d | j   k r( t St S(   Nu   Libav(   Rm   R   R"   R&   (   Ru   Rz   t   _Rp   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRw     s    (	   R6   R7   R8   Rt   RM   R{   R   R|   Rw   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR   i  s
   u   ffmpegt   FFMpegWriterc           B` s   e  Z d  Z d   Z RS(   uw   Pipe-based ffmpeg writer.

    Frames are streamed directly to ffmpeg via a pipe and written in a single
    pass.
    c         C` s   |  j    d d d d d d |  j d |  j d t |  j  g } t j   t j k rh | d d	 g 7} n  | d
 d g |  j	 7} | S(   Nu   -fu   rawvideou   -vcodecu   -su   %dx%du   -pix_fmtu   -ru	   -loglevelu   quietu   -iu   pipe:(
   Rv   RQ   RJ   Rs   RI   RT   t   getEffectiveLevelt   loggingt   DEBUGR   (   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRb     s    (   R6   R7   R8   Rb   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   u   ffmpeg_filet   FFMpegFileWriterc        	   B` s8   e  Z d  Z d d d d d d d d d	 g	 Z d
   Z RS(   u}   File-based ffmpeg writer.

    Frames are written to temporary files on disk and then stitched
    together at the end.

    u   pngu   jpegu   ppmu   tiffu   sgiu   bmpu   pbmu   rawu   rgbac         C` s>   |  j    d t |  j  d |  j   d t |  j  g |  j S(   Nu   -ru   -iu   -vframes(   Rv   Rs   RI   R   R   R   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRb     s    (   R6   R7   R8   R   Rb   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   t
   AVConvBasec           B` s)   e  Z d  Z d Z d Z e d    Z RS(   u   Mixin class for avconv output.

    To be useful this must be multiply-inherited from with a
    `MovieWriterBase` sub-class.
    u   animation.avconv_pathu   animation.avconv_argsc         C` s   t  j |  S(   N(   RH   Rw   (   Ru   Rz   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRw     s    (   R6   R7   R8   Rt   RM   R|   Rw   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   u   avconvt   AVConvWriterc           B` s   e  Z d  Z RS(   uw   Pipe-based avconv writer.

    Frames are streamed directly to avconv via a pipe and written in a single
    pass.
    (   R6   R7   R8   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   u   avconv_filet   AVConvFileWriterc           B` s   e  Z d  Z RS(   u|   File-based avconv writer.

    Frames are written to temporary files on disk and then stitched
    together at the end.
    (   R6   R7   R8   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   t   ImageMagickBasec           B` sV   e  Z d  Z d Z d Z e d    Z e d    Z e d    Z	 e d    Z
 RS(   u   Mixin class for ImageMagick output.

    To be useful this must be multiply-inherited from with a
    `MovieWriterBase` sub-class.
    u   animation.convert_pathu   animation.convert_argsc         C` s   d |  j  S(   Ng      Y@(   RI   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   delay  s    c         C` s
   |  j  g S(   N(   R;   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s    c         C` s   t  j d k s" t |  j d k r& d  Sd d l m } x d | j | j f D]t } yT | j | j	 d d | j
 | B } | j | d  d } | j |  | d 7} PWqL t k
 r d } qL XqL W| t |  j <t |  j <d  S(	   Nu   win32u   converti    (   t   winregu   Software\Imagemagick\Currentu   BinPathu   \convert.exeu    (   t   syst   platformR   Rt   t	   six.movesR   t   KEY_WOW64_32KEYt   KEY_WOW64_64KEYt	   OpenKeyExt   HKEY_LOCAL_MACHINEt   KEY_QUERY_VALUEt   QueryValueExt   CloseKeyR   R   (   Ru   R   t   flagt   hkeyt   binpath(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _init_from_registry  s    "
c         C` s8   |  j    } | d k r% |  j   n  t t |   j   S(   u   
        Check to see if a ImageMagickWriter is actually available.

        Done by first checking the windows registry (if applicable) and then
        running the commandline tool.
        u   convert(   Rv   R   R   R   R(   (   Ru   Rv   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR(     s    (   R6   R7   R8   Rt   RM   R{   R   R   R|   R   R(   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   u   imagemagickt   ImageMagickWriterc           B` s   e  Z d  Z d   Z RS(   u|   Pipe-based animated gif.

    Frames are streamed directly to ImageMagick via a pipe and written
    in a single pass.

    c         C` sF   |  j    d d |  j d d d t |  j  d d d |  j g
 |  j S(	   Nu   -sizeu   %ix%iu   -depthu   8u   -delayu   -loopu   0u   %s:-(   Rv   RQ   Rs   R   RJ   R   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRb   #  s
    	(   R6   R7   R8   Rb   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   u   imagemagick_filet   ImageMagickFileWriterc        	   B` s8   e  Z d  Z d d d d d d d d d	 g	 Z d
   Z RS(   u   File-based animated gif writer.

    Frames are written to temporary files on disk and then stitched
    together at the end.

    u   pngu   jpegu   ppmu   tiffu   sgiu   bmpu   pbmu   rawu   rgbac         C` s<   |  j    d t |  j  d d d |  j |  j f g |  j S(   Nu   -delayu   -loopu   0u   %s*.%s(   Rv   Rs   R   R   RJ   R   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRb   ;  s    (   R6   R7   R8   R   Rb   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR   /  s   c         C` s2   t  j d t |   d t j j |  d  d |  S(   u(   frame_list should be a list of filenamest   Nframest	   frame_diri    RJ   (   R   R4   t   lenR   t   patht   dirname(   t
   frame_listRJ   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _included_framesC  s    c         ` s0   d  d d j     f d   t |   D  S(   u7   frame_list should be a list of base64-encoded png filesu,     frames[{0}] = "data:image/{1};base64,{2}"
u   
u    c         3` s6   |  ], \ } }  j  |   | j d  d   Vq d S(   u   
u   \
N(   R4   t   replace(   t   .0t   it
   frame_data(   RJ   t   template(    s3   lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>N  s   (   t   joint	   enumerate(   R   RJ   (    (   RJ   R   s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _embedded_framesJ  s    	u   htmlt
   HTMLWriterc        	   B` sn   e  Z d  d d d g Z d Z e d    Z d d d d d e d d d  Z d d	  Z	 d
   Z
 d   Z RS(   u   pngu   jpegu   tiffu   svgu   animation.html_argsc         C` s   t  S(   N(   R&   (   Ru   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR(   W  s    i   u   loopc	   	      C` s   | |  _  | j   |  _ | d  k r4 t d |  _ n	 | |  _ |  j d 9_ |  j d	 k rt d |  _ t j d  n  g  |  _ d |  _	 t
 |  _ t t |   j | | | | |  d  S(
   Nu   animation.embed_limiti   u   loopu   onceu   reflectu'   unrecognized default_mode: using 'loop'i    i   (   u   loopu   onceu   reflect(   t   embed_framest   lowert   default_modeRE   R   t   _bytes_limitRT   t   warningt   _saved_framest   _total_bytesR"   t
   _hit_limitR   R   R%   (	   R$   RI   RK   RL   RN   RO   R   R   t   embed_limit(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%   [  s    						c         C` s   t  j j |  \ } } | d k r3 t d   n  |  j s | d  k rU | d } n  t  j j |  sw t  j |  n  t  j j | d  } n d  } t	 t
 |   j | | | | d t d  S(   Nu   .htmlu   .htmu   outfile must be *.htm or *.htmlu   _framesu   frameR~   (   u   .htmlu   .htm(   R   R   t   splitextt
   ValueErrorR   RE   t   existst   makedirsR   R   R   R<   R"   (   R$   R:   R;   R   R   t   roott   extR   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR<   t  s    	c         K` s   |  j  r |  j r d  Sd |  j } t   } |  j j | d |  j d |  j | t | j    j	 d  } |  j
 t |  7_
 |  j
 |  j k r t j d |  j
 |  j  t |  _ q |  j j |  n t t |   j |   Sd  S(   Nu   .R4   R   u   asciiu   Animation size has reached %s bytes, exceeding the limit of %s. If you're sure you want a larger animation embedded, set the animation.embed_limit rc parameter to a larger value (in MB). This and further frames will be dropped.(   R   R   RJ   R   R:   Rj   R   R   R   R   R   R   R   RT   R   R&   R   R   R   R   R>   (   R$   R=   t   suffixt   ft	   imgdata64(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR>     s     			c         C` s   d t  f d     Y} |   |  _ |  j rC t |  j |  j  } n t |  j |  j  } t d d d d d d  } d | |  j	 d <d	 |  j
 } t |  j d
  T } | j t  | j t j d t j   j d t |  j  d | d | |   Wd  QXd  S(   Nt   ProcessStandinc           B` s   e  Z d  Z d   Z RS(   i    c         S` s   d S(   Nu    (   u    u    (    (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRm     s    (   R6   R7   R   Rm   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s   t   once_checkedu    t   loop_checkedt   reflect_checkedu   checkedu   _checkedi  u   wt   idR   t   fill_framest   interval(   t   objectRf   R   R   R   RJ   R   R   R   R   RI   R   R;   t   writeR	   R   R4   t   uuidt   uuid4t   hexR   (   R$   R   R   t	   mode_dictR   t   of(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR\     s&    				N(   R6   R7   R   RM   R|   R(   RE   R"   R%   R<   R>   R\   (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR   R  s   		t	   Animationc        
   B` s   e  Z d  Z d e d  Z d   Z d   Z d d d d d d d d d d 	 Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d e d d  Z d   Z RS(   u"  This class wraps the creation of an animation using matplotlib.

    It is only a base class which should be subclassed to provide
    needed behavior.

    This class is not typically used directly.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
       The figure object that is used to get draw, resize, and any
       other needed events.

    event_source : object, optional
       A class that can run a callback when desired events
       are generated, as well as be stopped and started.

       Examples include timers (see :class:`TimedAnimation`) and file
       system notifications.

    blit : bool, optional
       controls whether blitting is used to optimize drawing.  Defaults
       to ``False``.

    See Also
    --------
    FuncAnimation,  ArtistAnimation

    c         C` s   | |  _  | o | j j |  _ |  j   |  _ | |  _ | j j d |  j  |  _	 |  j  j j d |  j
  |  _ |  j r |  j   n  d  S(   Nu
   draw_eventu   close_event(   R   R   t   supports_blitt   _blitt   new_frame_seqt	   frame_seqt   event_sourcet   mpl_connectt   _startt   _first_draw_idt   _stopt	   _close_idt   _setup_blit(   R$   R:   R  t   blit(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%     s    			c         G` sM   |  j  j j |  j  d |  _ |  j   |  j j |  j  |  j j	   d S(   u   
        Starts interactive animation. Adds the draw frame command to the GUI
        handler, calls show to start the event loop.
        N(
   R   R   t   mpl_disconnectR  RE   t
   _init_drawR  t   add_callbackt   _stept   start(   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s
    	
c         G` sX   |  j  r" |  j j j |  j  n  |  j j j |  j  |  j j |  j  d  |  _ d  S(   N(
   R   R   R   R
  t
   _resize_idR  R  t   remove_callbackR  RE   (   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR  	  s
    	c         ` sf  | d k r t d } nG t | t j  r` t d   | | | | | f D  r` t d   n  |
 d k ru i  }
 n    j d k	 r   j j	 j
   j  t } n t } | d k r t   d  r d   j } n  | d k r t d } n  | d k r  j j } n  | d k r!t d } n  | d k r:t d	 } n    g } |	 d k	 ro| j   f d
   |	 D  n  t | t j  r| t j k rt | | | | d | d | } qt j d |  y0 t t j   d | | | d | d | } Wqt k
 rt d   qXn  t j d t |   d |
 k rWt j d  |
 j d  n  t    t d d k rt j d  d t d <n  | j   j | |   x | D] } | j   qWxm t g  | D] } | j   ^ q  D]F } x0 t | |  D] \ } } | j  | d t qW| j! |
   qWWd QXWd QX| rb  j j	 j" d   j#    _ n  d S(   u
  Saves a movie file by drawing every frame.

        Parameters
        ----------

        filename : str
            The output filename, e.g., :file:`mymovie.mp4`.

        writer : :class:`MovieWriter` or str, optional
            A `MovieWriter` instance to use or a key that identifies a
            class to use, such as 'ffmpeg'. If ``None``, defaults to
            :rc:`animation.writer`.

        fps : number, optional
           Frames per second in the movie. Defaults to ``None``, which will use
           the animation's specified interval to set the frames per second.

        dpi : number, optional
           Controls the dots per inch for the movie frames.  This combined with
           the figure's size in inches controls the size of the movie.  If
           ``None``, defaults to :rc:`savefig.dpi`.

        codec : str, optional
           The video codec to be used. Not all codecs are supported
           by a given :class:`MovieWriter`. If ``None``, default to
           :rc:`animation.codec`.

        bitrate : number, optional
           Specifies the number of bits used per second in the compressed
           movie, in kilobits per second. A higher number means a higher
           quality movie, but at the cost of increased file size. If ``None``,
           defaults to :rc:`animation.bitrate`.

        extra_args : list, optional
           List of extra string arguments to be passed to the underlying movie
           utility. If ``None``, defaults to :rc:`animation.extra_args`.

        metadata : Dict[str, str], optional
           Dictionary of keys and values for metadata to include in
           the output file. Some keys that may be of use include:
           title, artist, genre, subject, copyright, srcform, comment.

        extra_anim : list, optional
           Additional `Animation` objects that should be included
           in the saved movie file. These need to be from the same
           `matplotlib.figure.Figure` instance. Also, animation frames will
           just be simply combined, so there should be a 1:1 correspondence
           between the frames from the different animations.

        savefig_kwargs : dict, optional
           Is a dictionary containing keyword arguments to be passed
           on to the `savefig` command which is called repeatedly to
           save the individual frames.

        Notes
        -----
        fps, codec, bitrate, extra_args, metadata are used to
        construct a :class:`MovieWriter` instance and can only be
        passed if `writer` is a string.  If they are passed as
        non-`None` and ``writer`` is a :class:`MovieWriter`, a
        `RuntimeError` will be raised.

        u   animation.writerc         s` s   |  ] } | d  k	 Vq d  S(   N(   RE   (   R   t   arg(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>X  s   u   Passing in values for arguments fps, codec, bitrate, extra_args, or metadata is not supported when writer is an existing MovieWriter instance. These should instead be passed as arguments when creating the MovieWriter instance.u	   _intervalg     @@u   savefig.dpiu   figureu   animation.codecu   animation.bitratec         3` s'   |  ] } | j    j  k r | Vq d  S(   N(   R   (   R   t   anim(   R$   (    s3   lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>~  s   RN   RO   u   MovieWriter %s unavailable.i    uZ   Cannot save animation: no writers are available. Please install ffmpeg to save animations.u   Animation.save using %su   bbox_inchesu   Warning: discarding the 'bbox_inches' argument in 'savefig_kwargs' as it may cause frame size to vary, which is inappropriate for animation.u   savefig.bboxu   tightuk   Disabling savefig.bbox = 'tight', as it may cause frame size to vary, which is inappropriate for animation.R	  Nu
   draw_event($   RE   R   t
   isinstanceR   t   string_typest   anyR2   R  R   R   R
  R&   R"   t   hasattrt	   _intervalR   R   t   writersR    RT   R   R0   t
   IndexErrorR   RU   t   typet   popR   RB   R  R   t   new_saved_frame_seqt   _draw_next_frameR>   R  R  (   R$   t   filenamet   writerRI   R   RK   RL   RN   RO   t
   extra_animR=   t   reconnect_first_drawt   all_animR  t   at   datat   d(    (   R$   s3   lib/python2.7/site-packages/matplotlib/animation.pyR     sp    D				
,c         G` sC   y* t  |  j  } |  j | |  j  t SWn t k
 r> t SXd S(   u   
        Handler for getting events. By default, gets the next frame in the
        sequence and hands the data off to be drawn.
        N(   t   nextR  R  R   R&   t   StopIterationR"   (   R$   R@   t	   framedata(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    c         C` s   t  |  j  S(   u,   Creates a new sequence of frame information.(   t   itert
   _framedata(   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s    c         C` s
   |  j    S(   u9   Creates a new sequence of saved/cached frame information.(   R   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    c         C` s1   |  j  | |  |  j |  |  j | |  d  S(   N(   t	   _pre_drawt   _draw_framet
   _post_draw(   R$   R(  R	  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    c         C` s   d  S(   N(    (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    c         C` s#   | r |  j  |  j |  j  n  d  S(   N(   t   _blit_cleart   _drawn_artistst   _blit_cache(   R$   R(  R	  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR+    s    c         C` s   t  d   d  S(   NuD   Needs to be implemented by subclasses to actually make an animation.(   Rq   (   R$   R(  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR,    s    c         C` s<   | r( |  j  r( |  j |  j  |  j  n |  j j j   d  S(   N(   R/  t
   _blit_drawR0  R   R   t	   draw_idle(   R$   R(  R	  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR-    s    c         C` s   g  } xb | D]Z } | j  | k rG | j j j | j  j  | | j  <n  | j  j |  | j | j   q Wx* t |  D] } | j j j | j  qx Wd  S(   N(	   t   axest   figureR   t   copy_from_bboxt   bboxt   draw_artistR   t   setR	  (   R$   t   artistst   bg_cachet
   updated_axR#  t   ax(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR1    s    %c         C` sQ   t  d   | D  } x4 | D], } | | k r | j j j | |  q q Wd  S(   Nc         s` s   |  ] } | j  Vq d  S(   N(   R3  (   R   R#  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pys	   <genexpr>  s    (   R8  R4  R   t   restore_region(   R$   R9  R:  R3  R#  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR.    s    c         C` sJ   t    |  _ g  |  _ |  j j j d |  j  |  _ |  j d  |  j
  d  S(   Nu   resize_event(   R   R0  R/  R   R   R  t   _handle_resizeR  R-  RE   R   (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s
    	c         G` s\   |  j  j j |  j  |  j j   |  j j   |  j   |  j  j j	 d |  j
  |  _ d  S(   Nu
   draw_event(   R   R   R
  R  R  t   stopR0  t   clearR  R  t   _end_redraw(   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR>    s    
c         C` sU   |  j  d  t  |  j j   |  j j j |  j  |  j j j	 d |  j
  |  _ d  S(   Nu   resize_event(   R-  RE   R"   R  R  R   R   R
  R  R  R>  (   R$   t   evt(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRA     s
    c   
      C` s  d } t  |  d  s8| d k r. t d } n  | d 9} t j d d d t  Q } t t d } | d	 d
 d t d d d |  j  } |  j | j	 d | Wd QXt
 | j	 d  n } t | j    } t |  } | | k r t j d | |  n' | j d  |  _ d j | j   |  _ Wd QXt j | j	  n  t  |  d  rd d g }	 t  |  d  r{|  j r{|	 j d  n  | j d |  j d |  j d d j |	   Sd Sd S(   u|  Returns animation as an HTML5 video tag.

        This saves the animation as an h264 video, encoded in base64
        directly into the HTML5 video tag. This respects the rc parameters
        for the writer as well as the bitrate. This also makes use of the
        ``interval`` to control the speed, and uses the ``repeat``
        parameter to decide whether to loop.
        u   <video {size} {options}>
  <source type="video/mp4" src="data:video/mp4;base64,{video}">
  Your browser does not support the video tag.
</video>u   _base64_videou   animation.embed_limiti   R   u   .m4vt   deleteu   animation.writerRK   u   h264RL   u   animation.bitrateRI   g     @@R  Nu   rbu   Animation movie is %s bytes, exceeding the limit of %s. If you're sure you want a large animation embedded, set the animation.embed_limit rc parameter to a larger value (in MB).u   asciiu   width="{}" height="{}"u   controlsu   autoplayu   repeatu   loopt   videot   sizet   optionsu    u   Video too large to embed.i   (   R  RE   R   t   tempfilet   NamedTemporaryFileR"   R  R  R   R*   R   R   t   readR   RT   R   R   t   _base64_videoR4   RQ   t   _video_sizeR   R   t   repeatR   R   (
   R$   R   t	   VIDEO_TAGR   t   WriterR  RD  t   vid64t   vid_lenRF  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   to_html5_video)  s>    

	c         C` s   | d k r+ t |  d  r+ d |  j } n  | d k rO |  j rF d n d } n  t |  d  re |  j St j d d d t  2 } |  j | j	 d	 t
 d
 | d | d |  Wd QXt | j	   } | j   } Wd QXt j | j	  | |  _ | Sd S(   u-   Generate HTML representation of the animationu	   _intervali  u   loopu   onceu   _html_representationR   u   .htmlRC  R  RI   R   R   N(   RE   R  R  RL  t   _html_representationRG  RH  R"   R   R*   R   R   RI  R   R   (   R$   RI   R   R   R   t   fobjt   html(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt	   to_jshtmll  s     	c         C` s:   t  d } | d k r  |  j   S| d k r6 |  j   Sd S(   u#   IPython display hook for rendering.u   animation.htmlu   html5u   jshtmlN(   R   RQ  RU  (   R$   t   fmt(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   _repr_html_  s
    

N(   R6   R7   R8   RE   R"   R%   R  R  R   R  R   R  R  R  R+  R,  R-  R1  R.  R  R>  RA  RQ  R&   RU  RW  (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s.   										
								Ct   TimedAnimationc           B` s>   e  Z d  Z d d e d d  Z d   Z d   Z d   Z RS(   u1  :class:`Animation` subclass for time-based animation.

    A new frame is drawn every *interval* milliseconds.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
       The figure object that is used to get draw, resize, and any
       other needed events.

    interval : number, optional
       Delay between frames in milliseconds.  Defaults to 200.

    repeat_delay : number, optional
        If the animation in repeated, adds a delay in milliseconds
        before repeating the animation.  Defaults to ``None``.

    repeat : bool, optional
        Controls whether the animation should repeat when the sequence
        of frames is completed.  Defaults to ``True``.

    blit : bool, optional
        Controls whether blitting is used to optimize drawing.  Defaults
        to ``False``.

    i   c         O` se   | |  _  | |  _ | |  _ | d  k rE | j j   } |  j  | _ n  t j |  | d | | | d  S(   NR  (	   R  t   _repeat_delayRL  RE   R   t	   new_timerR   R   R%   (   R$   R:   R   t   repeat_delayRL  R  R@   RA   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%     s    			c         G` s   t  j |  |  } | r |  j r |  j   |  j   |  _ |  j r} |  j j |  j  |  j j	 |  j
  |  j |  j _ t St  j |  |  Sn | Sd S(   u-   
        Handler for getting events.
        N(   R   R  RL  R  R   R  RY  R  R  R  t   _loop_delayR   R&   (   R$   R@   t   still_going(    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    

	c         G` s$   |  j  j |  j  t j |   d  S(   N(   R  R  R\  R   R  (   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    c         G` sF   |  j  j |  j  |  j |  j  _ |  j  j |  j  t j |   d  S(   N(   R  R  R\  R  R   R  R  R   (   R$   R@   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR\    s    N(	   R6   R7   R8   RE   R&   R%   R  R  R\  (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRX    s   			t   ArtistAnimationc           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   u  Animation using a fixed set of `Artist` objects.

    Before creating an instance, all plotting should have taken place
    and the relevant artists saved.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
       The figure object that is used to get draw, resize, and any
       other needed events.

    artists : list
        Each list entry a collection of artists that represent what
        needs to be enabled on each frame. These will be disabled for
        other frames.

    interval : number, optional
       Delay between frames in milliseconds.  Defaults to 200.

    repeat_delay : number, optional
        If the animation in repeated, adds a delay in milliseconds
        before repeating the animation.  Defaults to ``None``.

    repeat : bool, optional
        Controls whether the animation should repeat when the sequence
        of frames is completed. Defaults to ``True``.

    blit : bool, optional
        Controls whether blitting is used to optimize drawing.  Defaults
        to ``False``.

    c         O` s,   g  |  _  | |  _ t j |  | | |  d  S(   N(   R/  R*  RX  R%   (   R$   R:   R9  R@   RA   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR%     s    		c         C` s   t    } xj |  j   D]\ } xS | D]K } | j t  | j |  j  | j   | k r# | j | j    q# q# Wq Wx | D] } | j j	   q} Wd  S(   N(
   R8  R   t   set_visibleR"   t   set_animatedR   t
   get_figuret   addR   R2  (   R$   t   figsR   t   artistR:   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    	c         C` sD   | r |  j  |  j |  j  n! x |  j D] } | j t  q) Wd S(   u5   
        Clears artists from the last frame.
        N(   R.  R/  R0  R_  R"   (   R$   R(  R	  Rd  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR+    s    c         C` s+   | |  _  x | D] } | j t  q Wd  S(   N(   R/  R_  R&   (   R$   R9  Rd  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR,  +  s    	(   R6   R7   R8   R%   R  R+  R,  (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR^    s
    				t   FuncAnimationc           B` sG   e  Z d  Z d d d d d  Z d   Z d   Z d   Z d   Z RS(   uH	  
    Makes an animation by repeatedly calling a function ``func``.

    Parameters
    ----------
    fig : matplotlib.figure.Figure
       The figure object that is used to get draw, resize, and any
       other needed events.

    func : callable
       The function to call at each frame.  The first argument will
       be the next value in ``frames``.   Any additional positional
       arguments can be supplied via the ``fargs`` parameter.

       The required signature is::

          def func(frame, *fargs) -> iterable_of_artists:

    frames : iterable, int, generator function, or None, optional
        Source of data to pass ``func`` and each frame of the animation

        If an iterable, then simply use the values provided.  If the
        iterable has a length, it will override the ``save_count`` kwarg.

        If an integer, then equivalent to passing ``range(frames)``

        If a generator function, then must have the signature::

           def gen_function() -> obj:

        If ``None``, then equivalent to passing ``itertools.count``.

        In all of these cases, the values in *frames* is simply passed through
        to the user-supplied *func* and thus can be of any type.

    init_func : callable, optional
       A function used to draw a clear frame. If not given, the
       results of drawing from the first item in the frames sequence
       will be used. This function will be called once before the
       first frame.

       If ``blit == True``, ``init_func`` must return an iterable of artists
       to be re-drawn.

       The required signature is::

          def init_func() -> iterable_of_artists:

    fargs : tuple or None, optional
       Additional arguments to pass to each call to *func*.

    save_count : int, optional
       The number of values from *frames* to cache.

    interval : number, optional
       Delay between frames in milliseconds.  Defaults to 200.

    repeat_delay : number, optional
       If the animation in repeated, adds a delay in milliseconds
       before repeating the animation.  Defaults to ``None``.

    repeat : bool, optional
       Controls whether the animation should repeat when the sequence
       of frames is completed.  Defaults to ``True``.

    blit : bool, optional
       Controls whether blitting is used to optimize drawing.  Defaults
       to ``False``.

    c         ` s  | r | |  _  n	 d |  _  | |  _ | |  _   d  k rH t j |  _ nx t    r`   |  _ n` t j	    r   f d   |  _ t
   d  r t    |  _ q n   f d   |  _   |  _ |  j d  k r d |  _ n t |  j  |  _ | |  _ g  |  _ t j |  | |  g  |  _ d  S(   Nc           ` s
   t     S(   N(   R)  (    (   t   frames(    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   <lambda>  s    u   __len__c           ` s   t  t     S(   N(   R)  R   (    (   Rf  (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRg    s    id   (    (   Rb   t   _funct
   save_countRE   t	   itertoolst   countt	   _iter_gent   callableR   t   iterableR  R   R   t
   _init_funct	   _save_seqRX  R%   (   R$   R:   t   funcRf  t	   init_funct   fargsRi  RA   (    (   Rf  s3   lib/python2.7/site-packages/matplotlib/animation.pyR%   |  s,    						c         C` s
   |  j    S(   N(   Rl  (   R$   (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR     s    c         ` sv   |  j  r( t |  j   |  _ t |  j  S|  j d  k	 rP t j |  j   |  j  S|  j       f d   } |   Sd  S(   Nc          3` sN   y& x t  d  D] }  t    Vq WWn t k
 r9 n Xt j d d  d  S(   Nid   u   2.2u   FuncAnimation.save has truncated your animation to 100 frames.  In the future, no such truncation will occur; please pass 'save_count' accordingly.(   t   rangeR&  R'  R   t   warn_deprecated(   R   (   R  (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   gen  s    (	   Rp  R0   t   _old_saved_seqR)  Ri  RE   Rj  t   isliceR   (   R$   Rv  (    (   R  s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    	c         C` s   |  j  d  k r+ |  j t |  j     n] |  j    |  _ |  j r |  j d  k ra t d   n  x$ |  j D] } | j |  j  qk Wn  g  |  _	 d  S(   Nu7   The init_func must return a sequence of Artist objects.(
   Ro  RE   R,  R&  R   R/  R   R2   R`  Rp  (   R$   R#  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR    s    	c         C` s   |  j  j |  |  j  |  j |  _  |  j | |  j  |  _ |  j r |  j d  k rc t d   n  x$ |  j D] } | j	 |  j  qm Wn  d  S(   Nu@   The animation function must return a sequence of Artist objects.(
   Rp  R   Ri  Rh  Rb   R/  R   RE   R2   R`  (   R$   R(  R#  (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyR,    s    	N(	   R6   R7   R8   RE   R%   R   R  R  R,  (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyRe  5  s   F	0			(G   t
   __future__R    R   R   R   R   R   R   R   RC   RF   t   ioR   Rj  R   R   R   R   RG  R   t   numpyR   t   matplotlib._animation_dataR   R   R	   t   matplotlib.compatR
   t
   matplotlibR   R   R   R   t   PY2t   base64R   R   t	   getLoggerR6   RT   t   systemRe   t   CREATE_NO_WINDOWR   R   R   R  t   with_metaclasst   ABCMetaR9   RH   R}   R,   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   RX  R^  Re  (    (    (    s3   lib/python2.7/site-packages/matplotlib/animation.pyt   <module>   sp   ""		$F	"A()		1
		n RO