-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
This is a temporary tracker issue for the major differences between the stubs provided by NumType, and those bundled with NumPy. Once the documentation is online, a dedicated page for these will be created, instead.
Backwards incompatible fixes
Scalar type methods
[c]longdouble.item()and.tolist()now correctly returns[c]longdoubleinstead ofbuiltins.{complex,float}(💥 concrete complex scalar types #391, 💥 concrete floating scalar types #397)- moved the
is_integerandas_integer_ratiodefinitions fromfloatingto its concrete subtypes (💥 concrete floating scalar types #397) - moved the
__complex__and__hash__method definitions fromcomplexfloatingto its concrete subtypes (💥 concrete complex scalar types #391) - moved the
__hash__,__index__, andbitcountmethod definitions from[un]signedintegerto their concrete subtypes (💥 concretesignedintegerscalar types #407, 💥 concreteunsignedintegerscalar types #408)
Concrete scalar types
int{8,16,32,64}andlonghave been made into propersignedintegersubtypes (💥 concretesignedintegerscalar types #407)uint{8,16,32,64}andulonghave been made into properunsignedintegersubtypes (💥 concreteunsignedintegerscalar types #408)float16,float32, andlongdoublehave been made into properfloatingsubtypes (💥 concrete floating scalar types #397)complex64andclongdoublehave been made into propercomplexfloatingsubtypes (💥 concrete complex scalar types #391)- the discouraged
longandulongscalars are no longer equivalent to[u]intpand[u]int64
Extended precision
- removed
[u]int128,[u]int256,float80,float256,complex160,complex512(⚰️ remove non-existent extended-precision scalar types #209) float96andfloat128are aliases oflongdouble(💥 concrete floating scalar types #397)complex192andcomplex256are aliases ofclongdouble(💥 concrete complex scalar types #391)
NBitBase
numpy.typing.NBitBaseshould not be used anymore - actively discourage or prevent the usage ofnumpy.typing.NBitBase#395- removed the undocumented
numpy.typing.NBitBasesubtypes, such as_8Bitand_NBitDouble
Quality assurance
API consistency
Unlike NumPy, NumType uses stubtest to ensure that the typing stubs match the runtime implementation.
Type-checkers
The stubs in NumType are also checked by mypy, pyright, and basedpyright (in strict mode) to avoid any errors, and ensure compatibility with the major type-checkers.
Testing
NumPy uses a manual type-testing strategy, and its type-tests are a collection of toy examples that should either be rejected, accepted, or inferred to be of specific type using typing.assert_type.
But there is no mechanism that validates whether these type-tests correctly describe what would happen at runtime. The only way to ensure correctness of these tests, is to manually verify them. In NumPy, the type-tests are evaluated using mypy.
NumType also uses most of NumPy's (manual) type-tests, but validates them with both mypy and basedpyright.
But unlike NumPy, NumType also uses test generation in several places. For the scalar binary operators such as int8.__add__, for example, NumType procedurally generates all possible combinations of scalar types and operators, resulting in a 8283 assert_type statements and 2655 expected rejections. This guarantees that the scalar operator method annotations are correct and accurate for all possible (scalar) input types.
New features
Optional dtype type parameter
The generic scalar-type parameter of numpy.dtype has been made optional, with Any as the default. This allows you to write _: np.dtype instead of _: np.dtype[Any].
The numtype package
TBD
Shape-typing
TBD