Efficient NumPy sliding window function
Few suggestions:

Input validation: there is no input validation for win_size and padding. If win_size is -3 the exception says ValueError: Stride must satisfy 0 &lt; stride &lt;= -3.. If padding is a string, numpy throws an exception.

Type hints: consider adding typing to provide more info to the caller.

f-Strings: depending on the version of Python you use, the exception message can be slightly simplified.
From:
if not (0 &lt; stride &lt;= win_size):
    fmt = 'Stride must satisfy 0 &lt; stride &lt;= %d.'
    raise ValueError(fmt % win_size)

To:
if not 0 &lt; stride &lt;= win_size:
    raise ValueError(f'Stride must satisfy 0 &lt; stride &lt;= {win_size}.')


Duplication: the statement shape = n_windows, win_size seems duplicated and can be simplified.
From:
if padding is not None:
    n_windows = ceil(n_elems / stride)
    shape = n_windows, win_size
    A = np.pad(A, (0, n_windows * win_size - n_elems),
             constant_values = padding)
else:
    n_windows = floor(n_elems / stride)
    shape = n_windows, win_size

To:
if padding is not None:
    n_windows = ceil(n_elems / stride)
    A = np.pad(A, (0, n_windows * win_size - n_elems),
                   constant_values=padding)
else:
    n_windows = floor(n_elems / stride)
shape = n_windows, win_size


Warning: FYI on the doc of np.lib.stride_tricks.as_strided there is a warning that says This function has to be used with extreme care, see notes.. Not sure if it applies to your use case but consider checking it out.