| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
i.e. `numpy.typing` and `numpy._typing`
|
|
|
|
| |
Represents a subset of `npt.ArrayLike` that can be parametrized w.r.t. `np.generic`
|
|
|
|
| |
module
|
| |
|
| |
|
| |
|
|
|
| |
* Remove unnecessary imports and minor fixes
|
|
|
|
|
|
| |
Strings and types that are not subscriptable during runtime can cause issues with runtime Introspection helpers such as `typing.get_type_hints`.
While this is very much an upstream issue, the particular case of `npt.ArrayLike` can be quite easily resolved in numpy.
|
| |
|
| |
|
|
|
|
| |
`typing_extensions` is available
|
| |
|
| |
|
| |
|
|
|
|
| |
Implementations of `__array__` do not require the `dtype` parameter
|
|
|
|
|
| |
An invariant-ish array-like consisting of int-like objects.
Note that it is not truly invariant due to `builtins.bool` inheriting from `builtins.int`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ENH: Added `_ArrayLikeNumber`
* ENH: Added dtype support to the array comparison ops
* MAINT: Made `dtype` and `ndarray` covariant
The dtypes scalar-type and ndarrays' dtype are now covariant instead of invariant.
This change is necasary in order to ensure that all generic subclasses can be used as underlying scalar type.
* TST: Updated the comparison typing tests
* MAINT: Fixed an issue where certain `array > arraylike` operations where neglected
More specifically operations between array-likes of `timedelta64` and `ndarray`s that can be cast into `timedelta64`.
For example:
ar_i = np.array([1])
seq_m = [np.timedelta64()]
ar_i > seq_m
|
| |
|
| |
|
|
|
|
|
|
| |
Addresses https://github.com/numpy/numpy/pull/17981#discussion_r541018879
Co-Authored-By: Charles Harris <charlesr.harris@gmail.com>
|
| |
|
| |
|
|
|
| |
* MAINT: Move the `<scalar>Like` unions to `numpy.typing`
|
| |
|
| |
|
|
|
|
|
|
| |
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.
|
|
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.
|