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

Raise KeyError when attempting to slice Layout #1295

merged 3 commits into from Apr 14, 2017
Changes from 2 commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+16 −1
Diff settings


Just for now

@@ -529,6 +529,9 @@ def __getitem__(self, key):
if key < len(self):
raise KeyError("Element out of range.")
elif isinstance(key, slice):
raise KeyError("A Layout may not be sliced, ensure that you "
"are slicing on a leaf (i.e. not a branch) of the Layout.")

This comment has been minimized.

Copy link

jlstevens Apr 14, 2017


maybe 'leaf node' or 'leaf item'?

if len(key) == 2 and not any([isinstance(k, str) for k in key]):
if key == (slice(None), slice(None)): return self
row, col = key
@@ -1,6 +1,6 @@
import numpy as np

from holoviews import Image, HLine, VLine
from holoviews import Image, HLine, VLine, Text, Arrow, Annotation
from holoviews.element.comparison import ComparisonTestCase

class AnnotationTests(ComparisonTestCase):
@@ -18,3 +18,15 @@ def test_vline_dimension_values(self):
hline = VLine(0)
self.assertEqual(hline.range(0), (0, 0))
self.assertEqual(hline.range(1), (None, None))

def test_deep_clone_map_select_redim(self):
annotations = (Text(0, 0, 'A') + Arrow(0, 0) + HLine(0) + VLine(0))
selected =, 5))
redimmed = selected.redim(x='z')
relabelled = redimmed.relabel(label='foo', depth=5)
mapped = x: x.clone(group='bar'), Annotation)
kwargs = dict(label='foo', group='bar', extents=(0, None, 5, None), kdims=['z', 'y'])
self.assertEqual(mapped.Text.I, Text(0, 0, 'A', **kwargs))
self.assertEqual(mapped.Arrow.I, Arrow(0, 0, **kwargs))
self.assertEqual(mapped.HLine.I, HLine(0, **kwargs))
self.assertEqual(mapped.VLine.I, VLine(0, **kwargs))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.