summaryrefslogtreecommitdiff
path: root/numpy/typing
Commit message (Collapse)AuthorAgeFilesLines
...
* DOC: Add correctness vs strictness consideration for np.dtype (#16917)Anirudh Subramanian2020-08-031-2/+16
| | | | | | | | | | | | | | | | | | * DOC: Add correctness vs strictness consideration for np.dtype * MAINT: Update numpy/typing/__init__.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * MAINT: Update numpy/typing/__init__.py Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com> * MAINT: Change type to static type to differentiate from type objects * MAINT: Revert static type change Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
* MAINT: Implemented two dtype-related TODO's (#16622)Bas van Beek2020-07-301-15/+44
| | | | | This pull requests addresses and implement two previous TODO's in `np.typing._DTypeLike`: * Added a protocol, `_SupportsDtype`, for objects with the `dtype` attribute. * Replaced an old dictionary, representing array field parameter, with a `TypedDict`.
* DOC: add reference to Python issue about buffer protocolsJosh Wilson2020-06-161-2/+4
|
* DOC: add note about supporting buffer protocols in `ArrayLike`Josh Wilson2020-06-151-0/+5
|
* DOC: clarify `ArrayLike` example in typing docsJosh Wilson2020-06-151-5/+21
|
* DOC: add warning about typing-extensions module to numpy.typing docsJosh Wilson2020-06-112-2/+11
| | | | | | Typing `ArrayLike` correctly relies on `Protocol`, so warn users that they should be on 3.8+ or install `typing-extensions` if they want everything to work as expected.
* DOC: add documentation for the numpy.typing moduleJosh Wilson2020-06-101-0/+53
|
* MAINT: make typing module available at runtimeJosh Wilson2020-06-094-0/+82
Closes https://github.com/numpy/numpy/issues/16550. This makes `np.typing.ArrayLike` and `np.typing.DtypeLike` available at runtime in addition to typing time. Some things to consider: - `ArrayLike` uses protocols, which are only in the standard library in 3.8+, but are backported in `typing_extensions`. This conditionally imports `Protocol` and sets `_SupportsArray` to `Any` at runtime if the module is not available to prevent NumPy from having a hard dependency on `typing_extensions`. Since e.g. mypy already includes `typing_extensions` as a dependency, anybody actually doing type checking will have it set correctly. - We are starting to hit the edges of "the fiction of the stubs". In particular, they could just cram everything into `__init__.pyi` and ignore the real structure of NumPy. But now that typing is available a runtime, we have to e.g. carefully import `ndarray` from `numpy` in the typing module and not from `..core.multiarray`, because otherwise mypy will think you are talking about a different ndarray. We will probably need to do some shuffling the stubs into more fitting locations to mitigate weirdness like this.