def test_normalize_base(self, env, status, base): key = ('aseo0', 296750, 'MOVE') stream = status[key] result = sas.normalize_base(base, stream._interval) assert result == base stream.set_interval(off.Day()) result = sas.normalize_base(base, stream._interval) expected = pd.Timestamp( datetime.datetime(base.year, base.month, base.day)) assert result == expected stream.set_interval(off.Hour()) result = sas.normalize_base(base, stream._interval) expected = pd.Timestamp( datetime.datetime(base.year, base.month, base.day, base.hour)) assert result == expected
def _timestamps_from_iter(base, offset_mark, offset): normalized_base = sas.normalize_base(base, offset) year = normalized_base.year month = normalized_base.month day = normalized_base.day hour = normalized_base.hour normalized_list = [] for i, mark in enumerate(offset_mark): if isinstance(offset, off.Day): normalized_list.append( pd.Timestamp(datetime.datetime(year, month, mark))) elif isinstance(offset, off.Hour): if i > 0 and offset_mark[i - 1] > mark: day = day + 1 normalized_list.append( pd.Timestamp(datetime.datetime(year, month, day, mark))) elif isinstance(offset, off.Minute): normalized_list.append( datetime.datetime(pd.Timestamp(year, month, day, hour, mark))) return normalized_list