Exemple #1
0
 def test_widths(self):
     fmt = TimeFormatter()
     scale = TimeScale(minutes = 5)
     test_intervals = ([(2005,3,15,10,30), (2005,3,15,10,50), 50],
                       )
     print
     for start, end, width in test_intervals:
         est_width = scale.label_width(DTS(*start), DTS(*end), char_width=width)
         print start, end,
         print " avail:", width, "est:", est_width[1], "numlabels:", est_width[0]
     return
 def test_none_time(self):
     testee = TimeFormatter(None, 59)
     self.assertEqual("--:--", testee.format())
     testee = TimeFormatter(23, None)
     self.assertEqual("--:--", testee.format())
     testee = TimeFormatter(None, None)
     self.assertEqual("--:--", testee.format())
Exemple #3
0
    def test_labels(self):
        fmt = TimeFormatter()
        scale = ScaleSystem(*HMSScales)

        test_intervals = ([(2005,3,15,10,30), (2005,3,15,10,50), 150],
                          )
        print
        for start, end, width in test_intervals:
            labels = scale.labels(DTS(*start), DTS(*end), char_width=width)
            print start, end, " avail:", width,
            print " used:", sum([len(x[1]) for x in labels]),
            print labels
        return
Exemple #4
0
 def __init__(self, **kw_interval):
     """ Defines the time period that this scale uses.
     """
     self.formatter = kw_interval.pop("formatter", TimeFormatter())
     unit, val = kw_interval.items()[0]
     self.unit = unit
     if "_of_" in unit:
         # Calendar time interval - divide by the number of ticks per larger
         # unit of time to get an average resolution
         if type(val) in (int, float):
             val = [val]
         self.vals = val
         self.resolution = self.SECS_PER_UNIT[unit] / float(len(val))
     else:
         self.val = val
         self.resolution = val * self.SECS_PER_UNIT[unit]
     return
 def test_non_none_time(self):
     testee = TimeFormatter(23, 59)
     self.assertEqual("23:59", testee.format())