zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
U
O±dé
ã@s^dZddlmZddlmZmZmZmZmZm    Z    dgZ
edddZ e    Gdd„dee ƒƒZ d    S)
z3A module containing the `_NestedSequence` protocol.é)Ú annotations)ÚAnyÚIteratorÚoverloadÚTypeVarÚProtocolÚruntime_checkableÚ_NestedSequenceÚ_T_coT)Ú    covariantc@sšeZdZdZddœdd„Zedddœdd    „ƒZed
d dœd d    „ƒZd d    „Zdddœdd„Zddœdd„Zddœdd„Z    dddœdd„Z
dddœdd„Z dS)r    aðA protocol for representing nested sequences.
 
    Warning
    -------
    `_NestedSequence` currently does not work in combination with typevars,
    *e.g.* ``def func(a: _NestedSequnce[T]) -> T: ...``.
 
    See Also
    --------
    collections.abc.Sequence
        ABCs for read-only and mutable :term:`sequences`.
 
    Examples
    --------
    .. code-block:: python
 
        >>> from __future__ import annotations
 
        >>> from typing import TYPE_CHECKING
        >>> import numpy as np
        >>> from numpy._typing import _NestedSequence
 
        >>> def get_dtype(seq: _NestedSequence[float]) -> np.dtype[np.float64]:
        ...     return np.asarray(seq).dtype
 
        >>> a = get_dtype([1.0])
        >>> b = get_dtype([[1.0]])
        >>> c = get_dtype([[[1.0]]])
        >>> d = get_dtype([[[[1.0]]]])
 
        >>> if TYPE_CHECKING:
        ...     reveal_locals()
        ...     # note: Revealed local types are:
        ...     # note:     a: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
        ...     # note:     b: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
        ...     # note:     c: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
        ...     # note:     d: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
 
    Úint)ÚreturncCst‚dS)zImplement ``len(self)``.N©ÚNotImplementedError©Úself©rúUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/_typing/_nested_sequence.pyÚ__len__=sz_NestedSequence.__len__z_T_co | _NestedSequence[_T_co])Úindexr cCsdS©Nr©rrrrrÚ __getitem__Asz_NestedSequence.__getitem__Úslicez_NestedSequence[_T_co]cCsdSrrrrrrrCscCst‚dS)zImplement ``self[x]``.NrrrrrrFsÚobjectÚbool)Úxr cCst‚dS)zImplement ``x in self``.Nr)rrrrrÚ __contains__Jsz_NestedSequence.__contains__z(Iterator[_T_co | _NestedSequence[_T_co]]cCst‚dS)zImplement ``iter(self)``.NrrrrrÚ__iter__Nsz_NestedSequence.__iter__cCst‚dS)zImplement ``reversed(self)``.NrrrrrÚ __reversed__Rsz_NestedSequence.__reversed__r)Úvaluer cCst‚dS)z,Return the number of occurrences of `value`.Nr©rr rrrÚcountVsz_NestedSequence.countcCst‚dS)z"Return the first index of `value`.Nrr!rrrrZsz_NestedSequence.indexN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrrr"rrrrrr    s(N) r&Ú
__future__rÚtypingrrrrrrÚ__all__r
r    rrrrÚ<module>s