Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d239f13

Browse files
committed
json cls encoders recurse, so no need to index
1 parent bad0359 commit d239f13

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

plotly/utils.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,8 @@ def numpyJSONEncoder(self, obj):
105105
return float('nan')
106106

107107
if type(obj).__module__.split('.')[0] == numpy.__name__:
108-
l = obj.tolist()
109-
try:
110-
return self.datetimeJSONEncoder(l)
111-
except NotEncodable:
112-
return l
108+
return obj.tolist()
109+
113110
else:
114111
raise NotEncodable
115112

@@ -133,12 +130,6 @@ def datetimeJSONEncoder(self, obj):
133130
return obj.strftime('%Y-%m-%d %H:%M:%S')
134131
else:
135132
return obj.strftime('%Y-%m-%d')
136-
elif isinstance(obj[0], (datetime.datetime, datetime.date)):
137-
return [o.strftime(
138-
'%Y-%m-%d %H:%M:%S.%f') if o.microsecond else
139-
o.strftime('%Y-%m-%d %H:%M:%S') if any((o.second, o.minute, o.hour)) else
140-
o.strftime('%Y-%m-%d')
141-
for o in obj]
142133
else:
143134
raise NotEncodable
144135

0 commit comments

Comments
 (0)