linspace

kgpy.linspace(start, stop, num, axis=0)

A modified version of numpy.linspace() that returns a value in the center of the range between start and stop if num == 1 unlike numpy.linspace() which would just return start. This function is often helfpul when creating a grid. Sometimes you want to test with only a single element, but you want that element to be in the center of the range and not off to one side.

Parameters:
  • start (numpy.ndarray) – The starting value of the sequence.

  • stop (numpy.ndarray) – The end value of the sequence, must be broadcastable with start.

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

  • axis (int) – The axis in the result used to store the samples. The default is the first axis.

Return type:

typing.Union[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[typing.Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[typing.Union[bool, int, float, complex, str, bytes]]]

Returns:

An array the size of the broadcasted shape of start and stop with an additional dimension of length num.