extend

mdtools.numpy_helper_functions.extend(a, length, axis=- 1, fill_value=0)[source]

Extend an axis of an array to a given length by padding a given value at the end of the axis.

Parameters
  • a (array_like) – The array to extend.

  • length (int) – The desired length of a.

  • axis (int, optional) – The axis to extend. Default: last axis

  • fill_value (scalar, optional) – The fill value to use to extend the given axis of a to the desired length. Note that you might have to change the data type of the input array to fit the type of fill_value before parsing the array to this function.

Returns

a_new – A copy of the input array with the given axis padded with fill_value in such a wax that it has the desired length. If the given axis already had the desired length or is even longer, just the input array is returned.

Return type

numpy.ndarray