@@ -169,7 +169,7 @@ def get_header(self):
169
169
170
170
def get_burndown_parameters (self ):
171
171
header = self .data ["Burndown" ]
172
- return header ["sampling" ], header ["granularity" ]
172
+ return header ["sampling" ], header ["granularity" ], header [ "tick_size" ]
173
173
174
174
def get_project_burndown (self ):
175
175
return self .data ["hercules" ]["repository" ], \
@@ -300,7 +300,7 @@ def get_header(self):
300
300
301
301
def get_burndown_parameters (self ):
302
302
burndown = self .contents ["Burndown" ]
303
- return burndown .sampling , burndown .granularity
303
+ return burndown .sampling , burndown .granularity , burndown . tick_size / 1000000000
304
304
305
305
def get_project_burndown (self ):
306
306
return self ._parse_burndown_matrix (self .contents ["Burndown" ].project )
@@ -605,19 +605,23 @@ def import_pandas():
605
605
return pandas
606
606
607
607
608
+ def floor_datetime (dt , duration ):
609
+ return datetime .fromtimestamp (dt .timestamp () - dt .timestamp () % duration )
610
+
611
+
608
612
def load_burndown (header , name , matrix , resample , report_survival = True ):
609
613
pandas = import_pandas ()
610
614
611
- start , last , sampling , granularity = header
615
+ start , last , sampling , granularity , tick = header
612
616
assert sampling > 0
613
617
assert granularity > 0
614
- start = datetime .fromtimestamp (start )
618
+ start = floor_datetime ( datetime .fromtimestamp (start ), tick )
615
619
last = datetime .fromtimestamp (last )
616
620
if report_survival :
617
621
kmf = fit_kaplan_meier (matrix )
618
622
if kmf is not None :
619
623
print_survival_function (kmf , sampling )
620
- finish = start + timedelta (days = matrix .shape [1 ] * sampling )
624
+ finish = start + timedelta (seconds = matrix .shape [1 ] * sampling * tick )
621
625
if resample not in ("no" , "raw" ):
622
626
print ("resampling to %s, please wait..." % resample )
623
627
# Interpolate the day x day matrix.
@@ -670,31 +674,32 @@ def load_burndown(header, name, matrix, resample, report_survival=True):
670
674
labels = [dt .date () for dt in date_granularity_sampling ]
671
675
else :
672
676
labels = [
673
- "%s - %s" % ((start + timedelta (days = i * granularity )).date (),
677
+ "%s - %s" % ((start + timedelta (seconds = i * granularity * tick )).date (),
674
678
(
675
- start + timedelta (days = (i + 1 ) * granularity )).date ())
679
+ start + timedelta (seconds = (i + 1 ) * granularity * tick )).date ())
676
680
for i in range (matrix .shape [0 ])]
677
681
if len (labels ) > 18 :
678
682
warnings .warn ("Too many labels - consider resampling." )
679
683
resample = "M" # fake resampling type is checked while plotting
680
684
date_range_sampling = pandas .date_range (
681
- start + timedelta (days = sampling ), periods = matrix .shape [1 ],
685
+ start + timedelta (seconds = sampling * tick ), periods = matrix .shape [1 ],
682
686
freq = "%dD" % sampling )
683
687
return name , matrix , date_range_sampling , labels , granularity , sampling , resample
684
688
685
689
686
690
def load_ownership (header , sequence , contents , max_people ):
687
691
pandas = import_pandas ()
688
692
689
- start , last , sampling , _ = header
693
+ start , last , sampling , _ , tick = header
690
694
start = datetime .fromtimestamp (start )
695
+ start = floor_datetime (start , tick )
691
696
last = datetime .fromtimestamp (last )
692
697
people = []
693
698
for name in sequence :
694
699
people .append (contents [name ].sum (axis = 1 ))
695
700
people = numpy .array (people )
696
701
date_range_sampling = pandas .date_range (
697
- start + timedelta (days = sampling ), periods = people [0 ].shape [0 ],
702
+ start + timedelta (seconds = sampling * tick ), periods = people [0 ].shape [0 ],
698
703
freq = "%dD" % sampling )
699
704
700
705
if people .shape [0 ] > max_people :
0 commit comments