aspcore.matrices.to_length

aspcore.matrices.to_length(ar, length, axis=-1)

Either truncates or pads ar at the end with zeros, so that the length along axis is equal to length.

Parameters:
  • ar (ndarray) – array to be truncated or padded

  • length (int) – length of the array along axis after truncation or padding

  • axis (int) – axis along which to truncate or pad

Returns:

ar

Return type:

ndarray