In [1]:
import numpy as np
from bokeh.io import output_notebook, show
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

output_notebook()


BokehJS successfully loaded.

In [2]:
source = ColumnDataSource()
x = list(range(0, 6))
source.add(name="x", data=x)

y = list()
y.append([np.nan]*6)
y.append([None]*3 + [np.nan]*3)
y.append([np.nan]*3 + [None]*3)
y.append([1.0]*3 + [np.nan]*3)
y.append([np.nan]*3 + [1.0]*3)
y.append([None]*2 + [np.nan]*2 + [None]*2)
y.append([np.nan]*2 + [None]*2 + [np.nan]*2)
y.append([1.0]*2 + [np.nan]*2 + [1.0]*2)
y.append([np.nan]*2 + [1.0]*2 + [np.nan]*2)

for idx,yi in enumerate(y):
    source.add(name="y%d"%idx, data=yi)
    source.add(name="yr%d"%idx, data=np.array(yi))
    
p = figure()
for idx in range(0, len(y)):
    p.scatter("x", "y%d"%idx, source=source)
    p.scatter("x", "yr%d"%idx, source=source)
show(p)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-fe8960b8666b> in <module>()
     22     p.scatter("x", "y%d"%idx, source=source)
     23     p.scatter("x", "yr%d"%idx, source=source)
---> 24 show(p)

/home/bird/Dev/bokeh/bokeh/bokeh/io.py in show(obj, browser, new)
    235 
    236     '''
--> 237     _show_with_state(obj, _state, browser, new)
    238 
    239 def _show_with_state(obj, state, browser, new):

/home/bird/Dev/bokeh/bokeh/bokeh/io.py in _show_with_state(obj, state, browser, new)
    242 
    243     if state.notebook:
--> 244         _show_notebook_with_state(obj, state)
    245 
    246     elif state.session:

/home/bird/Dev/bokeh/bokeh/bokeh/io.py in _show_notebook_with_state(obj, state)
    260         publish_display_data({'text/html': snippet})
    261     else:
--> 262         publish_display_data({'text/html': notebook_div(obj)})
    263 
    264 def _show_server_with_state(obj, state, new, controller):

/home/bird/Dev/bokeh/bokeh/bokeh/embed.py in notebook_div(plot_object)
    159 
    160     js = PLOT_JS.render(
--> 161         all_models = serialize_json(plot_object.dump()),
    162         plots = plots
    163     )

/home/bird/Dev/bokeh/bokeh/bokeh/protocol.py in serialize_json(obj, encoder, **kwargs)
     84     if settings.pretty(False):
     85         kwargs["indent"] = 4
---> 86     return json.dumps(obj, cls=encoder, allow_nan=False, **kwargs)
     87 
     88 deserialize_json = json.loads

/opt/miniconda/envs/bokeh_dev_py34/lib/python3.4/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    235         check_circular=check_circular, allow_nan=allow_nan, indent=indent,
    236         separators=separators, default=default, sort_keys=sort_keys,
--> 237         **kw).encode(obj)
    238 
    239 

/opt/miniconda/envs/bokeh_dev_py34/lib/python3.4/json/encoder.py in encode(self, o)
    190         # exceptions aren't as detailed.  The list call should be roughly
    191         # equivalent to the PySequence_Fast that ''.join() would do.
--> 192         chunks = self.iterencode(o, _one_shot=True)
    193         if not isinstance(chunks, (list, tuple)):
    194             chunks = list(chunks)

/opt/miniconda/envs/bokeh_dev_py34/lib/python3.4/json/encoder.py in iterencode(self, o, _one_shot)
    248                 self.key_separator, self.item_separator, self.sort_keys,
    249                 self.skipkeys, _one_shot)
--> 250         return _iterencode(o, 0)
    251 
    252 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

ValueError: Out of range float values are not JSON compliant

In [3]:
source2 = ColumnDataSource()
x2 = list(range(0, 6))
source2.add(name="x", data=x2)

y2 = list()
y2.append(['NaN']*6)
y2.append([None]*3 + ['NaN']*3)
y2.append(['NaN']*3 + [None]*3)
y2.append([1.0]*3 + ['NaN']*3)
y2.append(['NaN']*3 + [1.0]*3)
y2.append([None]*2 + ['NaN']*2 + [None]*2)
y2.append(['NaN']*2 + [None]*2 + ['NaN']*2)
y2.append([1.0]*2 + ['NaN']*2 + [1.0]*2)
y2.append(['NaN']*2 + [1.0]*2 + ['NaN']*2)

for idx,yi in enumerate(y2):
    source2.add(name="y%d"%idx, data=yi)
    source2.add(name="yr%d"%idx, data=np.array(yi))
    
p2 = figure()
for idx in range(0, len(y2)):
    p2.scatter("x", "y%d"%idx, source=source2)
    p2.scatter("x", "yr%d"%idx, source=source2)
show(p2)



In [ ]: