MCPcopy Create free account
hub / github.com/Yasoz/DiffTraj / time_warping

Function time_warping

utils/utils.py:26–36  ·  view source on GitHub ↗

Resamples a trajectory to a new length.

(x, length=200)

Source from the content-addressed store, hash-verified

24
25
26def time_warping(x, length=200):
27 """
28 Resamples a trajectory to a new length.
29 """
30 len_x = len(x)
31 time_steps = np.arange(length) * (len_x - 1) / (length - 1)
32 x = x.T
33 warped_trajectory = np.zeros((2, length))
34 for i in range(2):
35 warped_trajectory[i] = np.interp(time_steps, np.arange(len_x), x[i])
36 return warped_trajectory.T
37
38
39def gather(consts: torch.Tensor, t: torch.Tensor):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected