Skip to content

Commit 1a3c4cd

Browse files
support for cumulative time
1 parent e615453 commit 1a3c4cd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Core/CDataSampler.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
import Core.CDataSampler_utils as DSUtils
77

88
class CDataSampler:
9-
def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0):
9+
def __init__(self, storage, batch_size, minFrames, defaults={}, maxT=1.0, cumulative_time=True):
10+
'''
11+
If cumulative_time is True, then time is a cumulative time from the start of the trajectory i.e. [0, 0.1, 0.2, 0.3, ...]
12+
If cumulative_time is False, then time is a time delta between frames i.e. [0, 0.1, 0.1, 0.1, ...]
13+
'''
1014
self._storage = storage
1115
self._defaults = defaults
1216
self._batchSize = batch_size
1317
self._maxT = maxT
1418
self._minFrames = minFrames
1519
self._samples = []
1620
self._currentSample = None
21+
self._cumulative_time = cumulative_time
1722
return
1823

1924
def reset(self):
@@ -118,6 +123,9 @@ def _prepareT(self, res):
118123
pass
119124
T = np.insert(T, 0, 0.0)
120125
assert len(res) == len(T)
126+
# T is an array of time deltas like [0, 0.1, 0.1, 0.1, ...], convert it to cumulative time
127+
if self._cumulative_time:
128+
T = np.cumsum(T)
121129
return T
122130

123131
def _framesFor(self, mainInd, samples, steps, stepsSampling):

0 commit comments

Comments
 (0)