linspace#
- class saiunit.math.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None)#
Return evenly spaced numbers over a specified interval.
Returns
numevenly spaced samples, calculated over the interval[start, stop]. The endpoint of the interval can optionally be excluded.- Parameters:
start (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – The starting value of the sequence.stop (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – The end value of the sequence. Must have the same unit asstartwhen either is aQuantity.num (
int) – Number of samples to generate. Default is 50.endpoint (
bool|None) – IfTrue,stopis the last sample. Otherwise, it is not included. Default isTrue.retstep (
bool|None) – IfTrue, return(samples, step), wherestepis the spacing between samples.dtype (
str|type[Any] |dtype|SupportsDType|None) – The type of the output array.
- Returns:
samples –
numequally spaced samples in the closed interval[start, stop]or the half-open interval[start, stop).- Return type:
saiunit.Quantity |
Array- Raises:
UnitMismatchError – If
startandstopdo not share the same unit.
Examples
>>> import saiunit as u >>> u.math.linspace(0, 10, 5) Array([ 0. , 2.5, 5. , 7.5, 10. ], dtype=float32) >>> u.math.linspace(0 * u.meter, 10 * u.meter, 5) Quantity([ 0. 2.5 5. 7.5 10. ], "m")