+ (raw_histo_log, min_timestamp_ms, max_timestamp_ms) = parse_hist_file(self.fn, 4, None)
+ self.A(min_timestamp_ms == 0 and max_timestamp_ms == 100)
+ aligned_log = align_histo_log(raw_histo_log, 5, 4, min_timestamp_ms, max_timestamp_ms)
+ self.A(len(aligned_log) == 1)
+ (time_ms0, h) = aligned_log[0]
+ self.A(time_ms0 == 0 and h == [1., 2., 3., 4.])
+
+ # handle case with log_unix_epoch=1 timestamps, 1-second time quantum
+ # here both records will be separated into 2 aligned intervals
+
+ def test_d1a_align_2rec_histo_log_epoch_1_quantum_1sec(self):
+ with open(self.fn, 'w') as f:
+ f.write('1536504002123, 1, 4096, 1, 2, 3, 4\n')
+ f.write('1536504003123, 1, 4096, 4, 3, 2, 1\n')
+ (raw_histo_log, min_timestamp_ms, max_timestamp_ms) = parse_hist_file(self.fn, 4, None)
+ self.A(min_timestamp_ms == 1536504001123 and max_timestamp_ms == 1536504003123)
+ aligned_log = align_histo_log(raw_histo_log, 1, 4, min_timestamp_ms, max_timestamp_ms)
+ self.A(len(aligned_log) == 3)
+ (time_ms0, h) = aligned_log[0]
+ self.A(time_ms0 == 1536504001123 and h == [0., 0., 0., 0.])
+ (time_ms1, h) = aligned_log[1]
+ self.A(time_ms1 == 1536504002123 and h == [1., 2., 3., 4.])
+ (time_ms2, h) = aligned_log[2]
+ self.A(time_ms2 == 1536504003123 and h == [4., 3., 2., 1.])
+
+ # handle case with log_unix_epoch=1 timestamps, 5-second time quantum
+ # here both records will be merged into a single aligned time interval
+
+ def test_d1b_align_2rec_histo_log_epoch_1_quantum_5sec(self):
+ with open(self.fn, 'w') as f:
+ f.write('1536504002123, 1, 4096, 1, 2, 3, 4\n')
+ f.write('1536504003123, 1, 4096, 4, 3, 2, 1\n')
+ (raw_histo_log, min_timestamp_ms, max_timestamp_ms) = parse_hist_file(self.fn, 4, None)
+ self.A(min_timestamp_ms == 1536504001123 and max_timestamp_ms == 1536504003123)
+ aligned_log = align_histo_log(raw_histo_log, 5, 4, min_timestamp_ms, max_timestamp_ms)