/ lib / numpy / _typing / _add_docstring.pyc
_add_docstring.pyc
  1  o

  2  Z��c��@s~dZddlZddlZddlmZgZdedededdfd	d
  3  �Zdefdd�Zed
dd�eddd�ede	e�d�e�Z
  4  dS)z=A module for creating docstrings for sphinx ``data`` domains.�N�)�NDArray�name�value�doc�returncCst�|||f�dS)z�Append ``_docstrings_list`` with a docstring for `name`.
  5  
  6      Parameters
  7      ----------
  8      name : str
  9          The name of the object.
 10      value : str
 11          A string-representation of the object.
 12      doc : str
 13          The docstring of the object.
 14  
 15      N)�_docstrings_list�append)rrr�r
 16  ��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\numpy\_typing\_add_docstring.py�
 17  add_newdocs
rcCs�g}tD]t\}}}t�|��dd�}|�d�}g}d}|D]E}t�d|�}	|	rY|rYt�|���}
 18  |
 19  dkrDd}|�|	�	d��d|
 20  ���nd}|�|	�	d��d	|
 21  ���|�d�q|�|�|���qd�
 22  |�}d
 23  |�d|�d|��}|�|�qd�
 24  |�S)zaConvert all docstrings in ``_docstrings_list`` into a single
 25      sphinx-legible text block.
 26  
 27      �
 28  z
 29      �z^(\s+)[-=]+\s*$�Examplesrz.. rubric:: z    z.. admonition:: z
 30  .. data:: z
 31      :value: )r�textwrap�dedent�replace�split�re�match�popr	�group�join)Z
type_list_retrrr�s�lines�	new_lines�indent�line�m�prevZs_blockr
 32  r
 33  r�_parse_docstringss*
 34  
 35  
 36  r �	ArrayLikeztyping.Union[...]ag
 37      A `~typing.Union` representing objects that can be coerced
 38      into an `~numpy.ndarray`.
 39  
 40      Among others this includes the likes of:
 41  
 42      * Scalars.
 43      * (Nested) sequences.
 44      * Objects implementing the `~class.__array__` protocol.
 45  
 46      .. versionadded:: 1.20
 47  
 48      See Also
 49      --------
 50      :term:`array_like`:
 51          Any scalar or sequence that can be interpreted as an ndarray.
 52  
 53      Examples
 54      --------
 55      .. code-block:: python
 56  
 57          >>> import numpy as np
 58          >>> import numpy.typing as npt
 59  
 60          >>> def as_array(a: npt.ArrayLike) -> np.ndarray:
 61          ...     return np.array(a)
 62  
 63      �	DTypeLikea�
 64      A `~typing.Union` representing objects that can be coerced
 65      into a `~numpy.dtype`.
 66  
 67      Among others this includes the likes of:
 68  
 69      * :class:`type` objects.
 70      * Character codes or the names of :class:`type` objects.
 71      * Objects with the ``.dtype`` attribute.
 72  
 73      .. versionadded:: 1.20
 74  
 75      See Also
 76      --------
 77      :ref:`Specifying and constructing data types <arrays.dtypes.constructing>`
 78          A comprehensive overview of all objects that can be coerced
 79          into data types.
 80  
 81      Examples
 82      --------
 83      .. code-block:: python
 84  
 85          >>> import numpy as np
 86          >>> import numpy.typing as npt
 87  
 88          >>> def as_dtype(d: npt.DTypeLike) -> np.dtype:
 89          ...     return np.dtype(d)
 90  
 91      ra�
 92      A :term:`generic <generic type>` version of
 93      `np.ndarray[Any, np.dtype[+ScalarType]] <numpy.ndarray>`.
 94  
 95      Can be used during runtime for typing arrays with a given dtype
 96      and unspecified shape.
 97  
 98      .. versionadded:: 1.21
 99  
100      Examples
101      --------
102      .. code-block:: python
103  
104          >>> import numpy as np
105          >>> import numpy.typing as npt
106  
107          >>> print(npt.NDArray)
108          numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]
109  
110          >>> print(npt.NDArray[np.float64])
111          numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
112  
113          >>> NDArrayInt = npt.NDArray[np.int_]
114          >>> a: NDArrayInt = np.arange(10)
115  
116          >>> def func(a: npt.ArrayLike) -> npt.NDArray[Any]:
117          ...     return np.array(a)
118  
119      )�__doc__rr�_generic_aliasrr�strrr �repr�_docstringsr
120  r
121  r
122  r�<module>s"!��
123  �
124