a ;jg @sbdZddlmZddlmZddlmZmZmZm Z dgZ edddZ e Gd ddee Z d S) z3A module containing the `_NestedSequence` protocol.) annotations)Iterator)AnyTypeVarProtocolruntime_checkable_NestedSequence_T_coT) covariantc@szeZdZdZddddZddddd Zd d d d dZddddZddddZdddddZ dddddZ dS)raA 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)returncCstdS)zImplement ``len(self)``.NNotImplementedErrorselfrH/usr/local/lib/python3.9/site-packages/numpy/_typing/_nested_sequence.py__len__<sz_NestedSequence.__len__z_T_co | _NestedSequence[_T_co])indexr cCstdS)zImplement ``self[x]``.Nr )rrrrr __getitem__@sz_NestedSequence.__getitem__objectbool)xr cCstdS)zImplement ``x in self``.Nr )rrrrr __contains__Dsz_NestedSequence.__contains__z(Iterator[_T_co | _NestedSequence[_T_co]]cCstdS)zImplement ``iter(self)``.Nr rrrr__iter__Hsz_NestedSequence.__iter__cCstdS)zImplement ``reversed(self)``.Nr rrrr __reversed__Lsz_NestedSequence.__reversed__r)valuer cCstdS)z,Return the number of occurrences of `value`.Nr rrrrrcountPsz_NestedSequence.countcCstdS)z"Return the first index of `value`.Nr rrrrrTsz_NestedSequence.indexN) __name__ __module__ __qualname____doc__rrrrrrrrrrrrs(N) r" __future__rcollections.abcrtypingrrrr__all__r rrrrrs