@@ -38,7 +38,7 @@ def test_column_json_encoding():
3838 Column (np_list , 'col 3' )
3939 ]
4040 json_columns = json .dumps (
41- columns , cls = utils ._plotlyJSONEncoder , sort_keys = True
41+ columns , cls = utils .PlotlyJSONEncoder , sort_keys = True
4242 )
4343 assert ('[{"data": [1, 2, 3], "name": "col 1"}, '
4444 '{"data": [1, "A", "2014-01-05", '
@@ -56,8 +56,8 @@ def test_figure_json_encoding():
5656 data = Data ([s1 , s2 ])
5757 figure = Figure (data = data )
5858
59- js1 = json .dumps (s1 , cls = utils ._plotlyJSONEncoder , sort_keys = True )
60- js2 = json .dumps (s2 , cls = utils ._plotlyJSONEncoder , sort_keys = True )
59+ js1 = json .dumps (s1 , cls = utils .PlotlyJSONEncoder , sort_keys = True )
60+ js2 = json .dumps (s2 , cls = utils .PlotlyJSONEncoder , sort_keys = True )
6161
6262 assert (js1 == '{"type": "scatter3d", "x": [1, 2, 3], '
6363 '"y": [1, 2, 3, NaN, NaN, Infinity, "2014-01-05"], '
@@ -66,8 +66,8 @@ def test_figure_json_encoding():
6666 assert (js2 == '{"type": "scatter", "x": [1, 2, 3]}' )
6767
6868 # Test JSON encoding works
69- json .dumps (data , cls = utils ._plotlyJSONEncoder , sort_keys = True )
70- json .dumps (figure , cls = utils ._plotlyJSONEncoder , sort_keys = True )
69+ json .dumps (data , cls = utils .PlotlyJSONEncoder , sort_keys = True )
70+ json .dumps (figure , cls = utils .PlotlyJSONEncoder , sort_keys = True )
7171
7272 # Test data wasn't mutated
7373 assert (bool (np .asarray (np_list ==
@@ -79,47 +79,48 @@ def test_figure_json_encoding():
7979
8080
8181def test_datetime_json_encoding ():
82- j1 = json .dumps (dt_list , cls = utils ._plotlyJSONEncoder )
82+ j1 = json .dumps (dt_list , cls = utils .PlotlyJSONEncoder )
8383 assert (j1 == '["2014-01-05", '
8484 '"2014-01-05 01:01:01", '
8585 '"2014-01-05 01:01:01.000001"]' )
86- j2 = json .dumps ({"x" : dt_list }, cls = utils ._plotlyJSONEncoder )
86+ j2 = json .dumps ({"x" : dt_list }, cls = utils .PlotlyJSONEncoder )
8787 assert (j2 == '{"x": ["2014-01-05", '
8888 '"2014-01-05 01:01:01", '
8989 '"2014-01-05 01:01:01.000001"]}' )
9090
9191
9292def test_pandas_json_encoding ():
93- j1 = json .dumps (df ['col 1' ], cls = utils ._plotlyJSONEncoder )
93+ j1 = json .dumps (df ['col 1' ], cls = utils .PlotlyJSONEncoder )
9494 assert (j1 == '[1, 2, 3, "2014-01-05", null, NaN, Infinity]' )
9595
9696 # Test that data wasn't mutated
9797 assert_series_equal (df ['col 1' ],
9898 pd .Series ([1 , 2 , 3 , dt (2014 , 1 , 5 ),
9999 pd .NaT , np .NaN , np .Inf ]))
100100
101- j2 = json .dumps (df .index , cls = utils ._plotlyJSONEncoder )
101+ j2 = json .dumps (df .index , cls = utils .PlotlyJSONEncoder )
102102 assert (j2 == '[0, 1, 2, 3, 4, 5, 6]' )
103103
104104 nat = [pd .NaT ]
105- j3 = json .dumps (nat , cls = utils ._plotlyJSONEncoder )
105+ j3 = json .dumps (nat , cls = utils .PlotlyJSONEncoder )
106106 assert (j3 == '[null]' )
107107 assert (nat [0 ] is pd .NaT )
108108
109- j4 = json .dumps (rng , cls = utils ._plotlyJSONEncoder )
109+ j4 = json .dumps (rng , cls = utils .PlotlyJSONEncoder )
110110 assert (j4 == '["2011-01-01", "2011-01-01 01:00:00"]' )
111111
112- j5 = json .dumps (ts , cls = utils ._plotlyJSONEncoder )
112+ j5 = json .dumps (ts , cls = utils .PlotlyJSONEncoder )
113113 assert (j5 == '[1.5, 2.5]' )
114114 assert_series_equal (ts , pd .Series ([1.5 , 2.5 ], index = rng ))
115115
116- j6 = json .dumps (ts .index , cls = utils ._plotlyJSONEncoder )
116+ j6 = json .dumps (ts .index , cls = utils .PlotlyJSONEncoder )
117117 assert (j6 == '["2011-01-01", "2011-01-01 01:00:00"]' )
118118
119119
120120def test_numpy_masked_json_encoding ():
121121 l = [1 , 2 , np .ma .core .masked ]
122- j1 = json .dumps (l , cls = utils ._plotlyJSONEncoder )
122+ j1 = json .dumps (l , cls = utils .PlotlyJSONEncoder )
123+ print j1
123124 assert (j1 == '[1, 2, NaN]' )
124125 assert (set (l ) == set ([1 , 2 , np .ma .core .masked ]))
125126
@@ -142,23 +143,23 @@ def test_masked_constants_example():
142143 renderer = PlotlyRenderer ()
143144 Exporter (renderer ).run (fig )
144145
145- json .dumps (renderer .plotly_fig , cls = utils ._plotlyJSONEncoder )
146+ json .dumps (renderer .plotly_fig , cls = utils .PlotlyJSONEncoder )
146147
147148 jy = json .dumps (renderer .plotly_fig ['data' ][1 ]['y' ],
148- cls = utils ._plotlyJSONEncoder )
149+ cls = utils .PlotlyJSONEncoder )
149150 assert (jy == '[-398.11793026999999, -398.11792966000002, '
150151 '-398.11786308000001, NaN]' )
151152
152153
153154def test_numpy_dates ():
154155 a = np .arange (np .datetime64 ('2011-07-11' ), np .datetime64 ('2011-07-18' ))
155- j1 = json .dumps (a , cls = utils ._plotlyJSONEncoder )
156+ j1 = json .dumps (a , cls = utils .PlotlyJSONEncoder )
156157 assert (j1 == '["2011-07-11", "2011-07-12", "2011-07-13", '
157158 '"2011-07-14", "2011-07-15", "2011-07-16", '
158159 '"2011-07-17"]' )
159160
160161
161162def test_datetime_dot_date ():
162163 a = [datetime .date (2014 , 1 , 1 ), datetime .date (2014 , 1 , 2 )]
163- j1 = json .dumps (a , cls = utils ._plotlyJSONEncoder )
164+ j1 = json .dumps (a , cls = utils .PlotlyJSONEncoder )
164165 assert (j1 == '["2014-01-01", "2014-01-02"]' )
0 commit comments