def test_kws_Error(self): # box text strip with self.assertRaises(TypeError): Sankey(df_layer, colorMode="global").plot(box_kws=5) with self.assertRaises(TypeError): Sankey(df_layer, colorMode="global").plot(text_kws=[1, 2]) with self.assertRaises(TypeError): Sankey(df_layer, colorMode="global").plot(strip_kws='strip')
def test_LabelMismatch_Error(self): mism_cls = { 'blueberrys': '#1f77b4', 'abcs': '#aec7e8', 'lime': '#ff7f0e', 'orange': '#ffbb78', 'apple': '#2ca02c' } mism_lyr_cls = { 'layer1': { 'blueberry': '#1f77b4', 'banana': '#aec7e8', 'lime': '#ff7f0e', 'orange': '#ffbb78', 'apple': '#2ca02c' }, 'layer2': { 'blueberry': '#1f77b4', 'abcs': '#ff7f0e', 'lime': '#2ca02c', 'orange': '#d62728', 'apple': '#9467bd' } } # Color mismatch with Label with self.assertRaises(LabelMismatchError): Sankey(df, colorDict=mism_cls, colorMode="global") with self.assertRaises(LabelMismatchError): Sankey(df, colorDict=mism_lyr_cls, colorMode="global") # Layer mismatch with DF mism_labs = { 'layer1': ['apple', 'abs', 'blueberry', 'lime', 'orange'], 'layer2': ['apple', 'banana', 'blueberry', 'lime', 'orange'] } with self.assertRaises(LabelMismatchError): Sankey(df_layer, colorMode="global", layerLabels=mism_labs)
# colors global_colors = dict(zip(global_labels, setColorConf(len(global_labels)))) layer_colors = { "From": dict(zip(set(df.From), setColorConf(len(set(df.From))))), "To": dict(zip(set(df.To), setColorConf(len(set(df.From)), colors="tab10"))) } # colnames mapping colmaps = {'From': 'layer1', 'To': 'layer2'} colmaps_layer = {'layer1': 'layer1', 'layer2': 'layer2'} # provided layerlabels # auto mode sky_auto_global_colors = Sankey(df, colorMode="global") sky_auto_layer_colors = Sankey(df, colorMode="layer") # provided colors global & layer mode sky_provided_global_colors = Sankey(df, colorDict=global_colors, colorMode="global") sky_provided_layer_colors = Sankey(df, colorDict=layer_colors, colorMode="layer") # provided layerlabels sky_provided_layer_labels = Sankey( df_layer, #colorDict=colors, colorMode="global",
def test_colorMode_Error(self): with self.assertRaises(ValueError): Sankey(df, colorMode="glb")
def test_LabelMismatch_Error(self): mism_cls = { 'abc': '#1f77b4', 'USA': '#aec7e8', 'Japan': '#ff7f0e', 'India': '#ffbb78', 'Brazil': '#2ca02c', 'England': '#98df8a', 'China': '#d62728', 'Spain': '#ff9896', 'Mexico': '#9467bd', 'Canada': '#c5b0d5', 'South Africa': '#8c564b' } mism_lyr_cls = { 'layer1': { 'abc': '#1f77b4', 'USA': '#aec7e8', 'Japan': '#ff7f0e', 'India': '#ffbb78', 'Brazil': '#2ca02c', 'England': '#98df8a', 'China': '#d62728', 'Spain': '#ff9896', 'Mexico': '#9467bd', 'Canada': '#c5b0d5', 'South Africa': '#8c564b' }, 'layer2': { 'Senegal': '#8dd3c7', 'USA': '#ffffb3', 'Angola': '#bebada', 'Japan': '#fb8072', 'India': '#80b1d3', 'Brazil': '#fdb462', 'England': '#b3de69', 'China': '#fccde5', 'Spain': '#d9d9d9', 'Mexico': '#bc80bd', 'Canada': '#ccebc5' }, 'layer3': { 'Senegal': '#a6cee3', 'USA': '#1f78b4', 'Japan': '#b2df8a', 'Brazil': '#33a02c', 'England': '#fb9a99', 'China': '#e31a1c', 'Spain': '#fdbf6f', 'Mexico': '#ff7f00', 'Canada': '#cab2d6', 'South Africa': '#6a3d9a' } } # Color mismatch with Label with self.assertRaises(LabelMismatchError): Sankey(df, colorDict=mism_cls, colorMode="global") with self.assertRaises(LabelMismatchError): Sankey(df, colorDict=mism_lyr_cls, colorMode="global") # Layer mismatch with DF mism_labs = { 'layer1': [ 'abc', 'Mexico', 'India', 'USA', 'China', 'England', 'Brazil', 'Canada', 'Senegal', 'Spain', 'Japan' ], 'layer2': [ 'abc', 'Mexico', 'India', 'USA', 'China', 'England', 'Brazil', 'Senegal', 'Canada', 'Angola', 'Japan' ], 'layer3': [ 'abc', 'South Africa', 'Mexico', 'USA', 'China', 'England', 'Brazil', 'Senegal', 'Canada', 'Japan' ] } with self.assertRaises(LabelMismatchError): Sankey(df_layer, colorMode="global", layerLabels=mism_labs)