Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 488/remove mutable default args in io model #692

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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