Skip to content

Commit

Permalink
Issue 488/remove mutable default args in io model (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaje authored and philippjfr committed Oct 12, 2019
1 parent 559c09a commit 3ccd6c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions panel/io/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from .state import state


#---------------------------------------------------------------------
# Public API
#---------------------------------------------------------------------
Expand Down Expand Up @@ -62,11 +61,16 @@ def add_to_doc(obj, doc, hold=False):
doc.hold()


def bokeh_repr(obj, depth=0, ignored=['children', 'text', 'name', 'toolbar', 'renderers', 'below', 'center', 'left', 'right']):
_DEFAULT_IGNORED_REPR = frozenset(['children', 'text', 'name', 'toolbar', 'renderers', 'below', 'center', 'left', 'right'])

def bokeh_repr(obj, depth=0, ignored=None):
"""
Returns a string repr for a bokeh model, useful for recreating
panel objects using pure bokeh.
"""
if ignored is None:
ignored = _DEFAULT_IGNORED_REPR

from ..viewable import Viewable
if isinstance(obj, Viewable):
obj = obj.get_root(Document())
Expand Down
8 changes: 7 additions & 1 deletion panel/io/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def save_png(model, filename):
#---------------------------------------------------------------------

def save(panel, filename, title=None, resources=None, template=None,
template_variables={}, embed=False, max_states=1000,
template_variables=None, embed=False, max_states=1000,
max_opts=3, embed_json=False, json_prefix='', save_path='./',
load_path=None):
"""
Expand All @@ -62,6 +62,10 @@ def save(panel, filename, title=None, resources=None, template=None,
Optional title for the plot
resources: bokeh resources
One of the valid bokeh.resources (e.g. CDN or INLINE)
template:
template file, as used by bokeh.file_html. If None will use bokeh defaults
template_variables:
template_variables file dict, as used by bokeh.file_html
embed: bool
Whether the state space should be embedded in the saved file.
max_states: int
Expand Down Expand Up @@ -101,6 +105,8 @@ def save(panel, filename, title=None, resources=None, template=None,
resources = CDN
if template:
kwargs['template'] = template
if template_variables:
kwargs['template_variables'] = template_variables

html = file_html(doc, resources, title, **kwargs)
if hasattr(filename, 'write'):
Expand Down

0 comments on commit 3ccd6c5

Please sign in to comment.