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 (
Union[saiunit.Quantity,Array,ndarray,number,bool]) – The starting value of the sequence.stop (
Union[saiunit.Quantity,Array,ndarray,number,bool]) – 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 (
Optional[bool]) – IfTrue,stopis the last sample. Otherwise, it is not included. Default isTrue.retstep (
Optional[bool]) – IfTrue, return(samples, step), wherestepis the spacing between samples.dtype (
Union[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:
Union[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")