scipp.linspace#

scipp.linspace(dim, start, stop, num, *, endpoint=True, unit=<automatically deduced unit>, dtype=None)#

Constructs a Variable with num evenly spaced samples, calculated over the interval [start, stop].

Parameters
  • dim (str) – Dimension label.

  • start (TypeVar(NumberOrVar, Union[int, float], Variable)) – The starting value of the sequence.

  • stop (TypeVar(NumberOrVar, Union[int, float], Variable)) – The end value of the sequence.

  • num (int) – Number of samples to generate.

  • endpoint (bool, default: True) – If True, step is the last returned value. Otherwise, it is not included.

  • unit (Union[Unit, str, None], default: <automatically deduced unit>) – Unit of contents.

  • dtype (scipp.typing.DTypeLike) – Type of underlying data. By default, inferred from value argument.

Returns

Variable – A variable of evenly spaced values.

Examples

>>> sc.linspace('x', 2.0, 4.0, num=4)
<scipp.Variable> (x: 4)    float64  [dimensionless]  [2, 2.66667, 3.33333, 4]
>>> sc.linspace('x', 2.0, 4.0, num=4, endpoint=False)
<scipp.Variable> (x: 4)    float64  [dimensionless]  [2, 2.5, 3, 3.5]
>>> sc.linspace('x', 1.5, 3.0, num=4, unit='m')
<scipp.Variable> (x: 4)    float64              [m]  [1.5, 2, 2.5, 3]