Type Promotion Rules — Python array API standard DRAFT documentation
https://data-apis.org/array-api/draft/API_specification/type_promotion.html
Type Promotion Rules — Python array API standard DRAFT documentation
https://data-apis.org/array-api/draft/API_specification/type_promotion.html
I have been investigating this:
```Python
from numbers import Real
def positive(x: Real) -> bool:
return x > 0 # Type Check failed!
```
#PEP 484 said that one should use `float` instead, but this does not solve for other numerical types e.g. #GMP numbers or #NumPy numbers.
And I found some old threads like https://github.com/python/typing/issues/1663
https://github.com/python/mypy/issues/3186
https://discuss.python.org/t/numeric-generics-where-do-we-go-from-pep-3141-and-present-day-mypy/17155
https://discuss.python.org/t/clarifying-the-float-int-complex-special-case/54018/26
And it seems like none has make any real progress.
To my understanding, ABC should also provides a good protocol for typing, just like typeclasses in #Haskell.
With regards to the numeric tower, PEP 484 states: PEP 3141 defines Python’s numeric tower, and the stdlib module numbers implements the corresponding ABCs (Number, Complex, Real, Rational and Inte...
https://numpy.org/neps/nep-0022-ndarray-duck-typing-overview.html
And I didn't know that #NumPy has NEPs