vak.transforms.functional.pad_to_window#

vak.transforms.functional.pad_to_window(arr, window_size, padval=0.0, return_padding_mask=True)[source]#

pad a 1d or 2d array so that it can be reshaped into consecutive windows of specified size

Parameters:
  • arr (numpy.ndarray) – with 1 or 2 dimensions, e.g. a vector of labeled timebins or a spectrogram.

  • window_size (int) – width of window in number of elements.

  • padval (float) – value to pad with. Added to end of array, the β€œright side” if 2-dimensional.

  • return_padding_mask (bool) – if True, return a boolean vector to use for cropping back down to size before padding. padding_mask has size equal to width of padded array, i.e. original size plus padding at the end, and has values of 1 where columns in padded are from the original array, and values of 0 where columns were added for padding.

Returns:

  • padded (numpy.ndarray) – Padded with padval

  • padding_mask (numpy.ndarray) – Boolean vector with size equal to width of padded, i.e. original size plus padding at the end. Has values of True where columns in padded are from the original array, and values of False where columns were added for padding. Only returned if return_padding_mask is True.