Integers and booleans can often be used interchangeably (in fact, bool is an int subclass in builtin python). Created_ArrayLikeIntOrBool to reflect this compatibility.
Rename _ScalarGeneric to _ScalarGenericDT; add a new _ScalarGeneric TypeVar which is only bound to np.generic.
np.choose() can only accept array-like objects consisting of integers (or booleans); reflect this in its annotation.
np.argpartition() will return an np.integer if a scalar is passed; not an np.ndarray.
Further Notes
It seems np.partition() might actually bugged in NumPy 1.17.3.
it's default value for axis is set to -1 instead of None. Consequently, it will raise an AxisError if a scalar is passed unless one explicitly passes axis=None to the function.
>>> import numpy as np
>>> np.partition(0, 0, axis=None)
array([0])
>>> np.partition(0, 0)
Traceback (most recent call last):
...
AxisError: axis -1 is out of bounds for array of dimension 0
Follow-up on https://github.com/numpy/numpy-stubs/pull/71#issuecomment-619435429.
https://github.com/numpy/numpy-stubs/pull/67 Fixes & Updates
bool
is anint
subclass in builtin python). Created_ArrayLikeIntOrBool
to reflect this compatibility._ScalarGeneric
to_ScalarGenericDT
; add a new_ScalarGeneric
TypeVar which is only bound tonp.generic
.np.choose()
can only accept array-like objects consisting of integers (or booleans); reflect this in its annotation.np.argpartition()
will return annp.integer
if a scalar is passed; not annp.ndarray
.Further Notes
np.partition()
might actually bugged in NumPy1.17.3
. it's default value foraxis
is set to-1
instead ofNone
. Consequently, it will raise anAxisError
if a scalar is passed unless one explicitly passesaxis=None
to the function.