34
34
35
35
## JSON encoding
36
36
numeric_list = [1 , 2 , 3 ]
37
- np_list = np .array ([1 , 2 , 3 , np .NaN , np .NAN , np . Inf , dt (2014 , 1 , 5 )])
37
+ np_list = np .array ([1 , 2 , 3 , np .nan , np .inf , dt (2014 , 1 , 5 )])
38
38
mixed_list = [
39
39
1 ,
40
40
"A" ,
45
45
dt_list = [dt (2014 , 1 , 5 ), dt (2014 , 1 , 5 , 1 , 1 , 1 ), dt (2014 , 1 , 5 , 1 , 1 , 1 , 1 )]
46
46
47
47
df = pd .DataFrame (
48
- columns = ["col 1" ], data = [1 , 2 , 3 , dt (2014 , 1 , 5 ), pd .NaT , np .NaN , np .Inf ]
48
+ columns = ["col 1" ], data = [1 , 2 , 3 , dt (2014 , 1 , 5 ), pd .NaT , np .nan , np .inf ]
49
49
)
50
50
51
51
rng = pd .date_range ("1/1/2011" , periods = 2 , freq = "H" )
@@ -184,7 +184,7 @@ def test_figure_json_encoding(self):
184
184
185
185
assert (
186
186
js1 == '{"type": "scatter3d", "x": [1, 2, 3], '
187
- '"y": [1, 2, 3, null, null, null, "2014-01-05T00:00:00"], '
187
+ '"y": [1, 2, 3, null, null, "2014-01-05T00:00:00"], '
188
188
'"z": [1, "A", "2014-01-05T00:00:00", '
189
189
'"2014-01-05T01:01:01", "2014-01-05T01:01:01.000001"]}'
190
190
)
@@ -195,9 +195,9 @@ def test_figure_json_encoding(self):
195
195
_json .dumps (figure , cls = utils .PlotlyJSONEncoder , sort_keys = True )
196
196
197
197
# Test data wasn't mutated
198
- np_array = np .array ([1 , 2 , 3 , np .NaN , np .NAN , np . Inf , dt (2014 , 1 , 5 )])
198
+ np_array = np .array ([1 , 2 , 3 , np .nan , np .inf , dt (2014 , 1 , 5 )])
199
199
for k in range (len (np_array )):
200
- if k in [ 3 , 4 ] :
200
+ if k == 3 :
201
201
# check NaN
202
202
assert np .isnan (np_list [k ]) and np .isnan (np_array [k ])
203
203
else :
@@ -237,7 +237,7 @@ def test_pandas_json_encoding(self):
237
237
# Test that data wasn't mutated
238
238
assert_series_equal (
239
239
df ["col 1" ],
240
- pd .Series ([1 , 2 , 3 , dt (2014 , 1 , 5 ), pd .NaT , np .NaN , np .Inf ], name = "col 1" ),
240
+ pd .Series ([1 , 2 , 3 , dt (2014 , 1 , 5 ), pd .NaT , np .nan , np .inf ], name = "col 1" ),
241
241
)
242
242
243
243
j2 = _json .dumps (df .index , cls = utils .PlotlyJSONEncoder )
0 commit comments