r86283 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86282‎ | r86283 | r86284 >
Date:21:08, 17 April 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
added time list processing from compute_confidence.py. Any handling of timestamps should exist in TimestampProcessor.
Modified paths:
  • /trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py (modified) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
@@ -402,3 +402,82 @@
403403
404404 return new_timestamp
405405
 406+"""
 407+
 408+ THIS METHOD IS CURRENTLY COUPLED WITH HYPOTHESIS TEST
 409+
 410+ This method takes a start time and endtime and interval length and produces
 411+ a list of timestamps corresponding to each time spaced by length 'interval'
 412+ between the start time and the end time inclusive
 413+
 414+ INPUT:
 415+ num_samples - number of samples per test interval
 416+ interval - intervals at which samples are drawn within the range, units = minutes
 417+ start_time - start timestamp 'yyyymmddhhmmss'
 418+ end_time - end timestamp 'yyyymmddhhmmss'
 419+ format - !! CURRENTLY UNUSED !! specifies timestamp format
 420+
 421+ RETURN:
 422+
 423+ times - list of timestamps for each sample
 424+ time_indices - list of indices counting from zero marking the indices for reporting test interval parameters
 425+
 426+"""
 427+def get_time_lists(self, start_time, end_time, interval, num_samples, format):
 428+
 429+ """ range must be divisible by interval - convert to hours """
 430+ range = float(interval * num_samples) / 60
 431+
 432+ """ Compose times """
 433+ start_datetime = dt.datetime(int(start_time[0:4]), int(start_time[4:6]), int(start_time[6:8]), int(start_time[8:10]), int(start_time[10:12]), int(start_time[12:14]))
 434+ end_datetime = dt.datetime(int(end_time[0:4]), int(end_time[4:6]), int(end_time[6:8]), int(end_time[8:10]), int(end_time[10:12]), int(end_time[12:14]))
 435+
 436+ """ current timestamp and hour index """
 437+ curr_datetime = start_datetime
 438+ curr_timestamp = start_time
 439+ curr_hour_index = 0.0
 440+
 441+ """ lists to store timestamps and indices """
 442+ times = []
 443+ time_indices = []
 444+
 445+ sample_count = 1
 446+
 447+ """ build a list of timestamps and time indices for plotting increment the time """
 448+ while curr_datetime < end_datetime:
 449+
 450+ """ for timestamp formatting """
 451+ month_str_fill = ''
 452+ day_str_fill = ''
 453+ hour_str_fill = ''
 454+ minute_str_fill = ''
 455+ if curr_datetime.month < 10:
 456+ month_str_fill = '0'
 457+ if curr_datetime.day < 10:
 458+ month_str_fill = '0'
 459+ if curr_datetime.hour < 10:
 460+ hour_str_fill = '0'
 461+ if curr_datetime.minute < 10:
 462+ minute_str_fill = '0'
 463+
 464+ curr_timestamp = str(curr_datetime.year) + month_str_fill + str(curr_datetime.month) + day_str_fill + str(curr_datetime.day) + hour_str_fill+ str(curr_datetime.hour) + minute_str_fill+ str(curr_datetime.minute) + '00'
 465+ times.append(curr_timestamp)
 466+
 467+ """ increment curr_hour_index if the """
 468+ if sample_count == num_samples:
 469+
 470+ time_indices.append(curr_hour_index + range / 2)
 471+ curr_hour_index = curr_hour_index + range
 472+ sample_count = 1
 473+ else:
 474+ sample_count = sample_count + 1
 475+
 476+
 477+ """ increment the time by interval minutes """
 478+ td = dt.timedelta(minutes=interval)
 479+ curr_datetime = curr_datetime + td
 480+
 481+ """ append the last items onto time lists """
 482+ times.append(end_time)
 483+
 484+ return [times, time_indices]
\ No newline at end of file

Status & tagging log