linspace#
- class brainunit.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|number|bool) – The starting value of the sequence.stop (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 (
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.
- Return type:
saiunit.Quantity |
Array|Tuple[saiunit.Quantity |Array, saiunit.Quantity |Array]- Returns:
samples (Quantity or Array) –
numequally spaced samples in the closed interval[start, stop]or the half-open interval[start, stop).step (Quantity or Array) – Only returned if
retstepisTrue: size of spacing between samples.
- 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")