Skip to content

Commit 3d4aed3

Browse files
authored
API: revert position-only 'start' in 'np.arange' (numpy#25955)
Closes numpy#25743, reverts numpy#23536 Removing the ability to use start as a kwarg in np.arange(start=3, stop=5) breaks too much even for a 2.0 release. I still am a bit confused about the motivation for the change, was it for typing or automatic signature parsing? Note that np.arange(start=3) raises, and np.arange(stop=5) assumes start=0`. At some point we may wish to revisit this and remove any use of kwargs, but that would require a long deprecation period. Edit: any use of kwargs _for start, stop, step
1 parent adaa8c0 commit 3d4aed3

File tree

4 files changed

+3
-18
lines changed

4 files changed

+3
-18
lines changed

doc/source/release/2.0.0-notes.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,6 @@ environment variables to interact with ``meson``. `Native files
310310

311311
(`gh-25193 <https://github.com/numpy/numpy/pull/25193>`__)
312312

313-
``arange``'s ``start`` argument is positional-only
314-
--------------------------------------------------
315-
The first argument of ``arange`` is now positional only. This way,
316-
specifying a ``start`` argument as a keyword, e.g. ``arange(start=0, stop=4)``,
317-
raises a TypeError. Other behaviors, are unchanged so ``arange(stop=4)``,
318-
``arange(2, stop=4)`` and so on, are still valid and have the same meaning as
319-
before.
320-
321-
(`gh-25336 <https://github.com/numpy/numpy/pull/25336>`__)
322-
323313

324314
C API changes
325315
=============

numpy/_core/_add_newdocs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@
16981698

16991699
add_newdoc('numpy._core.multiarray', 'arange',
17001700
"""
1701-
arange(start, / [, stop[, step,], dtype=None, *, device=None,, like=None)
1701+
arange([start,] stop[, step,], dtype=None, *, device=None, like=None)
17021702
17031703
Return evenly spaced values within a given interval.
17041704

numpy/_core/src/multiarray/multiarraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ array_arange(PyObject *NPY_UNUSED(ignored),
30683068
NPY_PREPARE_ARGPARSER;
30693069

30703070
if (npy_parse_arguments("arange", args, len_args, kwnames,
3071-
"|", NULL, &o_start,
3071+
"|start", NULL, &o_start,
30723072
"|stop", NULL, &o_stop,
30733073
"|step", NULL, &o_step,
30743074
"|dtype", &PyArray_DescrConverter2, &typecode,

numpy/_core/tests/test_multiarray.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9471,14 +9471,9 @@ def test_require_range(self):
94719471
assert_raises(TypeError, np.arange, start=4)
94729472

94739473
def test_start_stop_kwarg(self):
9474-
with pytest.raises(TypeError):
9475-
# Start cannot be passed as a kwarg anymore, because on it's own
9476-
# it would be strange.
9477-
np.arange(start=0, stop=3)
9478-
94799474
keyword_stop = np.arange(stop=3)
94809475
keyword_zerotostop = np.arange(0, stop=3)
9481-
keyword_start_stop = np.arange(3, stop=9)
9476+
keyword_start_stop = np.arange(start=3, stop=9)
94829477

94839478
assert len(keyword_stop) == 3
94849479
assert len(keyword_zerotostop) == 3

0 commit comments

Comments
 (0)