def test_load_palette(self): """ Tests load_palette """ expected_first = [0.89411764,0.10196078,0.10980392] expected_last = [0.8,0.8,0.8] expected_length = 74 color_palette = util.load_palette("brewer") actual_length = len(color_palette) actual_first = color_palette[0] actual_last = color_palette[-1] self.assertEqual(expected_length, actual_length, msg="Number of colors in palette") self.assertEqual(3, len(color_palette[0]), msg="Ensuring colors have 3 values for RGB format") for exp, act in zip(expected_first, actual_first): diff = abs(exp - act) self.assertTrue(diff < 0.0001, msg="First color in palette" +\ "\n Expected: " + str(expected_first) + \ "\n Actual: " + str(actual_first)) for exp, act in zip(expected_last, actual_last): diff = abs(exp - act) self.assertTrue(diff < 0.0001, msg="First color in palette" +\ "\n Expected: " + str(expected_last) + \ "\n Actual: " + str(actual_last))
def __init__(self, parent, color_set): super(ColorSetWidget, self).__init__(parent, style=wx.SIMPLE_BORDER) self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.color_set = color_set self.palette = load_palette("brewer") self.mapped_coloring = map_coloring(self.palette, color_set) self.sizer.Add(self.get_color_set_panel()) self.SetSizer(self.sizer)
def set_graph(self, graph, coloring, palette_name='brewer'): """Set the graph to display""" self.graph = graph self.palette = load_palette(palette_name) self.coloring = coloring self.mapped_coloring = map_coloring(self.palette, self.coloring) self.DG = DecompositionGenerator(self.graph, self.coloring) self.update_graph_display(set())
def set_graph(self, graph, colorings, palette_name='brewer'): """Set the graph to display""" self.coloring_index = 0 self.graph = graph self.palette = load_palette(palette_name) self.colorings = colorings self.mapped_colorings = map_colorings(self.palette, self.colorings) self.graph_layout(0) self.update_graph_display(reset_zoom=True)
def __init__(self, graph, pattern, tdd, dptable, coloring, palette_name): self.graph = graph self.pattern = pattern self.tdd = tdd self.dptable = dptable self.coloring = coloring self.palette = load_palette(palette_name) self.mapped_coloring = map_coloring(self.palette, self.coloring) self.isomorphism_list = None self.get_patterns()
def add_tabs(self, palette_name='brewer'): """Add a new tab to the Listbook with an appropriate label""" self.palette = load_palette(palette_name) self.mapped_colorings = map_colorings(self.palette, self.colorings) self.pos = None icons = [self.get_icon(coloring) for coloring in self.mapped_colorings] icons.append(self.get_total_icon()) il = wx.ImageList(self.w, self.h) self.add_image_list(icons) # Add coloring tabs for i in range(len(icons)-1): tab = CombinePage(self, -1, set(self.colorings[i]), self.colors, self.pattern_size, self.min_size) self.listbook.AddPage(tab, '', imageId=i) # Add total tab tab = CombinePage(self, -1, self.colors, self.colors, self.pattern_size, self.min_size, self.counts_per_colorset, is_totals_page=True) self.listbook.AddPage(tab, '', imageId=len(icons)-1)