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

Function validate_coerce_fig_to_dict

plotly/io/_utils.py:8–27  ·  view source on GitHub ↗
(fig, validate)

Source from the content-addressed store, hash-verified

6
7
8def validate_coerce_fig_to_dict(fig, validate):
9 from plotly.basedatatypes import BaseFigure
10
11 if isinstance(fig, BaseFigure):
12 fig_dict = fig.to_dict()
13 elif isinstance(fig, dict):
14 if validate:
15 # This will raise an exception if fig is not a valid plotly figure
16 fig_dict = plotly.graph_objs.Figure(fig).to_plotly_json()
17 else:
18 fig_dict = fig
19 elif hasattr(fig, "to_plotly_json"):
20 fig_dict = fig.to_plotly_json()
21 else:
22 raise ValueError(
23 """
24The fig parameter must be a dict or Figure.
25 Received value of type {typ}: {v}""".format(typ=type(fig), v=fig)
26 )
27 return fig_dict
28
29
30def validate_coerce_output_type(output_type):

Callers 7

_repr_mimebundle_Method · 0.90
to_htmlFunction · 0.90
to_jsonFunction · 0.90
showFunction · 0.90
to_imageFunction · 0.90
to_imageFunction · 0.90
write_imagesFunction · 0.90

Calls 3

to_dictMethod · 0.80
to_plotly_jsonMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected