本文整理汇总了Python中dataset.DataSet.set方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.set方法的具体用法?Python DataSet.set怎么用?Python DataSet.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _trim_data
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import set [as 别名]
def _trim_data(self, extension_fraction=None, max_interval=None):
"""
Toss out data outside of (extended) view range, and closer than max_interval seconds apart.
"""
if extension_fraction is None:
start_stamp = self._start_stamp
end_stamp = self._end_stamp
else:
extension = rospy.Duration((self._end_stamp - self._start_stamp).to_sec() * extension_fraction)
if extension.to_sec() >= self._start_stamp.to_sec():
start_stamp = rospy.Time(0, 1)
else:
start_stamp = self._start_stamp - extension
end_stamp = self._end_stamp + extension
min_x = (start_stamp - self._timeline.start_stamp).to_sec()
max_x = (end_stamp - self._timeline.start_stamp).to_sec()
for series in list(self._data.keys()):
points = self._data[series].points
num_points = len(points)
trimmed_points = []
if num_points > 0 and points[0][0] < max_x and points[-1][0] > min_x:
first_index = None
last_x = None
for i, (x, y) in enumerate(points):
if x >= min_x:
trimmed_points.append((x, y))
first_index = i
last_x = x
break
if first_index is not None:
for i, (x, y) in enumerate(points[first_index + 1:]):
if x > max_x:
break
if (max_interval is None) or (x - last_x >= max_interval):
trimmed_points.append((x, y))
last_x = x
new_data = DataSet()
new_data.set(trimmed_points)
self._data[series] = new_data