Skip to content

Commit 8ff916a

Browse files
committed
DOC: Deprecation info for float-slicing.
1 parent 1515155 commit 8ff916a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

numpy/core/tests/test_deprecations.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ def check_does_not_raise(f, category):
3030

3131
class TestFloatScalarIndexDeprecation(object):
3232
"""
33-
These test that DeprecationWarnings get raised when you
34-
try to use scalar indices that are not integers e.g. a[0.0],
35-
a[1.5, 0].
33+
These test that `DeprecationWarning`s get raised when you
34+
try to use scalar indices that are not integers e.g. `a[0.0]`,
35+
`a[1.5, 0]`.
3636
37-
grep PyIndex_Check_Or_Unsupported numpy/core/src/multiarray/* for
38-
all the calls to DEPRECATE().
37+
grep "non-integer scalar" numpy/core/src/multiarray/* for
38+
all the calls to `DEPRECATE()`, except the one inside
39+
`_validate_slice_parameter` which handles slicing (but see also
40+
`TestFloatSliceParameterDeprecation`).
3941
40-
When 2.4 support is dropped PyIndex_Check_Or_Unsupported should
41-
be removed from npy_pycompat.h and changed to just PyIndex_Check.
42+
When 2.4 support is dropped `PyIndex_Check_Or_Unsupported` should
43+
be removed from npy_pycompat.h and changed to just `PyIndex_Check`.
4244
"""
4345
def setUp(self):
4446
warnings.filterwarnings("error", message="non-integer scalar index",
@@ -92,6 +94,19 @@ def test_valid_not_deprecated(self):
9294

9395

9496
class TestFloatSliceParameterDeprecation(object):
97+
"""
98+
These test that `DeprecationWarning`s get raised when you
99+
try to use non-integers for slicing, e.g `a[0.0:5]`, `a[::1.5]`,
100+
etc.
101+
102+
When this is changed to an error, `slice_GetIndices` and
103+
`_validate_slice_parameter` should probably be removed. Calls to
104+
`slice_GetIndices` should be replaced by the standard Python
105+
API call `PySlice_GetIndicesEx`, since `slice_GetIndices`
106+
implements the same thing but with a) int coercion and b) Python
107+
< 2.3 backwards compatibility (which we have long since dropped
108+
as of this writing).
109+
"""
95110
def setUp(self):
96111
warnings.filterwarnings("error", message="non-integer slice param",
97112
category=DeprecationWarning)

0 commit comments

Comments
 (0)