Skip to content

Commit e4bd25d

Browse files
committed
📝 document the removal of the modular number ops
1 parent 11932c5 commit e4bd25d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/user_guide/differences.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ And even though it has gotten more verbose, it requires less mental to interpret
7878

7979
## Extended precision removals
8080

81-
The following non-extistent scalar types have been removed (numpy/numtype#209):
81+
The following non-existent scalar types have been removed (numpy/numtype#209):
8282

8383
- `int128` and `int256`
8484
- `uint128` and `uint256`
@@ -92,6 +92,25 @@ The platform-dependent `float96` and `float128` types are equivalent aliases of
9292
alias `clongdouble` (numpy/numtype#391).
9393
This was done in order to minimize the expected amount of "but it works on my machine".
9494

95+
## Removed `number.__floordiv__`
96+
97+
The abstract `numpy.number` type represents a scalar that's either integer, float, or complex.
98+
But the builtin "floordiv" operator, `//` is only supported for integer and floating scalars.
99+
Complex numpy scalars will raise an error. But in NumPy, type-checkers will allow you to write
100+
the following type-unsafe code:
101+
102+
```py
103+
import numpy as np
104+
105+
def half(a: np.number) -> np.number:
106+
return a // 2
107+
108+
half(np.complex128(1j)) # accepted
109+
```
110+
111+
In NumType's `numpy-stubs`, the `numpy.number.__[r]floordiv__` methods don't exist. This means that
112+
if you have `numtype` installed, your type-checker will report `a // 2` as an error.
113+
95114
## Mypy plugin
96115

97116
NumType does not support the numpy mypy plugin. The reasons for this are explained in the

0 commit comments

Comments
 (0)