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

Handle the empty string as a group name #5131

Merged
merged 3 commits into from
Nov 16, 2021
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
7 changes: 6 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,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 @@ -1750,7 +1752,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
7 changes: 7 additions & 0 deletions holoviews/tests/core/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import pytest

from holoviews import util
from holoviews import Store, Histogram, Image, Curve, Points, DynamicMap, opts
from holoviews.core.options import (
OptionError, Cycle, Options, OptionTree, StoreOptions, options_policy
Expand Down Expand Up @@ -313,6 +314,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