11from __future__ import absolute_import
22
3+ import collections
34import math
45
56from plotly import colors , exceptions , optional_imports
1112pd = optional_imports .get_module ('pandas' )
1213
1314
15+ def is_sequence (obj ):
16+ return (isinstance (obj , collections .Sequence ) and
17+ not isinstance (obj , basestring ))
18+
19+
1420def _bullet (df , markers , measures , ranges , subtitles , titles , orientation ,
1521 range_colors , measure_colors , horizontal_spacing ,
1622 vertical_spacing , scatter_options , layout_options ):
@@ -255,11 +261,11 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
255261 "'pandas' must be installed for this figure factory."
256262 )
257263
258- if isinstance (data , ( tuple , list ) ):
264+ if is_sequence (data ):
259265 if not all (isinstance (item , dict ) for item in data ):
260266 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.'
263269 )
264270
265271 elif not isinstance (data , pd .DataFrame ):
@@ -270,7 +276,7 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
270276
271277 # make DataFrame from data with correct column headers
272278 col_names = ['titles' , 'subtitle' , 'markers' , 'measures' , 'ranges' ]
273- if isinstance (data , ( tuple , list ) ):
279+ if is_sequence (data ):
274280 df = pd .DataFrame (
275281 [
276282 [d [titles ] for d in data ] if titles else ['' ] * len (data ),
0 commit comments