@@ -864,27 +864,55 @@ def test_same_data_in_index(self):
864
864
tls .FigureFactory .create_scatterplotmatrix ,
865
865
df , index = 'apple' )
866
866
867
- def test_valid_palette (self ):
867
+ def test_valid_colormap (self ):
868
868
869
- # check: the palette argument is in a acceptable form
869
+ # check: the colormap argument is in a valid form
870
870
df = pd .DataFrame ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]],
871
871
columns = ['a' , 'b' , 'c' ])
872
872
873
- self .assertRaisesRegexp (PlotlyError , "You must pick a valid "
874
- "plotly colorscale name." ,
875
- tls .FigureFactory .create_scatterplotmatrix ,
876
- df , use_theme = True , index = 'a' ,
877
- palette = 'fake_scale' )
873
+ # check: valid plotly scalename is entered
874
+ self .assertRaises (PlotlyError ,
875
+ tls .FigureFactory .create_scatterplotmatrix ,
876
+ df , index = 'a' , colormap = 'fake_scale' )
878
877
879
878
pattern = (
880
- "The items of 'palette' must be tripets of the form a,b,c or "
881
- "'rgbx,y,z' where a,b,c belong to the interval 0,1 and x,y,z "
882
- "belong to 0,255 ."
879
+ "You must input a valid colormap. Valid types include a plotly "
880
+ "scale, rgb, hex or tuple color, a list of any color types, or a "
881
+ "dictionary with index names each assigned to a color ."
883
882
)
884
883
884
+ # check: accepted data type for colormap
885
885
self .assertRaisesRegexp (PlotlyError , pattern ,
886
886
tls .FigureFactory .create_scatterplotmatrix ,
887
- df , use_theme = True , palette = 1 , index = 'c' )
887
+ df , colormap = 1 )
888
+
889
+ pattern_rgb = (
890
+ "Whoops! The elements in your rgb colormap tuples cannot "
891
+ "exceed 255.0."
892
+ )
893
+
894
+ # check: proper 'rgb' color
895
+ self .assertRaisesRegexp (PlotlyError , pattern_rgb ,
896
+ tls .FigureFactory .create_scatterplotmatrix ,
897
+ df , colormap = 'rgb(500, 1, 1)' , index = 'c' )
898
+
899
+ self .assertRaisesRegexp (PlotlyError , pattern_rgb ,
900
+ tls .FigureFactory .create_scatterplotmatrix ,
901
+ df , colormap = ['rgb(500, 1, 1)' ], index = 'c' )
902
+
903
+ pattern_tuple = (
904
+ "Whoops! The elements in your colormap tuples cannot "
905
+ "exceed 1.0."
906
+ )
907
+
908
+ # check: proper color tuple
909
+ self .assertRaisesRegexp (PlotlyError , pattern_tuple ,
910
+ tls .FigureFactory .create_scatterplotmatrix ,
911
+ df , colormap = (2 , 1 , 1 ), index = 'c' )
912
+
913
+ self .assertRaisesRegexp (PlotlyError , pattern_tuple ,
914
+ tls .FigureFactory .create_scatterplotmatrix ,
915
+ df , colormap = [(2 , 1 , 1 )], index = 'c' )
888
916
889
917
def test_valid_endpts (self ):
890
918
@@ -899,20 +927,35 @@ def test_valid_endpts(self):
899
927
900
928
self .assertRaisesRegexp (PlotlyError , pattern ,
901
929
tls .FigureFactory .create_scatterplotmatrix ,
902
- df , use_theme = True , index = 'a' ,
903
- palette = 'Blues' , endpts = 'foo' )
930
+ df , index = 'a' , colormap = 'Hot' , endpts = 'foo' )
904
931
905
932
# check: the endpts are a list of numbers
906
933
self .assertRaisesRegexp (PlotlyError , pattern ,
907
934
tls .FigureFactory .create_scatterplotmatrix ,
908
- df , use_theme = True , index = 'a' ,
909
- palette = 'Blues' , endpts = ['a' ])
935
+ df , index = 'a' , colormap = 'Hot' , endpts = ['a' ])
910
936
911
937
# check: endpts is a list of INCREASING numbers
912
938
self .assertRaisesRegexp (PlotlyError , pattern ,
913
939
tls .FigureFactory .create_scatterplotmatrix ,
914
- df , use_theme = True , index = 'a' ,
915
- palette = 'Blues' , endpts = [2 , 1 ])
940
+ df , index = 'a' , colormap = 'Hot' , endpts = [2 , 1 ])
941
+
942
+ def test_dictionary_colormap (self ):
943
+
944
+ # if colormap is a dictionary, make sure it all the values in the
945
+ # index column are keys in colormap
946
+ df = pd .DataFrame ([['apple' , 'happy' ], ['pear' , 'sad' ]],
947
+ columns = ['Fruit' , 'Emotion' ])
948
+
949
+ colormap = {'happy' : 'rgb(5, 5, 5)' }
950
+
951
+ pattern = (
952
+ "If colormap is a dictionary, all the names in the index "
953
+ "must be keys."
954
+ )
955
+
956
+ self .assertRaisesRegexp (PlotlyError , pattern ,
957
+ tls .FigureFactory .create_scatterplotmatrix ,
958
+ df , index = 'Emotion' , colormap = colormap )
916
959
917
960
def test_scatter_plot_matrix (self ):
918
961
@@ -925,7 +968,7 @@ def test_scatter_plot_matrix(self):
925
968
926
969
test_scatter_plot_matrix = tls .FigureFactory .create_scatterplotmatrix (
927
970
df = df , diag = 'scatter' , height = 1000 , width = 1000 , size = 13 ,
928
- title = 'Scatterplot Matrix' , use_theme = False
971
+ title = 'Scatterplot Matrix'
929
972
)
930
973
931
974
exp_scatter_plot_matrix = {
@@ -1019,17 +1062,17 @@ def test_scatter_plot_matrix_kwargs(self):
1019
1062
test_scatter_plot_matrix = tls .FigureFactory .create_scatterplotmatrix (
1020
1063
df , index = 'Fruit' , endpts = [- 10 , - 1 ], diag = 'histogram' ,
1021
1064
height = 1000 , width = 1000 , size = 13 , title = 'Scatterplot Matrix' ,
1022
- use_theme = True , palette = 'YlOrRd' , marker = dict (symbol = 136 )
1065
+ colormap = 'YlOrRd' , marker = dict (symbol = 136 )
1023
1066
)
1024
1067
1025
1068
exp_scatter_plot_matrix = {
1026
- 'data' : [{'marker' : {'color' : 'rgb(128.0, 0.0, 38.0 )' },
1069
+ 'data' : [{'marker' : {'color' : 'rgb(128,0,38 )' },
1027
1070
'showlegend' : False ,
1028
1071
'type' : 'histogram' ,
1029
1072
'x' : [2 , - 15 , - 2 , 0 ],
1030
1073
'xaxis' : 'x1' ,
1031
1074
'yaxis' : 'y1' },
1032
- {'marker' : {'color' : 'rgb(255.0, 255.0, 204.0 )' },
1075
+ {'marker' : {'color' : 'rgb(255, 255, 204)' },
1033
1076
'showlegend' : False ,
1034
1077
'type' : 'histogram' ,
1035
1078
'x' : [6 , 5 ],
0 commit comments