Added unit test for applying methods to Annotations
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 @@ class AnnotationTests(ComparisonTestCase):
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 = annotations.select(x=(0, 5))
+ redimmed = selected.redim(x='z')
+ relabelled = redimmed.relabel(label='foo', depth=5)
+ mapped = relabelled.map(lambda 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))
