§
    nŸr]]f  ã                   óš  — d Z ddlZddlZddlZddlZ	 ddlmZ n# e$ r	 ddlmZ Y nw xY wddlZddl	m
Z
mZmZ  G d„ d¦  «        Z G d„ d¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Ze
j        j        r%ddlZ G d„ dej        ¦  «        Z G d„ de¦  «        Zd„ Zd„ Zddedfd„ZdS )a  PlotItems.py -- Objects that can be plotted by Gnuplot.

This module contains several types of PlotItems.  PlotItems can be
plotted by passing them to a Gnuplot.Gnuplot object.  You can derive
your own classes from the PlotItem hierarchy to customize their
behavior.

é    N)ÚStringIO)ÚgpÚutilsÚErrorsc                   ó   — e Zd ZdZdS )Ú_unsetz*Used to represent unset keyword arguments.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú3/usr/lib/python3/dist-packages/Gnuplot/PlotItems.pyr   r      s   € € € € € Ø4Ð4à€Dr   r   c                   óx   — e Zd ZdZd„ d„ d„ dœZed         ed<   g d¢Zd	„ Zd
„ Zd„ Zd„ Z	d„ Z
d„ Zd„ Zd„ Zd„ ZdS )ÚPlotItemai  Plotitem represents an item that can be plotted by gnuplot.

    For the finest control over the output, you can create 'PlotItems'
    yourself with additional keyword options, or derive new classes
    from 'PlotItem'.

    The handling of options is complicated by the attempt to allow
    options and their setting mechanism to be inherited conveniently.
    Note first that there are some options that can only be set in the
    constructor then never modified, and others that can be set in the
    constructor and/or modified using the 'set_option()' member
    function.  The former are always processed within '__init__'.  The
    latter are always processed within 'set_option', which is called
    by the constructor.

    'set_option' is driven by a class-wide dictionary called
    '_option_list', which is a mapping '{ <option> : <setter> }' from
    option name to the function object used to set or change the
    option.  <setter> is a function object that takes two parameters:
    'self' (the 'PlotItem' instance) and the new value requested for
    the option.  If <setter> is 'None', then the option is not allowed
    to be changed after construction and an exception is raised.

    Any 'PlotItem' that needs to add options can add to this
    dictionary within its class definition.  Follow one of the
    examples in this file.  Alternatively it could override the
    'set_option' member function if it needs to do wilder things.

    Members:

      '_basecommand' -- a string holding the elementary argument that
          must be passed to gnuplot's `plot' command for this item;
          e.g., 'sin(x)' or '"filename.dat"'.

      '_options' -- a dictionary of (<option>,<string>) tuples
          corresponding to the plot options that have been set for
          this instance of the PlotItem.  <option> is the option as
          specified by the user; <string> is the string that needs to
          be set in the command line to set that option (or None if no
          string is needed).  Example::

              {'title' : ('Data', 'title "Data"'),
               'with' : ('linespoints', 'with linespoints')}

    c                 ó2   — |                       d|d d¦  «        S )NÚaxeszaxes %s©Úset_string_option)Úselfr   s     r   ú<lambda>zPlotItem.<lambda>T   s   €  D×$:Ò$:Ø�D˜$ 	ñ%+ô %+€ r   c                 ó2   — |                       d|d d¦  «        S )NÚwithzwith %sr   )r   Úwith_s     r   r   zPlotItem.<lambda>V   s   €  T×%;Ò%;Ø�E˜4 ñ&,ô &,€ r   c                 ó2   — |                       d|dd¦  «        S )NÚtitleÚnotitlez
title "%s"r   )r   r   s     r   r   zPlotItem.<lambda>X   s   €  d×&<Ò&<Ø�U˜I |ñ'5ô '5€ r   )r   r   r   r   r   )	ÚbinaryÚindexÚeveryÚthruÚusingÚsmoothr   r   r   c                 ó.   — i | _          | j        di |¤Ž dS )a  Construct a 'PlotItem'.

        Keyword options:

          'with_=<string>' -- choose how item will be plotted, e.g.,
              with_='points 3 3'.

          'title=<string>' -- set the title to be associated with the item
              in the plot legend.

          'title=None' -- choose 'notitle' option (omit item from legend).

        Note that omitting the title option is different than setting
        'title=None'; the former chooses gnuplot's default whereas the
        latter chooses 'notitle'.

        Nr   )Ú_optionsÚ
set_option)r   Úkeyws     r   Ú__init__zPlotItem.__init__d   s)   € ð& ˆŒØˆŒÐÐ˜$ÐÐÐÐÐr   c                 óX   — 	 | j         |         d         S #  t          d|z  ¦  «        ‚xY w)z4Return the setting of an option.  May be overridden.r   zoption %s is not set!©r%   ÚKeyError©r   Únames     r   Ú
get_optionzPlotItem.get_optionz   s6   € ð	;Ø”= Ô& qÔ)Ð)øð	;ÝÐ2°TÑ9Ñ:Ô:Ð:øøøs   ‚ •)c                 ó  — t          |                     ¦   «         ¦  «        D ]^\  }}	 | j        |         }n'# t          $ r t	          j        |›d|›�¦  «        ‚w xY w|€t	          j        d|¦  «        ‚ || |¦  «         Œ_dS )a®  Set or change a plot option for this PlotItem.

        See documentation for '__init__' for information about allowed
        options.  This function can be overridden by derived classes
        to allow additional options, in which case those options will
        also be allowed by '__init__' for the derived class.  However,
        it is easier to define a new '_option_list' variable for the
        derived class.

        ú=Nz+Cannot modify %s option after construction!)ÚlistÚitemsÚ_option_listr+   r   ÚOptionError)r   r'   ÚoptionÚvalueÚsetters        r   r&   zPlotItem.set_option‚   sº   € õ  $ D§J¢J¡L¤LÑ1Ô1ð 		$ð 		$‰OˆV�UðCØÔ*¨6Ô2��øÝð Cð Cð CÝÔ(°F°F°F¸5¸5Ð)AÑBÔBÐBðCøøøàˆ~ÝÔ(ØAÀ6ñKô Kð Kð ��t˜UÑ#Ô#Ð#Ð#ð		$ð 		$s	   ¨6¶$Ac                 ó¦   — |€||f| j         |<   dS t          |¦  «        t          u r|||z  f| j         |<   dS t          j        |›d|›�¦  «         dS )z(Set an option that takes a string value.Nr0   )r%   ÚtypeÚbytesr   r4   )r   r5   r6   ÚdefaultÚfmts        r   r   zPlotItem.set_string_option™   sn   € ð ˆ=Ø%*¨GÐ$4ˆDŒM˜&Ñ!Ð!Ð!Ý�%‰[Œ[�EÐ!Ð!Ø%*¨C°%©KÐ$8ˆDŒM˜&Ñ!Ð!Ð!åÔ¨&¨&¨&°%°%Ð9Ñ:Ô:Ð:Ð:Ð:r   c                 ó:   — 	 | j         |= dS # t          $ r Y dS w xY w)z=Clear (unset) a plot option.  No error if option was not set.Nr*   r,   s     r   Úclear_optionzPlotItem.clear_option£   s9   € ð	Ø”˜dÐ#Ð#Ð#øÝð 	ð 	ð 	ØˆDˆDð	øøøs   ‚ Œ
™c                 ó   — t          ¦   «         ‚©N)ÚNotImplementedError©r   s    r   Úget_base_command_stringz PlotItem.get_base_command_string«   s   € Ý!Ñ#Ô#Ð#r   c                 ó®   — g }| j         D ]7}| j                             |d¦  «        \  }}|�|                     |¦  «         Œ8d                     |¦  «        S )N)NNú )Ú_option_sequencer%   ÚgetÚappendÚjoin)r   ÚcmdÚoptÚvalÚstrs        r   Úget_command_option_stringz"PlotItem.get_command_option_string®   sY   € ØˆØÔ(ð 	 ð 	 ˆCØœ×)Ò)¨#¨{Ñ;Ô;‰IˆS�ØˆØ—
’
˜3‘”�øØ�xŠx˜‰}Œ}Ðr   c                 óx   — d                      |                      ¦   «         |                      ¦   «         g¦  «        S )zìBuild the plot command to be sent to gnuplot.

        Build and return the plot command, with options, necessary to
        display this item.  If anything else needs to be done once per
        plot, it can be done here too.

        rE   )rI   rC   rN   rB   s    r   ÚcommandzPlotItem.command¶   s=   € ð �xŠxØ×(Ò(Ñ*Ô*Ø×*Ò*Ñ,Ô,ðñ ô ð 	r   c                 ó   — dS )záPipe necessary inline data to gnuplot.

        If the plot command requires data to be put on stdin (i.e.,
        'plot "-"'), this method should put that data there.  Can be
        overridden in derived classes.

        Nr   ©r   Úfs     r   ÚpipeinzPlotItem.pipeinÄ   s	   € ð 	ˆr   N)r	   r
   r   r   r3   rF   r(   r.   r&   r   r>   rC   rN   rP   rT   r   r   r   r   r   #   só   € € € € € ð,ð ,ð`+ð +ð,ð ,ð5ð 5ð
ð 
€Lð )¨Ô0€L�Ñð
ð 
ð 
Ðð ð  ð  ð,;ð ;ð ;ð$ð $ð $ð.;ð ;ð ;ðð ð ð$ð $ð $ðð ð ðð ð ð	ð 	ð 	ð 	ð 	r   r   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚFunca  Represents a mathematical expression to plot.

    Func represents a mathematical expression that is to be computed by
    gnuplot itself, as if you would type for example::

        gnuplot> plot sin(x)

    into gnuplot itself.  The argument to the contructor is a string
    that should be a mathematical expression.  Example::

        g.plot(Func('sin(x)', with_='line 3'))

    As shorthand, a string passed to the plot method of a Gnuplot
    object is also treated as a Func::

        g.plot('sin(x)')

    c                 ó8   — t          j        | fi |¤Ž || _        d S r@   )r   r(   Úfunction)r   rX   r'   s      r   r(   zFunc.__init__ä   s&   € ÝÔ˜$Ð'Ð' $Ð'Ð'Ð'Ø ˆŒˆˆr   c                 ó   — | j         S r@   )rX   rB   s    r   rC   zFunc.get_base_command_stringè   s
   € ØŒ}Ðr   N©r	   r
   r   r   r(   rC   r   r   r   rV   rV   Ð   s<   € € € € € ðð ð&!ð !ð !ðð ð ð ð r   rV   c                   óœ   — e Zd ZdZej                             ¦   «         Ze                     d„ d„ d„ d„ d„ dœ¦  «         d„ Zd	„ Z	d
„ Z
d„ ZdS )Ú	_FileItemz£A PlotItem representing a file that contains gnuplot data.

    This class is not meant for users but rather as a base class for
    other types of FileItem.

    c                 ó,   — |                       |¦  «        S r@   )Úset_option_binary©r   r   s     r   r   z_FileItem.<lambda>ö   s   € ¨×(>Ò(>¸vÑ(FÔ(F€ r   c                 ó.   — |                       d|¦  «        S )Nr   ©Úset_option_colonsep©r   r6   s     r   r   z_FileItem.<lambda>÷   ó   €  d×&>Ò&>¸wÈÑ&NÔ&N€ r   c                 ó.   — |                       d|¦  «        S )Nr    ra   rc   s     r   r   z_FileItem.<lambda>ø   rd   r   c                 ó.   — |                       d|¦  «        S )Nr"   ra   rc   s     r   r   z_FileItem.<lambda>ù   rd   r   c                 ó2   — |                       d|d d¦  «        S )Nr#   z	smooth %sr   )r   r#   s     r   r   z_FileItem.<lambda>ú   s   € ¨×(>Ò(>Ø�f˜d Kñ)ô )€ r   )r   r   r    r"   r#   c                 ó8   — || _         t          j        | fi |¤Ž dS )aÈ  Represent a PlotItem that gnuplot treates as a file.

        This class holds the information that is needed to construct
        the plot command line, including options that are specific to
        file-like gnuplot input.

        <filename> is a string representing the filename to be passed
        to gnuplot within quotes.  It may be the name of an existing
        file, '-' for inline data, or the name of a named pipe.

        Keyword arguments:

            'using=<int>' -- plot that column against line number

            'using=<tuple>' -- plot using a:b:c:d etc.  Elements in
                the tuple that are None are output as the empty
                string.

            'using=<string>' -- plot `using <string>' (allows gnuplot's
                arbitrary column arithmetic)

            'every=<value>' -- plot 'every <value>'.  <value> is
                formatted as for 'using' option.

            'index=<value>' -- plot 'index <value>'.  <value> is
                formatted as for 'using' option.

            'binary=<boolean>' -- data in the file is in binary format
                (this option is only allowed for grid data for splot).

            'smooth=<string>' -- smooth the data.  Option should be
                'unique', 'csplines', 'acsplines', 'bezier', or
                'sbezier'.

        The keyword arguments recognized by 'PlotItem' can also be
        used here.

        Note that the 'using' option is interpreted by gnuplot, so
        columns must be numbered starting with 1.

        By default, gnuplot uses the name of the file plus any 'using'
        option as the dataset title.  If you want another title, set
        it explicitly using the 'title' option.

        N)Úfilenamer   r(   )r   ri   r'   s      r   r(   z_FileItem.__init__ÿ   s+   € ð^ !ˆŒåÔ˜$Ð'Ð' $Ð'Ð'Ð'Ð'Ð'r   c                 ó4   — t          j        | j        ¦  «        S r@   )r   Údouble_quote_stringri   rB   s    r   rC   z!_FileItem.get_base_command_string2  s   € ÝÔ% d¤mÑ4Ô4Ð4r   c                 óÀ  — |€|                       |¦  «         d S t          |¦  «        t          t          fv r||›d|›�f| j        |<   d S t          |¦  «        t
          u rgg }|D ]<}|€|                     d¦  «         Œ|                     t          |¦  «        ¦  «         Œ=||›dd                     |¦  «        ›�f| j        |<   d S t          j
        |›d|›�¦  «        ‚)NrE   Ú ú:r0   )r>   r9   r:   Úintr%   ÚtuplerH   rM   rI   r   r4   )r   r-   r6   ÚsuboptsÚsubopts        r   rb   z_FileItem.set_option_colonsep5  s  € Øˆ=Ø×Ò˜dÑ#Ô#Ð#Ð#Ð#Ý�%‰[Œ[�U¥C˜LÐ(Ð(Ø#(°T°T°T¸5¸5Ð*BÐ"CˆDŒM˜$ÑÐÐÝ�%‰[Œ[�EÐ!Ð!ØˆGØð 0ð 0�Ø�>Ø—N’N 2Ñ&Ô&Ð&Ð&à—N’N¥3 v¡;¤;Ñ/Ô/Ð/Ð/àØ˜4˜4 §¢¨'Ñ!2Ô!2Ð!2Ð4ð#ˆDŒM˜$ÑÐÐõ
 Ô$°°°°e°eÐ%=Ñ>Ô>Ð>r   c                 ó€   — |r1t           j        j        st          j        d¦  «        ‚d| j        d<   d S d| j        d<   d S )Nz8Gnuplot.py is currently configured to reject binary data)é   r   r   )r   N)r   ÚGnuplotOptsÚrecognizes_binary_splotr   r4   r%   r_   s     r   r^   z_FileItem.set_option_binaryH  sW   € Øð 	0Ý”>Ô9ð PÝÔ(ØNñPô Pð Pà&3ˆDŒM˜(Ñ#Ð#Ð#à&/ˆDŒM˜(Ñ#Ð#Ð#r   N)r	   r
   r   r   r   r3   ÚcopyÚupdater(   rC   rb   r^   r   r   r   r\   r\   ì   sµ   € € € € € ðð ð Ô(×-Ò-Ñ/Ô/€LØ×ÒØFÐFØNÐNØNÐNØNÐNðð ð
ð 
ñ ô ð ð1(ð 1(ð 1(ðf5ð 5ð 5ð?ð ?ð ?ð&0ð 0ð 0ð 0ð 0r   r\   c                   ó   — e Zd Zdd„Zd„ ZdS )Ú_NewFileItemNc                 óê  — |                      dd¦  «        }|rd}nd}|rd| _        t          ||¦  «        }nod| _        t          t          d¦  «        r0t	          j        d| ¬	¦  «        \  }}t          j        ||¦  «        }n#t	          j        ¦   «         }t          ||¦  «        }| 	                    |¦  «         | 
                    ¦   «          | j        r	d
|vrd |d
<   t          j        | |fi |¤Ž d S )Nr   r   ÚwbÚwFTÚmkstempú.gnuplot)ÚsuffixÚtextr   )rG   ÚtempÚopenÚhasattrÚtempfiler~   ÚosÚfdopenÚmktempÚwriteÚcloser\   r(   )r   Úcontentri   r'   r   ÚmoderS   Úfds           r   r(   z_NewFileItem.__init__S  s  € à—’˜( AÑ&Ô&ˆØð 	ØˆDˆDàˆDàð 	)àˆDŒIÝ�X˜tÑ$Ô$ˆAˆAàˆDŒIÝ•x Ñ+Ô+ð 	)å"*Ô"2Ø%°¨Zð#ñ #ô #‘��Xõ ”I˜b $Ñ'Ô'��õ $œ?Ñ,Ô,�Ý˜ 4Ñ(Ô(�à	�Š�ÑÔÐØ	�Š‰	Œ	ˆ	ð Œ9ð 	!˜¨Ð,Ð,Ø ˆD�‰MåÔ˜4 Ð2Ð2¨TÐ2Ð2Ð2Ð2Ð2r   c                 óJ   — | j         rt          j        | j        ¦  «         d S d S r@   )r‚   r†   Úunlinkri   rB   s    r   Ú__del__z_NewFileItem.__del__v  s.   € ØŒ9ð 	%ÝŒI�d”mÑ$Ô$Ð$Ð$Ð$ð	%ð 	%r   r@   )r	   r
   r   r(   r�   r   r   r   rz   rz   R  s8   € € € € € ð!3ð !3ð !3ð !3ðF%ð %ð %ð %ð %r   rz   c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú_InlineFileItemz6A _FileItem that actually indicates inline data.

    c                 óÐ   — d|vrd |d<   |                      dd¦  «        rt          j        d¦  «        ‚t          j        | dfi |¤Ž |d         dk    r	|| _        d S |dz   | _        d S )Nr   r   r   z#binary inline data is not supportedú-éÿÿÿÿú
)rG   r   r4   r\   r(   r‹   ©r   r‹   r'   s      r   r(   z_InlineFileItem.__init__€  s…   € ð ˜$ÐÐØ ˆD�‰Mà�8Š8�H˜aÑ Ô ð 	LÝÔ$Ð%JÑKÔKÐKåÔ˜4 Ð-Ð-¨Ð-Ð-Ð-à�2Œ;˜$ÒÐØ"ˆDŒLˆLˆLà" T™>ˆDŒLˆLˆLr   c                 ó@   — |                      | j        dz   ¦  «         d S )Nze
)r‰   r‹   rR   s     r   rT   z_InlineFileItem.pipein�  s!   € Ø	�Š�”˜uÑ$Ñ%Ô%Ð%Ð%Ð%r   N)r	   r
   r   r   r(   rT   r   r   r   r’   r’   {  s<   € € € € € ðð ð*ð *ð *ð &ð &ð &ð &ð &r   r’   c                   ó    — e Zd ZdZdd„Zd„ ZdS )Ú_FIFOWritera/  Create a FIFO (named pipe), write to it, then delete it.

        The writing takes place in a separate thread so that the main
        thread is not blocked.  The idea is that once the writing is
        finished we know that gnuplot is done with the data that were in
        the file so we can delete the file.  This technique removes the
        ambiguity about when the temporary files should be deleted.

        Since the tempfile module does not provide an easy, secure way
        to create a FIFO without race conditions, we instead create a
        temporary directory using mkdtemp() then create the FIFO
        within that directory.  When the writer thread has written the
        full information to the FIFO, it deletes both the FIFO and the
        temporary directory that contained it.

        r}   c                 óÀ  — || _         || _        t          t          d¦  «        rEt          j        d¬¦  «        | _        t          j                             | j        d¦  «        | _	        nd | _        t          j
        ¦   «         | _	        t          j                             | d| j	        ›�¬¦  «         t          j        | j	        ¦  «         |                      ¦   «          d S )NÚmkdtempr   )r€   ÚfifozFIFO Writer for )r-   )r‹   rŒ   r„   r…   rœ   Údirnamer†   ÚpathrI   ri   rˆ   Ú	threadingÚThreadr(   ÚmkfifoÚstart)r   r‹   rŒ   s      r   r(   z_FIFOWriter.__init__©  sÀ   € Ø"ˆDŒLØˆDŒIÝ•x Ñ+Ô+ð 	2õ  (Ô/°zÐBÑBÔB�”Ý "¤§¢¨T¬\¸6Ñ BÔ B�”�ð  $�”Ý (¤Ñ 1Ô 1�”ÝÔ×%Ò%Ø�Ø.2¬m¨mÐ=ð &ñ ô ð õ ŒI�d”mÑ$Ô$Ð$Ø�JŠJ‰LŒLˆLˆLˆLr   c                 ó  — t          | j        | j        ¦  «        }|                     | j        ¦  «         |                     ¦   «          t          j        | j        ¦  «         | j        �t          j	        | j        ¦  «         d S d S r@   )
rƒ   ri   rŒ   r‰   r‹   rŠ   r†   r�   rž   ÚrmdirrR   s     r   Úrunz_FIFOWriter.run½  sp   € Ý�T”] D¤IÑ.Ô.ˆAØ�GŠG�D”LÑ!Ô!Ð!Ø�GŠG‰IŒIˆIÝŒI�d”mÑ$Ô$Ð$ØŒ|Ð'Ý”˜œÑ&Ô&Ð&Ð&Ð&ð (Ð'r   N)r}   )r	   r
   r   r   r(   r¦   r   r   r   rš   rš   —  sA   € € € € € ð	ð 	ð"	ð 	ð 	ð 	ð(	'ð 	'ð 	'ð 	'ð 	'r   rš   c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú_FIFOFileItemz˜A _FileItem based on a FIFO (named pipe).

        This class depends on the availablity of os.mkfifo(), which only
        exists under Unix.

        c                 ó˜   — d|vrd |d<   t          j        | dfi |¤Ž || _        |                     dd¦  «        r	d| _        d S d| _        d S )Nr   rm   r   r   r|   r}   )r\   r(   r‹   rG   rŒ   r—   s      r   r(   z_FIFOFileItem.__init__Î  sf   € ð ˜dÐ"Ð"Ø $��W‘åÔ˜t RÐ0Ð0¨4Ð0Ð0Ð0Ø"ˆDŒLØ�xŠx˜ !Ñ$Ô$ð  Ø �”	�	�	à�”	�	�	r   c                 óh   — t          | j        | j        ¦  «        }t          j        |j        ¦  «        S )z¬Create the gnuplot command for plotting this item.

            The basecommand is different each time because each FIFOWriter
            creates a new FIFO.

            )rš   r‹   rŒ   r   rk   ri   )r   r�   s     r   rC   z%_FIFOFileItem.get_base_command_stringÛ  s*   € õ ˜tœ|¨T¬YÑ7Ô7ˆDÝÔ)¨$¬-Ñ8Ô8Ð8r   NrZ   r   r   r   r¨   r¨   Æ  s<   € € € € € ð	ð 	ð	 ð 	 ð 	 ð	9ð 	9ð 	9ð 	9ð 	9r   r¨   c                 óx   — t          | ¦  «        t          urt          j        d| ›d�¦  «        ‚t	          | fi |¤ŽS )a8  Construct a _FileItem object referring to an existing file.

    This is a convenience function that just returns a _FileItem that
    wraps the filename.

    <filename> is a string holding the filename of an existing file.
    The keyword arguments are the same as those of the _FileItem
    constructor.

    z
Argument (z) must be a filename)r9   r:   r   r4   r\   )ri   r'   s     r   ÚFiler¬   é  sO   € õ ˆH�~„~�UÐ"Ð"ÝÔ Ð Ø2:°(°(Ð<ñô ð 	õ �XÐ&Ð& Ð&Ð&Ð&r   c            
      óš  — t          | ¦  «        dk    rIt          j        | d         ¦  «        } t          | j        ¦  «        dk    r| dd…t          j        f         } nat          j        | ¦  «        } t          | j        ¦  «        }t	          j        | |dz
  ft          t          |dz
  ¦  «        ¦  «        z   ¦  «        } d|v r9|d         }|d= t          |t          ¦  «        r|f}t	          j        | |d¦  «        } d|v r|d         pd}|d= nd}d|v r$|d         }|d= |r|rt          j        d¦  «        ‚n| ot          j        j        }t#          ¦   «         }t          j        || ¦  «         |                     ¦   «         }|rt)          |fi |¤ŽS |rt+          |fd|i|¤ŽS t          j        j        rt/          |fi |¤ŽS t+          |fi |¤ŽS )	a¹  Create and return a _FileItem representing the data from *data.

    Create a '_FileItem' object (which is a type of 'PlotItem') out of
    one or more Float Python numpy arrays (or objects that can be
    converted to a float numpy array).  If the routine is passed a
    single with multiple dimensions, then the last index ranges over
    the values comprising a single data point (e.g., [<x>, <y>,
    <sigma>]) and the rest of the indices select the data point.  If
    passed a single array with 1 dimension, then each point is
    considered to have only one value (i.e., by default the values
    will be plotted against their indices).  If the routine is passed
    more than one array, they must have identical shapes, and then
    each data point is composed of one point from each array.  E.g.,
    'Data(x,x**2)' is a 'PlotItem' that represents x squared as a
    function of x.  For the output format, see the comments for
    'write_array()'.

    How the data are written to gnuplot depends on the 'inline'
    argument and preference settings for the platform in use.

    Keyword arguments:

        'cols=<tuple>' -- write only the specified columns from each
            data point to the file.  Since cols is used by python, the
            columns should be numbered in the python style (starting
            from 0), not the gnuplot style (starting from 1).

        'inline=<bool>' -- transmit the data to gnuplot 'inline'
            rather than through a temporary file.  The default is the
            value of gp.GnuplotOpts.prefer_inline_data.

        'filename=<string>' -- save data to a permanent file.

    The keyword arguments recognized by '_FileItem' can also be used
    here.

    rt   r   NÚcolsr•   ri   Úinlineú+cannot pass data both inline and via a file)Úlenr   Úfloat_arrayÚshapeÚnumpyÚnewaxisÚ	transposerp   ÚrangeÚ
isinstancero   Útaker   r4   r   ru   Úprefer_inline_datar   Úwrite_arrayÚgetvaluer’   rz   Úprefer_fifo_datar¨   )Údatar'   Údimsr®   ri   r¯   rS   r‹   s           r   ÚDatarÀ   ü  s	  € õN ˆ4�y„y�A‚~€~åÔ   a¤Ñ)Ô)ˆõ
 ˆtŒz‰?Œ?˜aÒÐØ˜˜˜�%œ-˜Ô(ˆDøõ
 Ô  Ñ&Ô&ˆÝ�4”:‰ŒˆåŒ˜t d¨1¡f Yµµu¸TÀ!¹V±}´}Ñ1EÔ1EÑ%EÑFÔFˆØ�€~€~Ø�FŒ|ˆØ�ˆLÝ�d�CÑ Ô ð 	Ø�7ˆDÝŒz˜$  bÑ)Ô)ˆà�TÐÐØ˜
Ô#Ð+ tˆØ�ÐÐàˆà�4ÐÐØ�h”ˆØ�ˆNØð 	�hð 	ÝÔ$Ø=ñô ð øð �,ÐE¥B¤NÔ$Eˆõ 	‰
Œ
€AÝ	Ô�a˜ÑÔÐØ�jŠj‰lŒl€GØð -Ý˜wÐ/Ð/¨$Ð/Ð/Ð/Ø	ð -Ý˜GÐ?Ð?¨hÐ?¸$Ð?Ð?Ð?Ý	ŒÔ	(ð -Ý˜WÐ-Ð-¨Ð-Ð-Ð-å˜GÐ,Ð, tÐ,Ð,Ð,r   c                 ó´  — t          j        | ¦  «        } 	 | j        \  }}n"# t          $ r t	          j        d¦  «        ‚w xY w|€t          j        |¦  «        }n4t          j        |¦  «        }|j        |fk    rt	          j        d¦  «        ‚|€t          j        |¦  «        }n4t          j        |¦  «        }|j        |fk    rt	          j        d¦  «        ‚|                     dd¦  «        ot          j
        j        }||d<   |t          u r| o| ot          j
        j        }n|r|rt	          j        d¦  «        ‚|�r1|rt	          j        d¦  «        ‚t          j        |dz   |dz   ft          j        ¦  «        }	||	d	<   |                     t          j        ¦  «        |	d
dd…f<   |                     t          j        ¦  «        |	dd…d
f<   	 t          j        | ¦  «        |	dd…dd…f<   nA#  t          j        |                      t          j        ¦  «        ¦  «        |	dd…dd…f<   Y nxY w|	                     ¦   «         }
|st          j
        j        rt+          |
fi |¤ŽS t-          |
fd|i|¤ŽS t          j        t          j        t          j        t          j        |||f¦  «        ¦  «        t          j        |||f¦  «        | f¦  «        d¦  «        }t3          ¦   «         }t          j        ||¦  «         |                     ¦   «         }
|rt9          |
fi |¤ŽS |rt-          |
fd|i|¤ŽS t          j
        j        rt+          |
fi |¤ŽS t-          |
fi |¤ŽS )a*  Return a _FileItem representing a function of two variables.

    'GridData' represents a function that has been tabulated on a
    rectangular grid.  The data are written to a file; no copy is kept
    in memory.

    Arguments:

        'data' -- the data to plot: a 2-d array with dimensions
            (numx,numy).

        'xvals' -- a 1-d array with dimension 'numx'

        'yvals' -- a 1-d array with dimension 'numy'

        'binary=<bool>' -- send data to gnuplot in binary format?

        'inline=<bool>' -- send data to gnuplot "inline"?

        'filename=<string>' -- save data to a permanent file.

    Note the unusual argument order!  The data are specified *before*
    the x and y values.  (This inconsistency was probably a mistake;
    after all, the default xvals and yvals are not very useful.)

    'data' must be a data array holding the values of a function
    f(x,y) tabulated on a grid of points, such that 'data[i,j] ==
    f(xvals[i], yvals[j])'.  If 'xvals' and/or 'yvals' are omitted,
    integers (starting with 0) are used for that coordinate.  The data
    are written to a temporary file; no copy of the data is kept in
    memory.

    If 'binary=0' then the data are written to a datafile as 'x y
    f(x,y)' triplets (y changes most rapidly) that can be used by
    gnuplot's 'splot' command.  Blank lines are included each time the
    value of x changes so that gnuplot knows to plot a surface through
    the data.

    If 'binary=1' then the data are written to a file in a binary
    format that 'splot' can understand.  Binary format is faster and
    usually saves disk space but is not human-readable.  If your
    version of gnuplot doesn't support binary format (it is a
    recently-added feature), this behavior can be disabled by setting
    the configuration variable
    'gp.GnuplotOpts.recognizes_binary_splot=0' in the appropriate
    gp*.py file.

    Thus if you have three arrays in the above format and a Gnuplot
    instance called g, you can plot your data by typing
    'g.splot(Gnuplot.GridData(data,xvals,yvals))'.

    z"data array must be two-dimensionalNzWThe size of xvals must be the same as the size of the first dimension of the data arrayzXThe size of yvals must be the same as the size of the second dimension of the data arrayr   rt   r°   z binary inline data not supported)r   r   r   ri   )rt   é   r   )r   r²   r³   Ú
ValueErrorr   Ú	DataErrorr´   ÚarangerG   r   ru   rv   r   rº   r4   ÚzerosÚfloat32Úastyper¶   Útostringr½   r¨   rz   ÚarrayÚresizer   r»   r¼   r’   )r¾   ÚxvalsÚyvalsr¯   ri   r'   ÚnumxÚnumyr   Úmoutr‹   ÚsetrS   s                r   ÚGridDatarÒ   Y  sÃ  € õr Ô˜TÑ"Ô"€DðEØ”z‰ˆˆtˆtøÝð Eð Eð EÝÔÐCÑDÔDÐDðEøøøð €}Ý”˜TÑ"Ô"ˆˆåÔ! %Ñ(Ô(ˆØŒ;˜4˜'Ò!Ð!ÝÔ"ð8ñ9ô 9ð 9ð €}Ý”˜TÑ"Ô"ˆˆåÔ! %Ñ(Ô(ˆØŒ;˜4˜'Ò!Ð!ÝÔ"ð9ñ:ô :ð :ð �XŠX�h Ñ"Ô"ÐM¥r¤~Ô'M€FØ€Dˆ�Nà•ÐÐàˆZð 2 (˜lð 2Ý”Ô1ð 	ˆð 
ð �Hð ÝÔ Ø9ñô ð 	ð
 ñ 41Øð 	IÝÔ$Ð%GÑHÔHÐHõ Œ{˜D 1™H d¨Q¡hÐ/µ´Ñ?Ô?ˆØˆˆS‰	Ø—\’\¥%¤-Ñ0Ô0ˆˆQˆqˆrˆrˆT‰
Ø—\’\¥%¤-Ñ0Ô0ˆˆQˆRˆR�ˆT‰
ð	Fåœ/¨$Ñ/Ô/ˆD����A�B�B�‰KˆKøð	Fõ  œ/¨$¯+ª+µe´mÑ*DÔ*DÑEÔEˆD����A�B�B�‰KˆKˆKøøøà—-’-‘/”/ˆØð 	D�bœnÔ=ð 	DÝ  Ð1Ð1¨DÐ1Ð1Ð1å ÐCÐC°(ÐC¸dÐCÐCÐCõ
 ŒoÝŒKÝ”¥¤¨e°d¸D°\Ñ!BÔ!BÑCÔCÝ”˜e d¨D \Ñ2Ô2Øðñô ð !ñ	"ô "ˆõ ‰JŒJˆÝÔ˜!˜SÑ!Ô!Ð!Ø—*’*‘,”,ˆàð 	1Ý" 7Ð3Ð3¨dÐ3Ð3Ð3Øð 	1Ý ÐCÐC°(ÐC¸dÐCÐCÐCÝŒ^Ô,ð 	1Ý  Ð1Ð1¨DÐ1Ð1Ð1å Ð0Ð0¨4Ð0Ð0Ð0s   –
! ¡A ÇG. Ç.<H,)r   r†   Ústringr…   ÚtypesÚior   ÚImportErrorr´   ÚGnuplotr   r   r   r   r   rV   r\   rz   r’   ru   Úsupport_fifor    r¡   rš   r¨   r¬   rÀ   rÒ   r   r   r   ú<module>rÙ      sˆ  ððð ð #Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ð "ðØÐÐÐÐÐÐøØð ð ð ØÐÐÐÐÐÐÐðøøøð €€€à %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ð %ð	ð 	ð 	ð 	ð 	ñ 	ô 	ð 	ðjð jð jð jð jñ jô jð jðZð ð ð ð ˆ8ñ ô ð ð8c0ð c0ð c0ð c0ð c0�ñ c0ô c0ð c0ðL&%ð &%ð &%ð &%ð &%�9ñ &%ô &%ð &%ðR&ð &ð &ð &ð &�iñ &ô &ð &ð2 „>Ôð R9ØÐÐÐð,'ð ,'ð ,'ð ,'ð ,'�iÔ&ñ ,'ô ,'ð ,'ð^ 9ð  9ð  9ð  9ð  9˜	ñ  9ô  9ð  9ðF'ð 'ð 'ð&Z-ð Z-ð Z-ð| ˜D¨¸$ðU1ð U1ð U1ð U1ð U1ð U1s   ” ›)¨)