1
1
from __future__ import absolute_import
2
2
3
+ import collections
3
4
import math
4
5
5
6
from plotly import colors , exceptions , optional_imports
11
12
pd = optional_imports .get_module ('pandas' )
12
13
13
14
15
+ def is_sequence (obj ):
16
+ return (isinstance (obj , collections .Sequence ) and
17
+ not isinstance (obj , basestring ))
18
+
19
+
14
20
def _bullet (df , markers , measures , ranges , subtitles , titles , orientation ,
15
21
range_colors , measure_colors , horizontal_spacing ,
16
22
vertical_spacing , scatter_options , layout_options ):
@@ -255,11 +261,11 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
255
261
"'pandas' must be installed for this figure factory."
256
262
)
257
263
258
- if isinstance (data , ( tuple , list ) ):
264
+ if is_sequence (data ):
259
265
if not all (isinstance (item , dict ) for item in data ):
260
266
raise exceptions .PlotlyError (
261
- 'Every entry of the data argument (a list or tuple) must be '
262
- 'a dictionary.'
267
+ 'Every entry of the data argument (list, tuple, etc ) must '
268
+ 'be a dictionary.'
263
269
)
264
270
265
271
elif not isinstance (data , pd .DataFrame ):
@@ -270,7 +276,7 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
270
276
271
277
# make DataFrame from data with correct column headers
272
278
col_names = ['titles' , 'subtitle' , 'markers' , 'measures' , 'ranges' ]
273
- if isinstance (data , ( tuple , list ) ):
279
+ if is_sequence (data ):
274
280
df = pd .DataFrame (
275
281
[
276
282
[d [titles ] for d in data ] if titles else ['' ] * len (data ),
0 commit comments