Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functionally equivalent output, but much faster, see example below: In [16]: from scipy.spatial.distance import cdist In [17]: import numpy as np In [18]: x = [12,13,15,16,17]*10 In [19]: x_re = np.lib.stride_tricks.sliding_window_view(x, window_shape=2) In [20]: %timeit np.max(np.abs(x_re[:, np.newaxis] - x_re[np.newaxis, :]), axis=2) ...: 62.9 μs ± 660 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each) In [21]: %timeit cdist(x_re, x_re, metric="chebyshev") 5.58 μs ± 19.8 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
- Loading branch information