Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfef7af

Browse filesBrowse files
committed
Fixed differences between Plus_2_Colorscale with master
2 parents e34082a + bd6f150 commit dfef7af
Copy full SHA for dfef7af

File tree

Expand file treeCollapse file tree

2 files changed

+569
-305
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+569
-305
lines changed

‎plotly/tests/test_optional/test_figure_factory.py

Copy file name to clipboardExpand all lines: plotly/tests/test_optional/test_figure_factory.py
+79-37Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,6 @@ def test_valid_colormap(self):
627627
self.assertRaises(PlotlyError, tls.FigureFactory.create_trisurf,
628628
x, y, z, simplices, colormap='foo')
629629

630-
# check that colormap is a list, if not a string
631-
632-
pattern1 = (
633-
"If 'colormap' is a list, then its items must be tripets of the "
634-
"form a,b,c or 'rgbx,y,z' where a,b,c are between 0 and 1 "
635-
"inclusive and x,y,z are between 0 and 255 inclusive."
636-
)
637-
638-
self.assertRaisesRegexp(PlotlyError, pattern1,
639-
tls.FigureFactory.create_trisurf,
640-
x, y, z, simplices, colormap=3)
641-
642630
# check: if colormap is a list of rgb color strings, make sure the
643631
# entries of each color are no greater than 255.0
644632

@@ -650,20 +638,31 @@ def test_valid_colormap(self):
650638
self.assertRaisesRegexp(PlotlyError, pattern2,
651639
tls.FigureFactory.create_trisurf,
652640
x, y, z, simplices,
653-
colormap=['rgb(1, 2, 3)', 'rgb(4, 5, 600)'])
641+
colormap=['rgb(4, 5, 600)'])
654642

655643
# check: if colormap is a list of tuple colors, make sure the entries
656644
# of each tuple are no greater than 1.0
657645

658646
pattern3 = (
659-
"Whoops! The elements in your rgb colormap tuples "
660-
"cannot exceed 1.0."
647+
"Whoops! The elements in your colormap tuples cannot exceed 1.0."
661648
)
662649

663650
self.assertRaisesRegexp(PlotlyError, pattern3,
664651
tls.FigureFactory.create_trisurf,
665652
x, y, z, simplices,
666-
colormap=[(0.2, 0.4, 0.6), (0.8, 1.0, 1.2)])
653+
colormap=[(0.8, 1.0, 1.2)])
654+
655+
# check:
656+
657+
pattern4 = (
658+
"You must input a valid colormap. Valid types include a plotly "
659+
"scale, rgb, hex or tuple color, or lastly a list of any color "
660+
"types."
661+
)
662+
663+
self.assertRaisesRegexp(PlotlyError, pattern4,
664+
tls.FigureFactory.create_trisurf,
665+
x, y, z, simplices, colormap=1)
667666

668667
def test_trisurf_all_args(self):
669668

@@ -865,27 +864,55 @@ def test_same_data_in_index(self):
865864
tls.FigureFactory.create_scatterplotmatrix,
866865
df, index='apple')
867866

868-
def test_valid_palette(self):
867+
def test_valid_colormap(self):
869868

870-
# check: the palette argument is in a acceptable form
869+
# check: the colormap argument is in a valid form
871870
df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
872871
columns=['a', 'b', 'c'])
873872

874-
self.assertRaisesRegexp(PlotlyError, "You must pick a valid "
875-
"plotly colorscale name.",
876-
tls.FigureFactory.create_scatterplotmatrix,
877-
df, use_theme=True, index='a',
878-
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')
879877

880878
pattern = (
881-
"The items of 'palette' must be tripets of the form a,b,c or "
882-
"'rgbx,y,z' where a,b,c belong to the interval 0,1 and x,y,z "
883-
"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."
884882
)
885883

884+
# check: accepted data type for colormap
886885
self.assertRaisesRegexp(PlotlyError, pattern,
887886
tls.FigureFactory.create_scatterplotmatrix,
888-
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')
889916

890917
def test_valid_endpts(self):
891918

@@ -900,20 +927,35 @@ def test_valid_endpts(self):
900927

901928
self.assertRaisesRegexp(PlotlyError, pattern,
902929
tls.FigureFactory.create_scatterplotmatrix,
903-
df, use_theme=True, index='a',
904-
palette='Blues', endpts='foo')
930+
df, index='a', colormap='Hot', endpts='foo')
905931

906932
# check: the endpts are a list of numbers
907933
self.assertRaisesRegexp(PlotlyError, pattern,
908934
tls.FigureFactory.create_scatterplotmatrix,
909-
df, use_theme=True, index='a',
910-
palette='Blues', endpts=['a'])
935+
df, index='a', colormap='Hot', endpts=['a'])
911936

912937
# check: endpts is a list of INCREASING numbers
913938
self.assertRaisesRegexp(PlotlyError, pattern,
914939
tls.FigureFactory.create_scatterplotmatrix,
915-
df, use_theme=True, index='a',
916-
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)
917959

918960
def test_scatter_plot_matrix(self):
919961

@@ -926,7 +968,7 @@ def test_scatter_plot_matrix(self):
926968

927969
test_scatter_plot_matrix = tls.FigureFactory.create_scatterplotmatrix(
928970
df=df, diag='scatter', height=1000, width=1000, size=13,
929-
title='Scatterplot Matrix', use_theme=False
971+
title='Scatterplot Matrix'
930972
)
931973

932974
exp_scatter_plot_matrix = {
@@ -1020,17 +1062,17 @@ def test_scatter_plot_matrix_kwargs(self):
10201062
test_scatter_plot_matrix = tls.FigureFactory.create_scatterplotmatrix(
10211063
df, index='Fruit', endpts=[-10, -1], diag='histogram',
10221064
height=1000, width=1000, size=13, title='Scatterplot Matrix',
1023-
use_theme=True, palette='YlOrRd', marker=dict(symbol=136)
1065+
colormap='YlOrRd', marker=dict(symbol=136)
10241066
)
10251067

10261068
exp_scatter_plot_matrix = {
1027-
'data': [{'marker': {'color': 'rgb(128.0, 0.0, 38.0)'},
1069+
'data': [{'marker': {'color': 'rgb(128,0,38)'},
10281070
'showlegend': False,
10291071
'type': 'histogram',
10301072
'x': [2, -15, -2, 0],
10311073
'xaxis': 'x1',
10321074
'yaxis': 'y1'},
1033-
{'marker': {'color': 'rgb(255.0, 255.0, 204.0)'},
1075+
{'marker': {'color': 'rgb(255,255,204)'},
10341076
'showlegend': False,
10351077
'type': 'histogram',
10361078
'x': [6, 5],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.