Hello everyone,
I am using bokeh to generate plots within an IPython Notebook. When the total number of plots that I have produced grows large (~50) and the larger of the plots contain many objects (say ~1000 circles), then a “maximal recursion depth reached” exception is thrown. The traceback is reproduced below.
The curious thing is that, even though the recursion seems tied to the objects contained within a given plot, this error only gets thrown when there are many plots in the notebook. Just plotting the last polt (which throws the exception) on its own works fine.
I am using bokeh 0.4.2.
Any ideas what exactly is going on and how to fix this?
Felix
<details class='elided'>
<summary title='Show trimmed content'>···</summary>
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-fd97b705660d> in <module>()
5 if len(list(partitions(n))) > 0:
6 print "n = %d, m = %d, k = %d, i = %d" % (n,m,k,i)
----> 7 show_partitions(n,m,title="n = %d, m = %d, k = %d, i = %d" % (n,m,k,i))
<ipython-input-4-351574fe308f> in show_partitions(n, m, small_circles, title)
49 plot.y_range = plot.x_range.clone()
50
---> 51 show()
/Library/Python/2.7/site-packages/bokeh/plotting.pyc in show(browser, new)
336 controller.open(_config["output_url"] + "/bokeh", new=new_param)
337 elif output_type == "notebook":
--> 338 session.show(curplot())
339
340 def save(filename=None):
/Library/Python/2.7/site-packages/bokeh/session/notebook_sessions.pyc in show(self, *objects)
38 """
39 import IPython.core.displaypub as displaypub
---> 40 displaypub.publish_display_data('bokeh', {'text/html': self.dumps(*objects)})
41
42
/Library/Python/2.7/site-packages/bokeh/session/notebook_sessions.pyc in dumps(self, *objects)
58 modelid = plot_ref["id"],
59 modeltype = plot_ref["type"],
---> 60 all_models = self.serialize_models(objects))
61
62 plot_div = self._load_template(self.div_template).render(elementid=elementid)
/Library/Python/2.7/site-packages/bokeh/session/base_json_session.pyc in serialize_models(self, objects, **jsonkwargs)
80
81 def serialize_models(self, objects=None, **jsonkwargs):
---> 82 return self.serialize(self.convert_models(objects), **jsonkwargs)
83
/Library/Python/2.7/site-packages/bokeh/session/base_json_session.pyc in convert_models(self, to_convert)
66 all = set(to_convert)
67 for model in to_convert:
---> 68 children = recursively_traverse_plot_object(model)
69 all.update(children)
70
/Library/Python/2.7/site-packages/bokeh/objects.pyc in recursively_traverse_plot_object(plot_object, traversed_ids, children)
155 child,
156 traversed_ids=traversed_ids,
--> 157 children=children)
158 return children
159
/Library/Python/2.7/site-packages/bokeh/objects.pyc in recursively_traverse_plot_object(plot_object, traversed_ids, children)
155 child,
156 traversed_ids=traversed_ids,
--> 157 children=children)
158 return children
159
... and so on recursively ...
/Library/Python/2.7/site-packages/bokeh/objects.pyc in recursively_traverse_plot_object(plot_object, traversed_ids, children)
146 return children
147 else:
--> 148 immediate_children = plot_object.references()
149 children.add(plot_object)
150 traversed_ids.add(plot_object._id)
/Library/Python/2.7/site-packages/bokeh/objects.pyc in references(self)
224 """Returns all PlotObjects that this object has references to
225 """
--> 226 return traverse_plot_object(self)
227
228 #---------------------------------------------------------------------
/Library/Python/2.7/site-packages/bokeh/objects.pyc in traverse_plot_object(plot_object)
133 children.add(obj)
134 return obj
--> 135 for prop in plot_object.properties_with_refs():
136 val = getattr(plot_object, prop)
137 json_apply(val, check_func, func)
/Library/Python/2.7/site-packages/bokeh/properties.pyc in properties_with_refs(cls)
547 if not hasattr(cls, "__cached_allprops_with_refs"):
548 s = accumulate_from_subclasses(cls,
--> 549 "__properties_with_refs__")
550 cls.__cached_allprops_with_refs = s
551 return cls.__cached_allprops_with_refs
/Library/Python/2.7/site-packages/bokeh/properties.pyc in accumulate_from_subclasses(cls, propname)
500 s = set()
501 for c in inspect.getmro(cls):
--> 502 if issubclass(c, HasProps):
503 s.update(getattr(c, propname))
504 return s
RuntimeError: maximum recursion depth exceeded while calling a Python object