§
    �Ÿj  ã                   ó   — d Z d„ Zd„ ZdeiZdS )a   
Handlers for IPythonDirective's @doctest pseudo-decorator.

The Sphinx extension that provides support for embedded IPython code provides
a pseudo-decorator @doctest, which treats the input/output block as a
doctest, raising a RuntimeError during doc generation if the actual output
(after running the input) does not match the expected output.

An example usage is:

.. code-block:: rst

   .. ipython::

        In [1]: x = 1

        @doctest
        In [2]: x + 2
        Out[3]: 3

One can also provide arguments to the decorator. The first argument should be
the name of a custom handler. The specification of any other arguments is
determined by the handler. For example,

.. code-block:: rst

      .. ipython::

         @doctest float
         In [154]: 0.1 + 0.2
         Out[154]: 0.3

allows the actual output ``0.30000000000000004`` to match the expected output
due to a comparison with `np.allclose`.

This module contains handlers for the @doctest pseudo-decorator. Handlers
should have the following function signature::

    handler(sphinx_shell, args, input_lines, found, submitted)

where `sphinx_shell` is the embedded Sphinx shell, `args` contains the list
of arguments that follow: '@doctest handler_name', `input_lines` contains
a list of the lines relevant to the current doctest, `found` is a string
containing the output from the IPython shell, and `submitted` is a string
containing the expected output from the IPython shell.

Handlers must be registered in the `doctests` dict at the end of this module.

c                 ó  — ddl }ddl m}m} |                      d¦  «        r
| dd…         } |                      d¦  «        r*|                     t          | ¦  «        t          ¬¦  «        }n"|                     t          | ¦  «        ¦  «        }|S )	aI  
    Simplistic converter of strings from repr to float NumPy arrays.

    If the repr representation has ellipsis in it, then this will fail.

    Parameters
    ----------
    s : str
        The repr version of a NumPy array.

    Examples
    --------
    >>> s = "array([ 0.3,  inf,  nan])"
    >>> a = str_to_array(s)

    é    N)ÚinfÚnanÚarrayé   éÿÿÿÿú[)Údtype)Únumpyr   r   Ú
startswithr   ÚevalÚfloatÚ
atleast_1d)ÚsÚnpr   r   Úas        ún/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/IPython/sphinxext/custom_doctests.pyÚstr_to_arrayr   3   sš   € ð" ÐÐÐð ÐÐÐÐÐÐÐà‡|‚|�HÑÔð àˆa�ˆdŒGˆà‡|‚|�DÑÔð $Ø�HŠH•T˜!‘W”W¥EˆHÑ*Ô*ˆˆð �MŠM�% ™(œ(Ñ#Ô#ˆØ€Hó    c           	      ót  ‡— ddl }t          |¦  «        dk    rd}d}nc	 t          |d         ¦  «        }t          |d         ¦  «        }n7# t          $ r*}d                     |¦  «        }t          |¦  «        |‚d}~ww xY w	 t          |¦  «        }t          |¦  «        }|                     |¦  «        }	|                     |¦  «        }
|                     |	|
¦  «         }||                     ||	          ||
          ||¬¦  «         z  }n	#  d	}Y nxY wd
Š| j        }|€d}d}n7|j	        j
        j        }d                     ˆfd„|j        D ¦   «         ¦  «        }|rYd}|                     ||d                     |¦  «        t          |¦  «        t          |¦  «        ‰¬¦  «        }t          |¦  «        ‚dS )zÿ
    Doctest which allow the submitted output to vary slightly from the input.

    Here is how it might appear in an rst file:

    .. code-block:: rst

       .. ipython::

          @doctest float
          In [1]: 0.1 + 0.2
          Out[1]: 0.3

    r   Né   gñhãˆµøä>g:Œ0âŽyE>é   zEBoth `rtol` and `atol` must be specified if either are specified: {0})ÚrtolÚatolTz    ÚUnavailableú
c                 ó   •— g | ]}‰|z   ‘ŒS © r   )Ú.0ÚlineÚTABs     €r   ú
<listcomp>z!float_doctest.<locals>.<listcomp>‰   s   ø€ ÐFÐFÐF¨D˜S 4™ZÐFÐFÐFr   z¥doctest float comparison failure

Document source: {0}

Raw content: 
{1}

On input line(s):
{TAB}{2}

we found output:
{TAB}{3}

instead of the expected:
{TAB}{4}

)r!   )r   Úlenr   Ú
IndexErrorÚformatr   ÚisnanÚallcloseÚ	directiveÚstateÚdocumentÚcurrent_sourceÚjoinÚcontentÚreprÚRuntimeError)Úsphinx_shellÚargsÚinput_linesÚfoundÚ	submittedr   r   r   ÚeÚfound_isnanÚsubmitted_isnanÚerrorr(   Úsourcer-   r!   s                  @r   Úfloat_doctestr:   U   sö  ø€ ð ÐÐÐå
ˆ4�y„y�A‚~€~ØˆØˆˆð	'Ý˜˜aœ‘>”>ˆDÝ˜˜aœ‘>”>ˆDˆDøÝð 	'ð 	'ð 	'ð0ß06²°t±´ð å˜Q‘-”- QÐ&øøøøð	'øøøð
7Ý  Ñ+Ô+ˆ	Ý˜UÑ#Ô#ˆð
 —h’h˜u‘o”oˆØŸ(š( 9Ñ-Ô-ˆØ—K’K ¨_Ñ=Ô=Ð=ˆØ�R—[’[ ¨ |Ô!4Ø!*¨OÐ+;Ô!<Ø&*°ð !ñ 7ô 7ð 7ñ 	7ˆˆøðàˆˆˆøøøð €CØÔ&€IØÐØˆØˆˆà”Ô)Ô8ˆà—)’)ÐFÐFÐFÐF°IÔ4EÐFÑFÔFÑGÔGˆàð 
ð6ˆð �HŠH�V˜W d§i¢i°Ñ&<Ô&<½dÀ5¹k¼kÝ˜)‘_”_¨#ð ñ /ô /ˆå˜1‰oŒoÐð
ð 
s#   Ÿ*A
 Á

A>Á%A9Á9A>ÂD ÄDr   N)Ú__doc__r   r:   Údoctestsr   r   r   ú<module>r=      sE   ðð0ð 0ðd ð  ð  ðD@ð @ð @ðJ ˆ]ð€€€r   