Return evenly spaced values from `start` to `stop` with step size `step`. The values are half-open [start, stop), so including start and excluding stop. This is basically the same as python's range function but for dask arrays. When using a non-integer step, such as 0.1, the r
(start=None, /, stop=None, step=1, *, chunks="auto", like=None, dtype=None)
| 383 | |
| 384 | @array_creation_dispatch.register_inplace("numpy") |
| 385 | def arange(start=None, /, stop=None, step=1, *, chunks="auto", like=None, dtype=None): |
| 386 | """ |
| 387 | Return evenly spaced values from `start` to `stop` with step size `step`. |
| 388 | |
| 389 | The values are half-open [start, stop), so including start and excluding |
| 390 | stop. This is basically the same as python's range function but for dask |
| 391 | arrays. |
| 392 | |
| 393 | When using a non-integer step, such as 0.1, the results will often not be |
| 394 | consistent. It is better to use linspace for these cases. |
| 395 | |
| 396 | Parameters |
| 397 | ---------- |
| 398 | start : int | float, optional |
| 399 | If ``stop`` is specified, the start of interval (inclusive); otherwise, the end |
| 400 | of the interval (exclusive). Default: 0 when ``stop`` is specified. |
| 401 | stop : int | float |
| 402 | The end of the interval (exclusive). |
| 403 | step : int | float, optional |
| 404 | The distance between two adjacent elements ``(out[i+1] - out[i])``. |
| 405 | Must not be 0; may be negative, this results in an empty array if stop >= start. |
| 406 | Default: 1. |
| 407 | chunks : int |
| 408 | The number of samples on each block. Note that the last block will have |
| 409 | fewer samples if ``len(array) % chunks != 0``. |
| 410 | Defaults to "auto" which will automatically determine chunk sizes. |
| 411 | dtype : numpy.dtype |
| 412 | Output dtype. Omit to infer it from start, stop, step |
| 413 | Defaults to ``None``. |
| 414 | like : array type or ``None`` |
| 415 | Array to extract meta from. Defaults to ``None``. |
| 416 | |
| 417 | Returns |
| 418 | ------- |
| 419 | samples : dask array |
| 420 | |
| 421 | See Also |
| 422 | -------- |
| 423 | dask.array.linspace |
| 424 | """ |
| 425 | if start is None and stop is None: |
| 426 | raise TypeError("arange() requires stop to be specified.") |
| 427 | elif start is None: |
| 428 | start = 0 |
| 429 | elif stop is None: |
| 430 | start, stop = 0, start |
| 431 | |
| 432 | # Avoid loss of precision calculating blockstart and blockstop below |
| 433 | # when start is a very large int (~2**63) and step is a small float |
| 434 | if start != 0 and not np.isclose(start + step - start, step, atol=0): |
| 435 | r = arange(0, stop - start, step, chunks=chunks, dtype=dtype, like=like) |
| 436 | return r + start |
| 437 | |
| 438 | num = int(max(np.ceil((stop - start) / step), 0)) |
| 439 | |
| 440 | meta = meta_from_array(like) if like is not None else None |
| 441 | |
| 442 | if dtype is None: |
no test coverage detected
searching dependent graphs…