by
Changes to 2 files · Browse files at 2b42738f1e42 Showing diff from parent ca5df3b8912a 7d017d34af8c Diff from another changeset...
@@ -66,6 +66,14 @@ for d in (0, SECS_PER_DAY, 365 * SECS_PER_DAY):
assert_equals('#ffd4d4', cm.get_color(fakectx(0, d), d + age))
+def test_negative_age_calc():
+ cm = colormap.AnnotateColorSaturation()
+ assert_equals('#ffaaaa', cm.get_color(fakectx(0, 0), 0), '0 days old')
+ assert_equals('#ffaaaa', cm.get_color(fakectx(0, 50 * SECS_PER_DAY), 0),
+ '-50 days old (should not raise ZeroDivisionError)')
+ assert_equals('#ffaaaa', cm.get_color(fakectx(0, 100 * SECS_PER_DAY), 0),
+ '-100 days old')
+
def test_makeannotatepalette_latest_wins():
userstep = sys.maxint / 16
filectxs = [fakectx(0 * userstep, 0), fakectx(1 * userstep, 1),
|
@@ -102,7 +102,7 @@ return _rescale(angle, 360.0 / self._maxhues)
def get_color(self, ctx, now):
- days = _days(ctx, now)
+ days = max(_days(ctx, now), 0.0)
saturation = 255/((days/50) + 1)
if self._maxsaturations:
saturation = _rescaleceil(saturation, 255. / self._maxsaturations)
|
Loading...