linspace

compas.itertools.linspace(start, stop, num=50)[source]

Generate a sequence of evenly spaced numbers over a specified interval.

Parameters:
startfloat

The start value of the sequence.

stopfloat

The end value of the sequence.

numint

The number of elements in the sequence.

Yields:
float

The next value in the sequence.

Raises:
ValueError

If the number of elements is less than 2.

References

This function mimicks the functionality of numpy.linspace [1], but in a simpler form.

Examples

>>> from compas.itertools import linspace
>>> list(linspace(0, 1, 3))
[0.0, 0.5, 1.0]