arange

Contents

arange#

class saiunit.math.arange(start=None, stop=None, step=None, dtype=None)#

Return evenly spaced values within a given interval.

Values are generated within the half-open interval [start, stop) (in other words, the interval including start but excluding stop). All of start, stop, and step must share the same unit when any of them is a Quantity.

Parameters:
  • start (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Start of the interval (inclusive). The default start value is 0.

  • stop (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity | None) – End of the interval (exclusive).

  • step (Array | ndarray | bool | number | bool | int | float | complex | saiunit.Quantity | None) – Spacing between values. The default step size is 1.

  • dtype (str | type[Any] | dtype | SupportsDType | None) – The type of the output array. If not given, the dtype is inferred from the other input arguments.

Returns:

out – Array of evenly spaced values.

Return type:

saiunit.Quantity | Array

Raises:

UnitMismatchError – If start, stop, and step do not share the same unit.

Examples

>>> import saiunit as u
>>> u.math.arange(5)
Array([0, 1, 2, 3, 4], dtype=int32)
>>> u.math.arange(0 * u.meter, 3 * u.meter, 1 * u.meter)
Quantity([0 1 2], "m")