File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,15 @@ def get_serializer(data, allow_pickle):
49
49
return _serialize_dataframe
50
50
elif _is_torch_tensor (data ):
51
51
return _serialize_torch_tensor
52
- elif allow_pickle :
52
+ elif module_name == 'builtins' and class_name == 'module' and not allow_pickle :
53
+ try :
54
+ import matplotlib
55
+ if data == matplotlib .pyplot :
56
+ return _serialize_matplotlib
57
+ except ImportError :
58
+ pass
59
+
60
+ if allow_pickle :
53
61
return _serialize_pickle
54
62
return None
55
63
@@ -63,6 +71,16 @@ def _serialize_plotly_figure(data):
63
71
data = plotly .io .to_json (data , 'json' )
64
72
return data , mimetype
65
73
74
+ @check_extra ("plot" )
75
+ def _serialize_matplotlib (data ):
76
+ try :
77
+ import plotly
78
+ except ImportError :
79
+ return None
80
+ mimetype = 'application/vnd.plotly.v1+json'
81
+ data = plotly .io .to_json (plotly .tools .mpl_to_plotly (data .gcf ()), 'json' )
82
+ return data , mimetype
83
+
66
84
@check_extra ("plot" )
67
85
def _serialize_matplotlib_figure (data ):
68
86
try :
You can’t perform that action at this time.
0 commit comments