Closed
Description
It makes sense to require positional only arguments for functions like add()
where there are no meaningful names, and likewise to require keyword arguments for true options.
However, this is less useful for most creation and manipulation functions. For example, arange
currently has the signature arange(start, /, *, stop=None, step=1, dtype=None)
, but readable code could pass both start
and stop
as either positional or keyword arguments, e.g., np.arange(start, stop)
and np.arange(start=0, stop=10)
.
I would suggest revisiting all of these functions and allowing arguments to be positional and keyword based when appropriate. Here are my suggestions off-hand:
arange(start, /, *, stop=None, step=1, dtype=None)
->arange(start, stop=None, *, step=1, dtype=None)
empty(shape, /, *, dtype=None)
->empty(shape, dtype=None)
full(shape, fill_value, /, *, dtype=None)
->full(shape, fill_value, *, dtype=None)
linspace(start, stop, num, /, *, dtype=None, endpoint=True)
->linspace(start, stop, num, *, dtype=None, endpoint=True)
ones
andzeros
should matchempty
expand_dims(x, axis, /)
->expand_dims(x, /, axis)
or evenexpand_dims(x, /, *, axis)
to match other manipulation functionsreshape(x, shape, /)
->reshape(x, /, shape)
roll(x, shift, /, *, axis=None)
->roll(x, /, shift, *, axis=None)
Metadata
Metadata
Assignees
Labels
No labels