11
11
import numpy as np
12
12
import json
13
13
import pandas as pd
14
+ import sys
14
15
from pandas .util .testing import assert_series_equal
15
16
import matplotlib .pyplot as plt
16
17
@@ -27,7 +28,7 @@ def test_encode_as_plotly(self):
27
28
28
29
# should *fail* when object doesn't have `to_plotly_json` attribute
29
30
objs_without_attr = [
30
- 1 , 'one' , { 'a' , 'set' } , {'a' : 'dict' }, ['a' , 'list' ]
31
+ 1 , 'one' , set ([ 'a' , 'set' ]) , {'a' : 'dict' }, ['a' , 'list' ]
31
32
]
32
33
for obj in objs_without_attr :
33
34
self .assertRaises (utils .NotEncodable ,
@@ -48,7 +49,7 @@ def test_encode_as_list(self):
48
49
49
50
# should *fail* when object doesn't have `tolist` method
50
51
objs_without_attr = [
51
- 1 , 'one' , { 'a' , 'set' } , {'a' : 'dict' }, ['a' , 'list' ]
52
+ 1 , 'one' , set ([ 'a' , 'set' ]) , {'a' : 'dict' }, ['a' , 'list' ]
52
53
]
53
54
for obj in objs_without_attr :
54
55
self .assertRaises (utils .NotEncodable ,
@@ -75,7 +76,7 @@ def test_encode_as_pandas(self):
75
76
76
77
# should succeed when we've got specific pandas thingies
77
78
res = utils .PlotlyJSONEncoder .encode_as_pandas (pd .NaT )
78
- self .assertIs (res , None )
79
+ self .assertTrue (res is None )
79
80
80
81
def test_encode_as_numpy (self ):
81
82
@@ -132,7 +133,7 @@ def test_encode_as_date(self):
132
133
utils .PlotlyJSONEncoder .encode_as_date , obj )
133
134
134
135
# should work with a date
135
- a_date = datetime .date (2013 , 10 , 01 )
136
+ a_date = datetime .date (2013 , 10 , 1 )
136
137
res = utils .PlotlyJSONEncoder .encode_as_date (a_date )
137
138
self .assertEqual (res , '2013-10-01' )
138
139
@@ -248,9 +249,8 @@ def test_pandas_json_encoding():
248
249
def test_numpy_masked_json_encoding ():
249
250
l = [1 , 2 , np .ma .core .masked ]
250
251
j1 = json .dumps (l , cls = utils .PlotlyJSONEncoder )
251
- print j1
252
+ print ( j1 )
252
253
assert (j1 == '[1, 2, null]' )
253
- assert (set (l ) == set ([1 , 2 , np .ma .core .masked ]))
254
254
255
255
256
256
def test_masked_constants_example ():
@@ -275,8 +275,9 @@ def test_masked_constants_example():
275
275
276
276
jy = json .dumps (renderer .plotly_fig ['data' ][1 ]['y' ],
277
277
cls = utils .PlotlyJSONEncoder )
278
- assert (jy == '[-398.11793026999999, -398.11792966000002, '
279
- '-398.11786308000001, null]' )
278
+ print (jy )
279
+ array = json .loads (jy )
280
+ assert (array == [- 398.11793027 , - 398.11792966 , - 398.11786308 , None ])
280
281
281
282
282
283
def test_numpy_dates ():
0 commit comments