Beispiel #1
0
def test_makeannotatepalette_mindate_earlier_than_rev0():
    agestep = 50 * SECS_PER_DAY
    filectxs = [fakectx(0, 1 * agestep), fakectx(0, 2 * agestep)]
    palette = colormap.makeannotatepalette(
        filectxs, now=2 * agestep, maxcolors=1, maxhues=1, maxsaturations=255, mindate=0
    )
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    for fctx in filectxs:
        assert fctx in palfctxs
Beispiel #2
0
def test_makeannotatepalette_fold_same_color():
    userstep = sys.maxint / 16
    filectxs = [fakectx(0 * userstep, 0), fakectx(1 * userstep, 0),
                fakectx(2 * userstep, 0), fakectx(3 * userstep, 0),
                fakectx(4 * userstep, 0)]
    palette = colormap.makeannotatepalette(filectxs, now=0,
                                           maxcolors=4, maxhues=8)
    assert_equals(2, len(palette))
    assert_equals(set([filectxs[0], filectxs[1], filectxs[2]]),
                  set(palette['#ffaaaa']))
    assert_equals(set([filectxs[3], filectxs[4]]), set(palette['#ffaae9']))
Beispiel #3
0
def test_makeannotatepalette_latest_wins():
    userstep = sys.maxint / 16
    filectxs = [fakectx(0 * userstep, 0), fakectx(1 * userstep, 1),
                fakectx(2 * userstep, 2), fakectx(3 * userstep, 3),
                fakectx(4 * userstep, 4)]

    palette = colormap.makeannotatepalette(filectxs, now=4, maxcolors=4)
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    assert_equals(set(filectxs[1:]), palfctxs)
Beispiel #4
0
def test_makeannotatepalette_mindate_earlier_than_rev0():
    agestep = 50 * SECS_PER_DAY
    filectxs = [fakectx(0, 1 * agestep), fakectx(0, 2 * agestep)]
    palette = colormap.makeannotatepalette(filectxs,
                                           now=2 * agestep,
                                           maxcolors=1,
                                           maxhues=1,
                                           maxsaturations=255,
                                           mindate=0)
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    for fctx in filectxs:
        assert fctx in palfctxs
Beispiel #5
0
def test_makeannotatepalette_latest_wins():
    userstep = sys.maxint / 16
    filectxs = [
        fakectx(0 * userstep, 0),
        fakectx(1 * userstep, 1),
        fakectx(2 * userstep, 2),
        fakectx(3 * userstep, 3),
        fakectx(4 * userstep, 4)
    ]

    palette = colormap.makeannotatepalette(filectxs, now=4, maxcolors=4)
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    assert_equals(set(filectxs[1:]), palfctxs)
Beispiel #6
0
def test_makeannotatepalette_mindate_included():
    agestep = 10 * SECS_PER_DAY
    filectxs = [fakectx(0, 0 * agestep), fakectx(0, 1 * agestep),
                fakectx(0, 2 * agestep), fakectx(0, 3 * agestep),
                fakectx(0, 4 * agestep), fakectx(0, 5 * agestep),
                fakectx(0, 6 * agestep), fakectx(0, 7 * agestep)]
    palette = colormap.makeannotatepalette(filectxs, now=7 * agestep,
                                           maxcolors=4, maxhues=4,
                                           maxsaturations=255,
                                           mindate=2 * agestep)
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    for fctx in filectxs[2:]:
        assert fctx in palfctxs
Beispiel #7
0
def test_makeannotatepalette_fold_same_color():
    userstep = sys.maxint / 16
    filectxs = [
        fakectx(0 * userstep, 0),
        fakectx(1 * userstep, 0),
        fakectx(2 * userstep, 0),
        fakectx(3 * userstep, 0),
        fakectx(4 * userstep, 0)
    ]
    palette = colormap.makeannotatepalette(filectxs,
                                           now=0,
                                           maxcolors=4,
                                           maxhues=8)
    assert_equals(2, len(palette))
    assert_equals(set([filectxs[0], filectxs[1], filectxs[2]]),
                  set(palette['#ffaaaa']))
    assert_equals(set([filectxs[3], filectxs[4]]), set(palette['#ffaae9']))
Beispiel #8
0
    def _redefinemarkers(self):
        """Redefine line markers according to the current revs"""
        curdate = self.ctx.date()[0]

        # make sure to colorize at least 1 year
        mindate = curdate - 365 * 24 * 60 * 60

        self._revmarkers.clear()
        filectxs = iter(fctx for fctx, _origline in self._links)
        palette = colormap.makeannotatepalette(
            filectxs, curdate, maxcolors=32, maxhues=8, maxsaturations=16, mindate=mindate
        )
        for i, (color, fctxs) in enumerate(palette.iteritems()):
            self.markerDefine(qsci.Background, i)
            self.setMarkerBackgroundColor(QColor(color), i)
            for fctx in fctxs:
                self._revmarkers[fctx.rev()] = i
Beispiel #9
0
    def _redefinemarkers(self):
        """Redefine line markers according to the current revs"""
        curdate = self.ctx.date()[0]

        # make sure to colorize at least 1 year
        mindate = curdate - 365 * 24 * 60 * 60

        self._revmarkers.clear()
        filectxs = iter(fctx for fctx, _origline in self._links)
        palette = colormap.makeannotatepalette(filectxs, curdate,
                                               maxcolors=32, maxhues=8,
                                               maxsaturations=16,
                                               mindate=mindate)
        for i, (color, fctxs) in enumerate(palette.iteritems()):
            self.markerDefine(qsci.Background, i)
            self.setMarkerBackgroundColor(QColor(color), i)
            for fctx in fctxs:
                self._revmarkers[fctx.rev()] = i
Beispiel #10
0
def test_makeannotatepalette_mindate_included():
    agestep = 10 * SECS_PER_DAY
    filectxs = [
        fakectx(0, 0 * agestep),
        fakectx(0, 1 * agestep),
        fakectx(0, 2 * agestep),
        fakectx(0, 3 * agestep),
        fakectx(0, 4 * agestep),
        fakectx(0, 5 * agestep),
        fakectx(0, 6 * agestep),
        fakectx(0, 7 * agestep)
    ]
    palette = colormap.makeannotatepalette(filectxs,
                                           now=7 * agestep,
                                           maxcolors=4,
                                           maxhues=4,
                                           maxsaturations=255,
                                           mindate=2 * agestep)
    palfctxs = set()
    for _color, fctxs in palette.iteritems():
        palfctxs.update(fctxs)
    for fctx in filectxs[2:]:
        assert fctx in palfctxs