1j dZddlmZddlmZddlmZmZmZm Z m Z dgZ eddZ e Gd de e Z d S) z3A module containing the `_NestedSequence` protocol.) annotations)Iterator)AnyoverloadTypeVarProtocolruntime_checkable_NestedSequence_T_coT) covariantcxeZdZdZddZeddZedd Zd ZddZddZddZ ddZ ddZ dS)r aA 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]] returnintct)zImplement ``len(self)``.NotImplementedErrorselfs U/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/_typing/_nested_sequence.py__len__z_NestedSequence.__len__=!!index_T_co | _NestedSequence[_T_co]cdSNrrs r __getitem__z_NestedSequence.__getitem__AsLOCrslice_NestedSequence[_T_co]cdSrrrs rrz_NestedSequence.__getitem__CsFIcrct)zImplement ``self[x]``.rrs rrz_NestedSequence.__getitem__Frrxobjectboolct)zImplement ``x in self``.r)rr$s r __contains__z_NestedSequence.__contains__Jrr(Iterator[_T_co | _NestedSequence[_T_co]]ct)zImplement ``iter(self)``.rrs r__iter__z_NestedSequence.__iter__Nrrct)zImplement ``reversed(self)``.rrs r __reversed__z_NestedSequence.__reversed__Rrrvaluerct)z,Return the number of occurrences of `value`.rrr.s rcountz_NestedSequence.countVrrct)z"Return the first index of `value`.rr0s rrz_NestedSequence.indexZrrN)rr)rrrr)rr rr!)r$r%rr&)rr))r.rrr) __name__ __module__ __qualname____doc__rrrr(r+r-r1rrrrr r s&&P""""OOOXO IIIXI"""""""""""""""""""""""""rN)r6 __future__rcollections.abcrtypingrrrrr __all__r r rrrr;s99""""""$$$$$$  4(((H"H"H"H"H"huoH"H"H"H"H"r