示例#1
0
    def test_continous_color_cycle_combo(self):
        color_cycler = (cycler('color', ['r', 'g', 'b']))
        marker_cycler = (cycler('marker', ['o', '+', 's']))
        line_cycler = (cycler('linestyle', ['-', '--', '-.']))

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()
        color_line_cycle = utils.ContinousColorCycle(color_cycle,
                                                     color_cycle_len,
                                                     line_cycler,
                                                     used_style_color_combo)
        color_marker_cycle = utils.ContinousColorCycle(color_cycle,
                                                       color_cycle_len,
                                                       marker_cycler,
                                                       used_style_color_combo)

        res = []
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_marker_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res = tuple(res)
        print(str(res))
        assert res == ((('color', 'r'), ('linestyle', '-')),
                       (('color', 'g'), ('linestyle', '-')),
                       (('color', 'b'), ('marker', 'o')), (('color', 'b'),
                                                           ('linestyle', '-')))
    def test_continous_color_cycle_combo(self):
        color_cycler = (cycler('color', ['r', 'g', 'b']))
        marker_cycler = (cycler('marker', ['o', '+', 's']))
        line_cycler = (cycler('linestyle', ['-', '--', '-.']))

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()
        color_line_cycle = utils.ContinousColorCycle(color_cycle, color_cycle_len, line_cycler, used_style_color_combo)
        color_marker_cycle = utils.ContinousColorCycle(color_cycle, color_cycle_len, marker_cycler, used_style_color_combo)


        res = []
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_marker_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res = tuple(res)
        print(str(res))
        assert res == ((('color', 'r'), ('linestyle', '-')), (('color', 'g'), ('linestyle', '-')), (('color', 'b'), ('marker', 'o')), (('color', 'b'), ('linestyle', '-')))
示例#3
0
    def test_continous_color_cycle_line_and_markers(self):
        #TODO: Test that i can also cycle line and markers. I mean the product line_cycler * marker_cycler
        color_cycler = (cycler('color', ['r', 'g', 'b']))
        marker_cycler = (cycler('marker', ['o', '+', 's']))
        line_cycler = (cycler('linestyle', ['-', '--', '-.']))

        style_cycler = (marker_cycler*line_cycler)

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()
        color_style_cycler = utils.ContinuousColorCycle(color_cycle, color_cycle_len, style_cycler, used_style_color_combo)
        color_line_cycle = utils.ContinuousColorCycle(color_cycle, color_cycle_len, line_cycler, used_style_color_combo)
        color_marker_cycle = utils.ContinuousColorCycle(color_cycle, color_cycle_len, marker_cycler,
                                                       used_style_color_combo)

        res = []
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_marker_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res = tuple(res)
        print(str(res))
        assert res == ((('color', 'r'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'g'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'b'), ('marker', 'o')),
                       (('color', 'r'), ('linestyle', '-')),
                       (('color', 'b'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'r'), ('linestyle', '--'), ('marker', 'o')))
    def test_continous_color_cycle_line_and_markers(self):
        #TODO: Test that i can also cycle line and markers. I mean the product line_cycler * marker_cycler
        color_cycler = (cycler('color', ['r', 'g', 'b']))
        marker_cycler = (cycler('marker', ['o', '+', 's']))
        line_cycler = (cycler('linestyle', ['-', '--', '-.']))

        style_cycler = (marker_cycler*line_cycler)

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()
        color_style_cycler = utils.ContinousColorCycle(color_cycle, color_cycle_len, style_cycler, used_style_color_combo)
        color_line_cycle = utils.ContinousColorCycle(color_cycle, color_cycle_len, line_cycler, used_style_color_combo)
        color_marker_cycle = utils.ContinousColorCycle(color_cycle, color_cycle_len, marker_cycler,
                                                       used_style_color_combo)

        res = []
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_marker_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res.append(dict_to_tuple(next(color_style_cycler)))
        res = tuple(res)
        print(str(res))
        assert res == ((('color', 'r'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'g'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'b'), ('marker', 'o')),
                       (('color', 'r'), ('linestyle', '-')),
                       (('color', 'b'), ('linestyle', '-'), ('marker', 'o')),
                       (('color', 'r'), ('linestyle', '--'), ('marker', 'o')))
示例#5
0
    def test_continous_color_cycle_ran_out(self, mock_np_random_rand,
                                           mock_messagebar):
        """Test that i can also cycle line and markers. I mean the product line_cycler * marker_cycler"""
        color_cycler = (cycler('color', ['r', 'g']))
        line_cycler = (cycler('linestyle', ['-', '--']))

        mock_np_random_rand.side_effect = np.array(['123', '456', '789'])

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()

        color_line_cycle = utils.ContinousColorCycle(color_cycle,
                                                     color_cycle_len,
                                                     line_cycler,
                                                     used_style_color_combo)

        res = []
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))

        res = tuple(res)
        print(str(res))
        print(str(mock_messagebar.mock_calls))
        assert res == ((('color', 'r'), ('linestyle', '-')),
                       (('color', 'g'), ('linestyle', '-')),
                       (('color', 'r'), ('linestyle', '--')),
                       (('color', 'g'), ('linestyle', '--')),
                       (('color', '123'), ('linestyle', '-')),
                       (('color', '456'),
                        ('linestyle', '--')), (('color', '789'), ('linestyle',
                                                                  '-')))
        assert mock_messagebar.mock_calls == [
            call.info(
                bar_msg=
                'Style cycler ran out of unique combinations. Using random color!'
            ),
            call.info(
                bar_msg=
                'Style cycler ran out of unique combinations. Using random color!'
            ),
            call.info(
                bar_msg=
                'Style cycler ran out of unique combinations. Using random color!'
            )
        ]
    def test_continous_color_cycle_ran_out(self, mock_np_random_rand, mock_messagebar):
        # TODO: Test that i can also cycle line and markers. I mean the product line_cycler * marker_cycler
        color_cycler = (cycler('color', ['r', 'g']))
        line_cycler = (cycler('linestyle', ['-', '--']))

        mock_np_random_rand.side_effect = ['123', '456', '789']

        color_cycle_len = len(color_cycler)
        color_cycle = color_cycler()

        used_style_color_combo = set()

        color_line_cycle = utils.ContinousColorCycle(color_cycle, color_cycle_len, line_cycler, used_style_color_combo)

        res = []
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))
        res.append(dict_to_tuple(next(color_line_cycle)))

        res = tuple(res)
        print(str(res))
        print(str(mock_messagebar.mock_calls))
        assert res == ((('color', 'r'), ('linestyle', '-')),
                       (('color', 'g'), ('linestyle', '-')),
                       (('color', 'r'), ('linestyle', '--')),
                       (('color', 'g'), ('linestyle', '--')),
                       (('color', '123'), ('linestyle', '-')),
                       (('color', '456'), ('linestyle', '--')),
                       (('color', '789'), ('linestyle', '-')))
        assert mock_messagebar.mock_calls == [call.info(bar_msg='Style cycler ran out of unique combinations. Using random color!'),
         call.info(bar_msg='Style cycler ran out of unique combinations. Using random color!'),
         call.info(bar_msg='Style cycler ran out of unique combinations. Using random color!')]