MCPcopy Index your code
hub / github.com/plotly/plotly.py / validate_scatterplotmatrix

Function validate_scatterplotmatrix

plotly/figure_factory/_scatterplot.py:80–142  ·  view source on GitHub ↗

Validates basic inputs for FigureFactory.create_scatterplotmatrix() :raises: (PlotlyError) If pandas is not imported :raises: (PlotlyError) If pandas dataframe is not inputted :raises: (PlotlyError) If pandas dataframe has <= 1 columns :raises: (PlotlyError) If diagonal plot ch

(df, index, diag, colormap_type, **kwargs)

Source from the content-addressed store, hash-verified

78
79
80def validate_scatterplotmatrix(df, index, diag, colormap_type, **kwargs):
81 """
82 Validates basic inputs for FigureFactory.create_scatterplotmatrix()
83
84 :raises: (PlotlyError) If pandas is not imported
85 :raises: (PlotlyError) If pandas dataframe is not inputted
86 :raises: (PlotlyError) If pandas dataframe has <= 1 columns
87 :raises: (PlotlyError) If diagonal plot choice (diag) is not one of
88 the viable options
89 :raises: (PlotlyError) If colormap_type is not a valid choice
90 :raises: (PlotlyError) If kwargs contains 'size', 'color' or
91 'colorscale'
92 """
93 if not pd:
94 raise ImportError(
95 "FigureFactory.scatterplotmatrix requires a pandas DataFrame."
96 )
97
98 # Check if pandas dataframe
99 if not isinstance(df, pd.core.frame.DataFrame):
100 raise exceptions.PlotlyError(
101 "Dataframe not inputed. Please "
102 "use a pandas dataframe to pro"
103 "duce a scatterplot matrix."
104 )
105
106 # Check if dataframe is 1 column or less
107 if len(df.columns) <= 1:
108 raise exceptions.PlotlyError(
109 "Dataframe has only one column. To "
110 "use the scatterplot matrix, use at "
111 "least 2 columns."
112 )
113
114 # Check that diag parameter is a valid selection
115 if diag not in DIAG_CHOICES:
116 raise exceptions.PlotlyError(
117 "Make sure diag is set to one of {}".format(DIAG_CHOICES)
118 )
119
120 # Check that colormap_types is a valid selection
121 if colormap_type not in VALID_COLORMAP_TYPES:
122 raise exceptions.PlotlyError(
123 "Must choose a valid colormap type. "
124 "Either 'cat' or 'seq' for a cate"
125 "gorical and sequential colormap "
126 "respectively."
127 )
128
129 # Check for not 'size' or 'color' in 'marker' of **kwargs
130 if "marker" in kwargs:
131 FORBIDDEN_PARAMS = ["size", "color", "colorscale"]
132 if any(param in kwargs["marker"] for param in FORBIDDEN_PARAMS):
133 raise exceptions.PlotlyError(
134 "Your kwargs dictionary cannot "
135 "include the 'size', 'color' or "
136 "'colorscale' key words inside "
137 "the marker dict since 'size' is "

Callers 1

create_scatterplotmatrixFunction · 0.85

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected