Skip to content

Commit

Permalink
Merge 132c00d into 201ab38
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Dec 19, 2018
2 parents 201ab38 + 132c00d commit 1ba46f9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions holoviews/core/pprint.py
Expand Up @@ -378,12 +378,12 @@ def option_info(cls_or_slf, node):
return opts

@bothmethod
def format_options(cls_or_slf, opts, wrap_count=80):
def format_options(cls_or_slf, opts, wrap_count=100):
opt_repr = str(opts)
cls_name = type(opts).__name__
indent = ' '*(len(cls_name)+1)
wrapper = textwrap.TextWrapper(width=wrap_count, subsequent_indent=indent)
return [' '+l for l in wrapper.wrap(opt_repr)]
return [' | '+l for l in wrapper.wrap(opt_repr)]

@bothmethod
def adjointlayout_info(cls_or_slf, node, siblings, level, value_dims):
Expand Down
12 changes: 6 additions & 6 deletions holoviews/tests/core/testprettyprint.py
Expand Up @@ -47,29 +47,29 @@ def setUp(self):
def test_element_options(self):
element = TestObj(None).opts(style_opt1='A', backend='backend_1')
r = self.pprinter.pprint(element)
self.assertEqual(r, ":TestObj\n Options(style_opt1='A')")
self.assertEqual(r, ":TestObj\n | Options(style_opt1='A')")

def test_element_options_wrapping(self):
element = TestObj(None).opts(plot_opt1='A'*40, style_opt1='B'*40, backend='backend_1')
r = self.pprinter.pprint(element)
self.assertEqual(r, ":TestObj\n Options(plot_opt1='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',\n style_opt1='BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB')")
self.assertEqual(r, ":TestObj\n | Options(plot_opt1='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',\n | style_opt1='BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB')")

def test_overlay_options(self):
overlay = (TestObj(None) * TestObj(None)).opts(plot_opt1='A')
r = self.pprinter.pprint(overlay)
self.assertEqual(r, ":Overlay\n Options(plot_opt1='A')\n .Element.I :TestObj\n .Element.II :TestObj")
self.assertEqual(r, ":Overlay\n | Options(plot_opt1='A')\n .Element.I :TestObj\n .Element.II :TestObj")

def test_overlay_nested_options(self):
overlay = (TestObj(None) * TestObj(None)).opts('TestObj', plot_opt1='A', style_opt1='A')
r = self.pprinter.pprint(overlay)
self.assertEqual(r, ":Overlay\n .Element.I :TestObj\n Options(plot_opt1='A', style_opt1='A')\n .Element.II :TestObj\n Options(plot_opt1='A', style_opt1='A')")
self.assertEqual(r, ":Overlay\n .Element.I :TestObj\n | Options(plot_opt1='A', style_opt1='A')\n .Element.II :TestObj\n | Options(plot_opt1='A', style_opt1='A')")

def test_layout_options(self):
overlay = (TestObj(None) + TestObj(None)).opts(plot_opt1='A')
r = self.pprinter.pprint(overlay)
self.assertEqual(r, ":Layout\n Options(plot_opt1='A')\n .Element.I :TestObj\n .Element.II :TestObj")
self.assertEqual(r, ":Layout\n | Options(plot_opt1='A')\n .Element.I :TestObj\n .Element.II :TestObj")

def test_layout_nested_options(self):
overlay = (TestObj(None) + TestObj(None)).opts('TestObj', plot_opt1='A', style_opt1='A')
r = self.pprinter.pprint(overlay)
self.assertEqual(r, ":Layout\n .Element.I :TestObj\n Options(plot_opt1='A', style_opt1='A')\n .Element.II :TestObj\n Options(plot_opt1='A', style_opt1='A')")
self.assertEqual(r, ":Layout\n .Element.I :TestObj\n | Options(plot_opt1='A', style_opt1='A')\n .Element.II :TestObj\n | Options(plot_opt1='A', style_opt1='A')")
28 changes: 14 additions & 14 deletions holoviews/util/__init__.py
Expand Up @@ -477,18 +477,12 @@ class output(param.ParameterizedFunction):
are ignored.
"""

filename_warning = param.Boolean(default=True, doc="""
Whether to warn if the output utility is called on an object and
a filename is not given (in which case the utility has no
effect)""" )

def __call__(self, *args, **options):
warn = options.pop('filename_warning', self.filename_warning)
help_prompt = 'For help with hv.util.output call help(hv.util.output)'
line, obj = None,None
if len(args) > 2:
raise TypeError('The opts utility accepts one or two positional arguments.')
if len(args) == 1 and options:
if len(args) == 1 and not isinstance(args[0], basestring):
obj = args[0]
elif len(args) == 1:
line = args[0]
Expand All @@ -502,13 +496,19 @@ def __call__(self, *args, **options):
if k not in Store.output_settings.allowed:
raise KeyError('Invalid keyword: %s' % k)
if 'filename' in options:
def save_fn(obj, renderer): renderer.save(obj, options['filename'])
Store.output_settings.output(line=line, cell=obj, cell_runner=save_fn,
help_prompt=help_prompt, **options)
elif warn:
self.warning("hv.output not supplied a filename to export the "
"given object. This call will have no effect." )
return obj
if util.config.future_deprecations:
self.warning('The filename argument of output is deprecated. '
'Use hv.save instead.')

def display_fn(obj, renderer):
try:
from IPython.display import display
except:
return
display(obj)

Store.output_settings.output(line=line, cell=obj, cell_runner=display_fn,
help_prompt=help_prompt, **options)
elif obj is not None:
return obj
else:
Expand Down

0 comments on commit 1ba46f9

Please sign in to comment.