Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/sphinxext/__pycache__/custom_doctests.cpython-39.pyc
Ðазад
a o�h � @ s d Z dd� Zdd� ZdeiZdS )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 C s^ ddl }ddl m}m} | �d�r.| dd� } | �d�rL|jt| �td�}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� ����[)Zdtype)�numpyr r � startswithr �eval�floatZ atleast_1d)�s�npr r �a� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/sphinxext/custom_doctests.py�str_to_array3 s r c sZ ddl }t|�dkrd}d}nVzt|d �}t|d �}W n8 tyr } z d�|�}t|�|�W Y d}~n d}~0 0 zt|�}t|�}W n d} Y nH0 |�|�} |�|�}|�| |� } | |j|| || ||d � O } d � | j}|du r�d} d}n$|j j j} d�� fd d�|j D ��}| �rVd}|j| |d�|�t|�t|�� d�}t|��dS )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}T)�rtol�atolz ZUnavailable� c s g | ]}� | �qS r r )�.0�line�ZTABr r � <listcomp>� � z!float_doctest.<locals>.<listcomp>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 �isnanZallclose� directive�stateZdocumentZcurrent_source�join�content�repr�RuntimeError)Zsphinx_shell�argsZinput_lines�foundZ submittedr r r �e�errorZfound_isnanZsubmitted_isnanr �sourcer# r r r � float_doctestU sJ � � �r+ r N)�__doc__r r+ Zdoctestsr r r r �<module> s 2"E�
| ver. 1.1 | |
.
| PHP 8.3.30 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка