Skip to content

Commit

Permalink
Handle the empty string as a group name (#5131)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbednar authored and philippjfr committed Nov 16, 2021
1 parent 2176344 commit f094d4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ def tree_attribute(identifier):
These custom attributes start with a capitalized character when
applicable (not applicable to underscore or certain unicode characters)
"""
if identifier == '':
return True
if identifier[0].upper().isupper() is False and identifier[0] != '_':
return True
else:
Expand Down Expand Up @@ -1826,7 +1828,10 @@ def capitalize(string):
"""
Capitalizes the first letter of a string.
"""
return string[0].upper() + string[1:]
if string:
return string[0].upper() + string[1:]
else:
return string


def get_path(item):
Expand Down
9 changes: 8 additions & 1 deletion holoviews/tests/core/testoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from unittest import SkipTest

import numpy as np
from holoviews import Store, Histogram, Image, Curve, Points, DynamicMap, opts

from holoviews import Store, Histogram, Image, Curve, Points, DynamicMap, opts, util
from holoviews.core.options import (
OptionError, Cycle, Options, OptionTree, StoreOptions, options_policy
)
Expand Down Expand Up @@ -309,6 +310,12 @@ def initialize_option_tree(self):
options.Image = Options('style', cmap='hot', interpolation='nearest')
return options

def test_empty_group(self):
"Test to prevent regression of issue fixed in #5131"
ls = np.linspace(0, 10, 200)
xx, yy = np.meshgrid(ls, ls)
util.render(Image(np.sin(xx)*np.cos(yy), group="").opts(cmap="greys"))

def test_merge_keywords(self):
options = self.initialize_option_tree()
options.Image = Options('style', clims=(0, 0.5))
Expand Down

0 comments on commit f094d4b

Please sign in to comment.