arange¶
- arange(start: int | float, /, stop: int | float | None = None, step: int | float = 1, *, dtype: dtype | None = None, device: device | None = None) array ¶
Returns evenly spaced values within the half-open interval
[start, stop)
as a one-dimensional array.- Parameters:
start (Union[int, float]) – if
stop
is specified, the start of interval (inclusive); otherwise, the end of the interval (exclusive). Ifstop
is not specified, the default starting value is0
.stop (Optional[Union[int, float]]) – the end of the interval. Default:
None
.step (Union[int, float]) – the distance between two adjacent elements (
out[i+1] - out[i]
). Must not be0
; may be negative, this results in an empty array ifstop >= start
. Default:1
.dtype (Optional[dtype]) – output array data type. If
dtype
isNone
, the output array data type must be inferred fromstart
,stop
andstep
. If those are all integers, the output array dtype must be the default integer dtype; if one or more have typefloat
, then the output array dtype must be the default real-valued floating-point data type. Default:None
.device (Optional[device]) – device on which to place the created array. Default:
None
.
Note
This function cannot guarantee that the interval does not include the
stop
value in those cases wherestep
is not an integer and floating-point rounding errors affect the length of the output array.- Returns:
out (array) – a one-dimensional array containing evenly spaced values. The length of the output array must be
ceil((stop-start)/step)
ifstop - start
andstep
have the same sign, and length0
otherwise.