Initial configuration commit
This commit is contained in:
commit
31c8abea59
266 changed files with 780274 additions and 0 deletions
81
typings/numpy/_typing/_nested_sequence.pyi
Normal file
81
typings/numpy/_typing/_nested_sequence.pyi
Normal file
|
@ -0,0 +1,81 @@
|
|||
"""
|
||||
This type stub file was generated by pyright.
|
||||
"""
|
||||
|
||||
from collections.abc import Iterator
|
||||
from typing import Any, Protocol, TypeVar, runtime_checkable
|
||||
|
||||
"""A module containing the `_NestedSequence` protocol."""
|
||||
__all__ = ["_NestedSequence"]
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
@runtime_checkable
|
||||
class _NestedSequence(Protocol[_T_co]):
|
||||
"""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]]
|
||||
|
||||
"""
|
||||
def __len__(self, /) -> int:
|
||||
"""Implement ``len(self)``."""
|
||||
...
|
||||
|
||||
def __getitem__(self, index: int, /) -> _T_co | _NestedSequence[_T_co]:
|
||||
"""Implement ``self[x]``."""
|
||||
...
|
||||
|
||||
def __contains__(self, x: object, /) -> bool:
|
||||
"""Implement ``x in self``."""
|
||||
...
|
||||
|
||||
def __iter__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
|
||||
"""Implement ``iter(self)``."""
|
||||
...
|
||||
|
||||
def __reversed__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
|
||||
"""Implement ``reversed(self)``."""
|
||||
...
|
||||
|
||||
def count(self, value: Any, /) -> int:
|
||||
"""Return the number of occurrences of `value`."""
|
||||
...
|
||||
|
||||
def index(self, value: Any, /) -> int:
|
||||
"""Return the first index of `value`."""
|
||||
...
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue