summaryrefslogtreecommitdiff
path: root/numpy/typing/_nested_sequence.py
diff options
context:
space:
mode:
authorBas van Beek <43369155+BvB93@users.noreply.github.com>2022-03-18 17:09:56 +0100
committerBas van Beek <43369155+BvB93@users.noreply.github.com>2022-03-18 18:29:54 +0100
commit7739583f5fb39c31e83010a3153fa078004e55eb (patch)
tree23435d5de3f1870bc664354d50524b7166c2587a /numpy/typing/_nested_sequence.py
parenta8f9711493adee93fa3d61e7ef1bee11d7055a85 (diff)
downloadnumpy-7739583f5fb39c31e83010a3153fa078004e55eb.tar.gz
MAINT: Split `numpy.typing` into a public and private component
i.e. `numpy.typing` and `numpy._typing`
Diffstat (limited to 'numpy/typing/_nested_sequence.py')
-rw-r--r--numpy/typing/_nested_sequence.py90
1 files changed, 0 insertions, 90 deletions
diff --git a/numpy/typing/_nested_sequence.py b/numpy/typing/_nested_sequence.py
deleted file mode 100644
index 3db226ddf..000000000
--- a/numpy/typing/_nested_sequence.py
+++ /dev/null
@@ -1,90 +0,0 @@
-"""A module containing the `_NestedSequence` protocol."""
-
-from __future__ import annotations
-
-from typing import (
- Any,
- Iterator,
- overload,
- TypeVar,
- Protocol,
-)
-
-__all__ = ["_NestedSequence"]
-
-_T_co = TypeVar("_T_co", covariant=True)
-
-
-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 _NestedSequnce
-
- >>> def get_dtype(seq: _NestedSequnce[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)``."""
- raise NotImplementedError
-
- @overload
- def __getitem__(self, index: int, /) -> _T_co | _NestedSequence[_T_co]: ...
- @overload
- def __getitem__(self, index: slice, /) -> _NestedSequence[_T_co]: ...
-
- def __getitem__(self, index, /):
- """Implement ``self[x]``."""
- raise NotImplementedError
-
- def __contains__(self, x: object, /) -> bool:
- """Implement ``x in self``."""
- raise NotImplementedError
-
- def __iter__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
- """Implement ``iter(self)``."""
- raise NotImplementedError
-
- def __reversed__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
- """Implement ``reversed(self)``."""
- raise NotImplementedError
-
- def count(self, value: Any, /) -> int:
- """Return the number of occurrences of `value`."""
- raise NotImplementedError
-
- def index(self, value: Any, /) -> int:
- """Return the first index of `value`."""
- raise NotImplementedError